fix building on ancient compilers (#32)
* jit: allow building with ancient MSVC versions
Visual Studio older than 2013, fails to build with JIT enabled,
because it is unable to parse non C89 compatible syntax, with
mixed declarations and code.
While most recent compilers wouldn't even report this as a warning
since it is valid C99, it could be also made visible by adding to
gcc/clang the -Wdeclaration-after-statement flag at build time.
Move the code below the affected definitions.
* pcre2grep: avoid mixing declarations with code
Since d5a61ee8
(Patch to detect (and ignore) symlink loops in
pcre2grep., 2021-08-28), code will fail to build in a strict C89
compiler.
Reformat slightly to make it C89 compatible again.
This commit is contained in:
parent
bf2c8cc564
commit
128c50360c
|
@ -4202,9 +4202,6 @@ TMP2 is not used. Otherwise TMP2 must contain the start of the subject buffer,
|
||||||
and it is destroyed. Does not modify STR_PTR for invalid character sequences. */
|
and it is destroyed. Does not modify STR_PTR for invalid character sequences. */
|
||||||
DEFINE_COMPILER;
|
DEFINE_COMPILER;
|
||||||
|
|
||||||
SLJIT_UNUSED_ARG(backtracks);
|
|
||||||
SLJIT_UNUSED_ARG(must_be_valid);
|
|
||||||
|
|
||||||
#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32
|
#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32
|
||||||
struct sljit_jump *jump;
|
struct sljit_jump *jump;
|
||||||
#endif
|
#endif
|
||||||
|
@ -4278,6 +4275,10 @@ if (common->invalid_utf && !must_be_valid)
|
||||||
}
|
}
|
||||||
#endif /* PCRE2_CODE_UNIT_WIDTH == [8|16|32] */
|
#endif /* PCRE2_CODE_UNIT_WIDTH == [8|16|32] */
|
||||||
#endif /* SUPPORT_UNICODE */
|
#endif /* SUPPORT_UNICODE */
|
||||||
|
|
||||||
|
SLJIT_UNUSED_ARG(backtracks);
|
||||||
|
SLJIT_UNUSED_ARG(must_be_valid);
|
||||||
|
|
||||||
OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
|
OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14131,6 +14132,10 @@ PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
|
||||||
pcre2_jit_compile(pcre2_code *code, uint32_t options)
|
pcre2_jit_compile(pcre2_code *code, uint32_t options)
|
||||||
{
|
{
|
||||||
pcre2_real_code *re = (pcre2_real_code *)code;
|
pcre2_real_code *re = (pcre2_real_code *)code;
|
||||||
|
#ifdef SUPPORT_JIT
|
||||||
|
executable_functions *functions;
|
||||||
|
static int executable_allocator_is_working = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (code == NULL)
|
if (code == NULL)
|
||||||
return PCRE2_ERROR_NULL;
|
return PCRE2_ERROR_NULL;
|
||||||
|
@ -14165,8 +14170,7 @@ actions are needed:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef SUPPORT_JIT
|
#ifdef SUPPORT_JIT
|
||||||
executable_functions *functions = (executable_functions *)re->executable_jit;
|
functions = (executable_functions *)re->executable_jit;
|
||||||
static int executable_allocator_is_working = 0;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((options & PCRE2_JIT_INVALID_UTF) != 0)
|
if ((options & PCRE2_JIT_INVALID_UTF) != 0)
|
||||||
|
|
|
@ -3361,18 +3361,23 @@ if (isdirectory(pathname))
|
||||||
because that affects the output from pcre2grep. */
|
because that affects the output from pcre2grep. */
|
||||||
|
|
||||||
#ifdef HAVE_REALPATH
|
#ifdef HAVE_REALPATH
|
||||||
|
{
|
||||||
char resolvedpath[PATH_MAX];
|
char resolvedpath[PATH_MAX];
|
||||||
|
BOOL isSame;
|
||||||
|
size_t rlen;
|
||||||
if (realpath(childpath, resolvedpath) == NULL)
|
if (realpath(childpath, resolvedpath) == NULL)
|
||||||
continue; /* This path is invalid - we can skip processing this */
|
continue; /* This path is invalid - we can skip processing this */
|
||||||
BOOL isSame = strcmp(pathname, resolvedpath) == 0;
|
isSame = strcmp(pathname, resolvedpath) == 0;
|
||||||
if (isSame) continue; /* We have a recursion */
|
if (isSame) continue; /* We have a recursion */
|
||||||
size_t rlen = strlen(resolvedpath);
|
rlen = strlen(resolvedpath);
|
||||||
if (rlen++ < sizeof(resolvedpath) - 3)
|
if (rlen++ < sizeof(resolvedpath) - 3)
|
||||||
{
|
{
|
||||||
|
BOOL contained;
|
||||||
strcat(resolvedpath, "/");
|
strcat(resolvedpath, "/");
|
||||||
BOOL contained = strncmp(pathname, resolvedpath, rlen) == 0;
|
contained = strncmp(pathname, resolvedpath, rlen) == 0;
|
||||||
if (contained) continue; /* We have a recursion */
|
if (contained) continue; /* We have a recursion */
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif /* HAVE_REALPATH */
|
#endif /* HAVE_REALPATH */
|
||||||
|
|
||||||
frc = grep_or_recurse(childpath, dir_recurse, FALSE);
|
frc = grep_or_recurse(childpath, dir_recurse, FALSE);
|
||||||
|
|
Loading…
Reference in New Issue