Fix several bugs concerned with different configurations.

This commit is contained in:
Philip.Hazel 2014-10-15 15:57:49 +00:00
parent 29ae875dd7
commit 722817013c
9 changed files with 124 additions and 114 deletions

View File

@ -268,11 +268,11 @@ fi
# All of 8-bit, 16-bit, and 32-bit character strings may be supported, but only # All of 8-bit, 16-bit, and 32-bit character strings may be supported, but only
# one need be. # one need be.
$sim ./pcre2test -C pcre8 >/dev/null $sim ./pcre2test -C pcre2_8 >/dev/null
support8=$? support8=$?
$sim ./pcre2test -C pcre16 >/dev/null $sim ./pcre2test -C pcre2_16 >/dev/null
support16=$? support16=$?
$sim ./pcre2test -C pcre32 >/dev/null $sim ./pcre2test -C pcre2_32 >/dev/null
support32=$? support32=$?
# Initialize all bitsizes skipped # Initialize all bitsizes skipped
@ -686,6 +686,6 @@ fi
done done
# Clean up local working files # Clean up local working files
rm -f test3input test3output test3outputA testNinput testsaved* teststderr teststdout testtry rm -f test3input test3output test3outputA testNinput testsaved* teststdout testtry
# End # End

View File

@ -117,9 +117,9 @@ to the same value:
.sp .sp
ebcdic compiled for an EBCDIC environment ebcdic compiled for an EBCDIC environment
jit just-in-time support is available jit just-in-time support is available
pcre16 the 16-bit library was built pcre2_16 the 16-bit library was built
pcre32 the 32-bit library was built pcre2_32 the 32-bit library was built
pcre8 the 8-bit library was built pcre2_8 the 8-bit library was built
unicode Unicode support is available unicode Unicode support is available
.sp .sp
If an unknown option is given, an error message is output; the exit code is 0. If an unknown option is given, an error message is output; the exit code is 0.

View File

@ -84,7 +84,7 @@ fi
function runtest() function runtest()
{ {
rm -f *_unittest rm -f $srcdir/pcre2test $srcdir/pcre2grep $srcdir/pcre2_jit_test
testcount=`expr $testcount + 1` testcount=`expr $testcount + 1`
if [ "$opts" = "" ] ; then if [ "$opts" = "" ] ; then
@ -119,42 +119,53 @@ function runtest()
fi fi
nl=`./pcre2test -C newline` nl=`./pcre2test -C newline`
if [ "$nl" = "LF" -o "$nl" = "ANY" -o "$nl" = "ANYCRLF" ]; then
nlok=1
else
nlok=0
fi
./pcre2test -C jit >/dev/null ./pcre2test -C jit >/dev/null
jit=$? jit=$?
./pcre2test -C utf >/dev/null ./pcre2test -C unicode >/dev/null
utf=$? utf=$?
./pcre2test -C pcre2_8 >/dev/null
pcre2_8=$?
if [ "$nl" = "LF" -o "$nl" = "ANY" ]; then if [ $nlok -gt 0 ]; then
echo "Running C library tests $withvalgrind" echo "Running C library tests $withvalgrind"
$srcdir/RunTest $valgrind >teststdout $srcdir/RunTest $valgrind >teststdout 2>teststderr
if [ $? -ne 0 ]; then if [ $? -ne 0 -o -s teststderr ]; then
echo " " echo " "
echo "**** Test failed ****" echo "**** Test failed ****"
cat teststdout cat teststderr
if [ -s teststdout ] ; then cat teststdout; fi
exit 1 exit 1
fi fi
else else
echo "Skipping C library tests: newline is $nl" echo "Skipping C library tests: newline is $nl"
fi fi
if [ "$nl" = "LF" ]; then if [ $nlok -gt 0 -a $pcre2_8 -gt 0 ]; then
echo "Running pcre2grep tests $withvalgrind" echo "Running pcre2grep tests $withvalgrind"
$srcdir/RunGrepTest $valgrind >teststdout 2>teststderr $srcdir/RunGrepTest $valgrind >teststdout 2>teststderr
if [ $? -ne 0 ]; then if [ $? -ne 0 -o -s teststderr ]; then
echo " " echo " "
echo "**** Test failed ****" echo "**** Test failed ****"
cat teststderr cat teststderr
cat teststdout cat teststdout
exit 1 exit 1
fi fi
else elif [ $nlok -gt 0 ]; then
echo "Skipping pcre2grep tests: 8-bit library not compiled"
else
echo "Skipping pcre2grep tests: newline is $nl" echo "Skipping pcre2grep tests: newline is $nl"
fi fi
if [ "$jit" -gt 0 -a $utf -gt 0 ]; then if [ "$jit" -gt 0 -a $utf -gt 0 ]; then
echo "Running JIT regression tests $withvalgrind" echo "Running JIT regression tests $withvalgrind"
$cvalgrind $srcdir/pcre2_jit_test >teststdout 2>teststderr $cvalgrind $srcdir/pcre2_jit_test >teststdout 2>teststderr
if [ $? -ne 0 ]; then if [ $? -ne 0 -o -s teststderr ]; then
echo " " echo " "
echo "**** Test failed ****" echo "**** Test failed ****"
cat teststderr cat teststderr

View File

@ -53,9 +53,10 @@ locale using the pcre2_maketables() function, which is part of the PCRE2 API.
#include <string.h> #include <string.h>
#include <locale.h> #include <locale.h>
#define PCRE2_CODE_UNIT_WIDTH 0 /* Must be set, but not relevant here */
#include "pcre2_internal.h" #include "pcre2_internal.h"
#define DFTABLES /* pcre2_maketables.c notices this */ #define DFTABLES /* pcre2_maketables.c notices this */
#include "pcre2_maketables.c" #include "pcre2_maketables.c"
int main(int argc, char **argv) int main(int argc, char **argv)

View File

@ -972,7 +972,7 @@ for (;;)
{ {
PCRE2_SPTR temp = ptr + 1; PCRE2_SPTR temp = ptr + 1;
#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32
if (utf) { FORWARDCHAR(temp); } if (utf) { FORWARDCHARTEST(temp, mb->end_subject); }
#endif #endif
mb->last_used_ptr = temp; mb->last_used_ptr = temp;
} }

View File

@ -56,6 +56,7 @@ just to undefine them all. */
#undef BYTES2CU #undef BYTES2CU
#undef CU2BYTES #undef CU2BYTES
#undef FORWARDCHAR #undef FORWARDCHAR
#undef FORWARDCHARTEST
#undef GET #undef GET
#undef GET2 #undef GET2
#undef GETCHAR #undef GETCHAR
@ -261,6 +262,7 @@ UTF support is omitted, we don't even define them. */
/* #define GETCHARLENTEST(c, eptr, len) */ /* #define GETCHARLENTEST(c, eptr, len) */
/* #define BACKCHAR(eptr) */ /* #define BACKCHAR(eptr) */
/* #define FORWARDCHAR(eptr) */ /* #define FORWARDCHAR(eptr) */
/* #define FORWARCCHARTEST(eptr,end) */
/* #define ACROSSCHAR(condition, eptr, action) */ /* #define ACROSSCHAR(condition, eptr, action) */
#else /* SUPPORT_UNICODE */ #else /* SUPPORT_UNICODE */
@ -339,6 +341,7 @@ because almost all calls are already within a block of UTF-8 only code. */
/* Same as above, just in the other direction. */ /* Same as above, just in the other direction. */
#define FORWARDCHAR(eptr) while((*eptr & 0xc0) == 0x80) eptr++ #define FORWARDCHAR(eptr) while((*eptr & 0xc0) == 0x80) eptr++
#define FORWARDCHARTEST(eptr,end) while(eptr < end && (*eptr & 0xc0) == 0x80) eptr++
/* Same as above, but it allows a fully customizable form. */ /* Same as above, but it allows a fully customizable form. */
#define ACROSSCHAR(condition, eptr, action) \ #define ACROSSCHAR(condition, eptr, action) \
@ -444,6 +447,7 @@ code. */
/* Same as above, just in the other direction. */ /* Same as above, just in the other direction. */
#define FORWARDCHAR(eptr) if ((*eptr & 0xfc00) == 0xdc00) eptr++ #define FORWARDCHAR(eptr) if ((*eptr & 0xfc00) == 0xdc00) eptr++
#define FORWARDCHARTEST(eptr,end) if (eptr < end && (*eptr & 0xfc00) == 0xdc00) eptr++
/* Same as above, but it allows a fully customizable form. */ /* Same as above, but it allows a fully customizable form. */
#define ACROSSCHAR(condition, eptr, action) \ #define ACROSSCHAR(condition, eptr, action) \
@ -517,6 +521,7 @@ These are all no-ops since all UTF-32 characters fit into one pcre_uchar. */
/* Same as above, just in the other direction. */ /* Same as above, just in the other direction. */
#define FORWARDCHAR(eptr) do { } while (0) #define FORWARDCHAR(eptr) do { } while (0)
#define FORWARDCHARTEST(eptr,end) do { } while (0)
/* Same as above, but it allows a fully customizable form. */ /* Same as above, but it allows a fully customizable form. */

View File

@ -172,19 +172,13 @@ PCRE2_EXP_DEFN void PCRE2_CALL_CONVENTION
pcre2_jit_stack_free(pcre2_jit_stack *jit_stack) pcre2_jit_stack_free(pcre2_jit_stack *jit_stack)
{ {
#ifndef SUPPORT_JIT #ifndef SUPPORT_JIT
(void)jit_stack; (void)jit_stack;
#else /* SUPPORT_JIT */ #else /* SUPPORT_JIT */
/* Dummy code */
if (jit_stack != NULL) if (jit_stack != NULL)
{ {
sljit_free_stack((struct sljit_stack *)(jit_stack->stack), &jit_stack->memctl); sljit_free_stack((struct sljit_stack *)(jit_stack->stack), &jit_stack->memctl);
jit_stack->memctl.free(jit_stack, jit_stack->memctl.memory_data); jit_stack->memctl.free(jit_stack, jit_stack->memctl.memory_data);
} }
#endif /* SUPPORT_JIT */ #endif /* SUPPORT_JIT */
} }
@ -196,7 +190,11 @@ if (jit_stack != NULL)
const char* const char*
PRIV(jit_get_target)(void) PRIV(jit_get_target)(void)
{ {
#ifndef SUPPORT_JIT
return "JIT is not supported";
#else /* SUPPORT_JIT */
return sljit_get_platform_name(); return sljit_get_platform_name();
#endif /* SUPPORT_JIT */
} }
@ -208,16 +206,12 @@ size_t
PRIV(jit_get_size)(void *executable_jit) PRIV(jit_get_size)(void *executable_jit)
{ {
#ifndef SUPPORT_JIT #ifndef SUPPORT_JIT
(void)executable_jit; (void)executable_jit;
return 0; return 0;
#else /* SUPPORT_JIT */ #else /* SUPPORT_JIT */
sljit_uw *executable_sizes = ((executable_functions *)executable_jit)->executable_sizes; sljit_uw *executable_sizes = ((executable_functions *)executable_jit)->executable_sizes;
SLJIT_COMPILE_ASSERT(JIT_NUMBER_OF_COMPILE_MODES == 3, number_of_compile_modes_changed); SLJIT_COMPILE_ASSERT(JIT_NUMBER_OF_COMPILE_MODES == 3, number_of_compile_modes_changed);
return executable_sizes[0] + executable_sizes[1] + executable_sizes[2]; return executable_sizes[0] + executable_sizes[1] + executable_sizes[2];
#endif #endif
} }

View File

@ -2230,7 +2230,7 @@ for (;;)
else else
{ {
PCRE2_SPTR nextptr = eptr + 1; PCRE2_SPTR nextptr = eptr + 1;
FORWARDCHAR(nextptr); FORWARDCHARTEST(nextptr, mb->end_subject);
if (nextptr > mb->last_used_ptr) mb->last_used_ptr = nextptr; if (nextptr > mb->last_used_ptr) mb->last_used_ptr = nextptr;
GETCHAR(c, eptr); GETCHAR(c, eptr);
if ((mb->poptions & PCRE2_UCP) != 0) if ((mb->poptions & PCRE2_UCP) != 0)

View File

@ -574,9 +574,9 @@ static coptstruct coptlist[] = {
{ "jit", CONF_INT, PCRE2_CONFIG_JIT }, { "jit", CONF_INT, PCRE2_CONFIG_JIT },
{ "linksize", CONF_INT, PCRE2_CONFIG_LINKSIZE }, { "linksize", CONF_INT, PCRE2_CONFIG_LINKSIZE },
{ "newline", CONF_NL, PCRE2_CONFIG_NEWLINE }, { "newline", CONF_NL, PCRE2_CONFIG_NEWLINE },
{ "pcre16", CONF_FIX, SUPPORT_16 }, { "pcre2_16", CONF_FIX, SUPPORT_16 },
{ "pcre32", CONF_FIX, SUPPORT_32 }, { "pcre2_32", CONF_FIX, SUPPORT_32 },
{ "pcre8", CONF_FIX, SUPPORT_8 }, { "pcre2_8", CONF_FIX, SUPPORT_8 },
{ "unicode", CONF_INT, PCRE2_CONFIG_UNICODE } { "unicode", CONF_INT, PCRE2_CONFIG_UNICODE }
}; };
@ -1304,9 +1304,9 @@ the three different cases. */
#define PCRE2_JIT_STACK_ASSIGN(a,b,c) \ #define PCRE2_JIT_STACK_ASSIGN(a,b,c) \
pcre2_jit_stack_assign_8(G(a,8),(pcre2_jit_callback_8)b,c); pcre2_jit_stack_assign_8(G(a,8),(pcre2_jit_callback_8)b,c);
#define PCRE2_JIT_STACK_FREE(a) pcre2_jit_stack_free_8((pcre2_jit_stack_8 *)a); #define PCRE2_JIT_STACK_FREE(a) pcre2_jit_stack_free_8((pcre2_jit_stack_8 *)a);
#define PCRE2_MAKETABLES(a) a = pcre2_maketables_8(NULL)
#define PCRE2_MATCH(a,b,c,d,e,f,g,h) \ #define PCRE2_MATCH(a,b,c,d,e,f,g,h) \
a = pcre2_match_8(G(b,8),(PCRE2_SPTR8)c,d,e,f,G(g,8),G(h,8)) a = pcre2_match_8(G(b,8),(PCRE2_SPTR8)c,d,e,f,G(g,8),G(h,8))
#define PCRE2_MAKETABLES(a) a = pcre2_maketables_8(NULL)
#define PCRE2_MATCH_DATA_CREATE(a,b,c) G(a,8) = pcre2_match_data_create_8(b,c) #define PCRE2_MATCH_DATA_CREATE(a,b,c) G(a,8) = pcre2_match_data_create_8(b,c)
#define PCRE2_MATCH_DATA_FREE(a) pcre2_match_data_free_8(G(a,8)) #define PCRE2_MATCH_DATA_FREE(a) pcre2_match_data_free_8(G(a,8))
#define PCRE2_PATTERN_INFO(a,b,c,d) a = pcre2_pattern_info_8(G(b,8),c,d) #define PCRE2_PATTERN_INFO(a,b,c,d) a = pcre2_pattern_info_8(G(b,8),c,d)
@ -1373,7 +1373,7 @@ the three different cases. */
a = pcre2_match_16(G(b,16),(PCRE2_SPTR16)c,d,e,f,G(g,16),G(h,16)) a = pcre2_match_16(G(b,16),(PCRE2_SPTR16)c,d,e,f,G(g,16),G(h,16))
#define PCRE2_MATCH_DATA_CREATE(a,b,c) G(a,16) = pcre2_match_data_create_16(b,c) #define PCRE2_MATCH_DATA_CREATE(a,b,c) G(a,16) = pcre2_match_data_create_16(b,c)
#define PCRE2_MATCH_DATA_FREE(a) pcre2_match_data_free_16(G(a,16)) #define PCRE2_MATCH_DATA_FREE(a) pcre2_match_data_free_16(G(a,16))
#define PCRE2_PATTERN_INFO(a,b,c,d) G(a,16) = pcre2_pattern_info_16(G(b,16),c,d) #define PCRE2_PATTERN_INFO(a,b,c,d) a = pcre2_pattern_info_16(G(b,16),c,d)
#define PCRE2_PRINTINT(a) pcre2_printint_16(compiled_code16,outfile,a) #define PCRE2_PRINTINT(a) pcre2_printint_16(compiled_code16,outfile,a)
#define PCRE2_SET_CALLOUT(a,b,c) \ #define PCRE2_SET_CALLOUT(a,b,c) \
pcre2_set_callout_16(G(a,16),(int (*)(pcre2_callout_block_16 *))b,c); pcre2_set_callout_16(G(a,16),(int (*)(pcre2_callout_block_16 *))b,c);
@ -1432,12 +1432,12 @@ the three different cases. */
#define PCRE2_JIT_STACK_ASSIGN(a,b,c) \ #define PCRE2_JIT_STACK_ASSIGN(a,b,c) \
pcre2_jit_stack_assign_32(G(a,32),(pcre2_jit_callback_32)b,c); pcre2_jit_stack_assign_32(G(a,32),(pcre2_jit_callback_32)b,c);
#define PCRE2_JIT_STACK_FREE(a) pcre2_jit_stack_free_32((pcre2_jit_stack_32 *)a); #define PCRE2_JIT_STACK_FREE(a) pcre2_jit_stack_free_32((pcre2_jit_stack_32 *)a);
#define PCRE2_MATCH(a,b,c,d,e,f,g,h) \
a = pcre2_match_32(G(b,32),(PCRE2_SPTR32)c,d,e,f,G(g,32),g(h,32))
#define PCRE2_MAKETABLES(a) a = pcre2_maketables_32(NULL) #define PCRE2_MAKETABLES(a) a = pcre2_maketables_32(NULL)
#define PCRE2_MATCH(a,b,c,d,e,f,g,h) \
a = pcre2_match_32(G(b,32),(PCRE2_SPTR32)c,d,e,f,G(g,32),G(h,32))
#define PCRE2_MATCH_DATA_CREATE(a,b,c) G(a,32) = pcre2_match_data_create_32(b,c) #define PCRE2_MATCH_DATA_CREATE(a,b,c) G(a,32) = pcre2_match_data_create_32(b,c)
#define PCRE2_MATCH_DATA_FREE(a) pcre2_match_data_free_32(G(a,32)) #define PCRE2_MATCH_DATA_FREE(a) pcre2_match_data_free_32(G(a,32))
#define PCRE2_PATTERN_INFO(a,b,c,d) G(a,32) = pcre2_pattern_info_32(G(b,32),c,d) #define PCRE2_PATTERN_INFO(a,b,c,d) a = pcre2_pattern_info_32(G(b,32),c,d)
#define PCRE2_PRINTINT(a) pcre2_printint_32(compiled_code32,outfile,a) #define PCRE2_PRINTINT(a) pcre2_printint_32(compiled_code32,outfile,a)
#define PCRE2_SET_CALLOUT(a,b,c) \ #define PCRE2_SET_CALLOUT(a,b,c) \
pcre2_set_callout_32(G(a,32),(int (*)(pcre2_callout_block_32 *))b,c); pcre2_set_callout_32(G(a,32),(int (*)(pcre2_callout_block_32 *))b,c);
@ -1451,11 +1451,11 @@ the three different cases. */
#define PCRE2_SUBSTRING_COPY_BYNUMBER(a,b,c,d,e) \ #define PCRE2_SUBSTRING_COPY_BYNUMBER(a,b,c,d,e) \
a = pcre2_substring_copy_bynumber_32(G(b,32),c,(PCRE2_UCHAR32 *)d,e); a = pcre2_substring_copy_bynumber_32(G(b,32),c,(PCRE2_UCHAR32 *)d,e);
#define PCRE2_SUBSTRING_FREE(a) pcre2_substring_free_32((PCRE2_UCHAR32 *)a) #define PCRE2_SUBSTRING_FREE(a) pcre2_substring_free_32((PCRE2_UCHAR32 *)a)
##define PCRE2_SUBSTRING_GET_BYNAME(a,b,c,d,e) \ #define PCRE2_SUBSTRING_GET_BYNAME(a,b,c,d,e) \
a = pcre2_substring_get_byname_32(G(b,32),G(c,32),(PCRE2_UCHAR32 **)d,e) a = pcre2_substring_get_byname_32(G(b,32),G(c,32),(PCRE2_UCHAR32 **)d,e)
define PCRE2_SUBSTRING_GET_BYNUMBER(a,b,c,d,e) \ #define PCRE2_SUBSTRING_GET_BYNUMBER(a,b,c,d,e) \
a = pcre2_substring_get_bynumber_32(G(b,32),c,(PCRE2_UCHAR32 **)d) a = pcre2_substring_get_bynumber_32(G(b,32),c,(PCRE2_UCHAR32 **)d,e)
#define PCRE2_SUBSTRING_LIST_GET(a,b,c,d,e) \ #define PCRE2_SUBSTRING_LIST_GET(a,b,c,d) \
a = pcre2_substring_list_get_32(G(b,32),(PCRE2_UCHAR32 ***)c,d) a = pcre2_substring_list_get_32(G(b,32),(PCRE2_UCHAR32 ***)c,d)
#define PCRE2_SUBSTRING_LIST_FREE(a) \ #define PCRE2_SUBSTRING_LIST_FREE(a) \
pcre2_substring_list_free_32((PCRE2_SPTR32 *)a) pcre2_substring_list_free_32((PCRE2_SPTR32 *)a)
@ -1464,7 +1464,7 @@ define PCRE2_SUBSTRING_GET_BYNUMBER(a,b,c,d,e) \
#define SETFLDVEC(x,y,v,z) G(x,32)->y[v] = z #define SETFLDVEC(x,y,v,z) G(x,32)->y[v] = z
#define SETOP(x,y,z) G(x,32) z y #define SETOP(x,y,z) G(x,32) z y
#define SETCASTPTR(x,y) G(x,32) = (uint32_t *)y #define SETCASTPTR(x,y) G(x,32) = (uint32_t *)y
#define STRLEN(p) (int)strle32(p) #define STRLEN(p) (int)strlen32(p)
#define SUB1(a,b) G(a,32)(G(b,32)) #define SUB1(a,b) G(a,32)(G(b,32))
#define SUB2(a,b,c) G(a,32)(G(b,32),G(c,32)) #define SUB2(a,b,c) G(a,32)(G(b,32),G(c,32))
#define TEST(x,r,y) (G(x,32) r (y)) #define TEST(x,r,y) (G(x,32) r (y))
@ -2299,7 +2299,7 @@ return 0;
* Move back by so many characters * * Move back by so many characters *
*************************************************/ *************************************************/
/* Given a code unit offset in a subject string, move backwards by a number of /* Given a code unit offset in a subject string, move backwards by a number of
characters, and return the resulting offset. characters, and return the resulting offset.
Arguments: Arguments:
@ -2307,9 +2307,9 @@ Arguments:
offset start offset offset start offset
count count to move back by count count to move back by
utf TRUE if in UTF mode utf TRUE if in UTF mode
Returns: a possibly changed offset Returns: a possibly changed offset
*/ */
static PCRE2_SIZE static PCRE2_SIZE
backchars(uint8_t *subject, PCRE2_SIZE offset, uint32_t count, BOOL utf) backchars(uint8_t *subject, PCRE2_SIZE offset, uint32_t count, BOOL utf)
@ -2321,26 +2321,26 @@ if (!utf || test_mode == PCRE32_MODE) yield = offset - count;
else if (test_mode == PCRE8_MODE) else if (test_mode == PCRE8_MODE)
{ {
PCRE2_SPTR8 pp = (PCRE2_SPTR8)subject + offset; PCRE2_SPTR8 pp = (PCRE2_SPTR8)subject + offset;
for (; count > 0; count--) for (; count > 0 && pp > (PCRE2_SPTR8)subject; count--)
{ {
pp--; pp--;
while ((*pp & 0xc0) == 0x80) pp--; while ((*pp & 0xc0) == 0x80) pp--;
} }
yield = pp - (PCRE2_SPTR8)subject; yield = pp - (PCRE2_SPTR8)subject;
} }
else /* 16-bit mode */ else /* 16-bit mode */
{ {
PCRE2_SPTR16 pp = (PCRE2_SPTR16)subject + offset; PCRE2_SPTR16 pp = (PCRE2_SPTR16)subject + offset;
for (; count > 0; count--) for (; count > 0 && pp > (PCRE2_SPTR16)subject; count--)
{ {
pp--; pp--;
if ((*pp & 0xfc00) == 0xdc00) pp--; if ((*pp & 0xfc00) == 0xdc00) pp--;
} }
yield = pp - (PCRE2_SPTR16)subject; yield = pp - (PCRE2_SPTR16)subject;
} }
return (yield >= 0)? yield : 0; return (yield >= 0)? yield : 0;
} }
@ -2683,7 +2683,7 @@ for (;;)
pp = p; pp = p;
while (pp < ep && *pp != '=') pp++; while (pp < ep && *pp != '=') pp++;
index = scan_modifiers(p, pp - p); index = scan_modifiers(p, pp - p);
/* If the first modifier is unrecognized, try to interpret it as a sequence /* If the first modifier is unrecognized, try to interpret it as a sequence
of single-character abbreviated modifiers. None of these modifiers have any of single-character abbreviated modifiers. None of these modifiers have any
associated data. They just set options or control bits. */ associated data. They just set options or control bits. */
@ -3379,7 +3379,7 @@ if ((pat_patctl.control & CTL_INFO) != 0)
if (pat_patctl.jit != 0 && (pat_patctl.control & CTL_JITVERIFY) != 0) if (pat_patctl.jit != 0 && (pat_patctl.control & CTL_JITVERIFY) != 0)
{ {
if (FLD(compiled_code, executable_jit) != NULL) if (FLD(compiled_code, executable_jit) != NULL)
fprintf(outfile, "JIT compilation was successful\n"); fprintf(outfile, "JIT compilation was successful\n");
else else
#ifdef SUPPORT_JIT #ifdef SUPPORT_JIT
@ -3426,7 +3426,7 @@ else if (strncmp((char *)buffer, "#pattern", 8) == 0 && isspace(buffer[8]))
{ {
(void)decode_modifiers(buffer + 8, CTX_DEFPAT, &def_patctl, NULL); (void)decode_modifiers(buffer + 8, CTX_DEFPAT, &def_patctl, NULL);
if (def_patctl.jit == 0 && (def_patctl.control & CTL_JITVERIFY) != 0) if (def_patctl.jit == 0 && (def_patctl.control & CTL_JITVERIFY) != 0)
def_patctl.jit = 7; def_patctl.jit = 7;
} }
else if (strncmp((char *)buffer, "#perltest", 9) == 0 && isspace(buffer[9])) else if (strncmp((char *)buffer, "#perltest", 9) == 0 && isspace(buffer[9]))
{ {
@ -3514,7 +3514,7 @@ patlen = p - buffer - 2;
if (!decode_modifiers(p, CTX_PAT, &pat_patctl, NULL)) return PR_SKIP; if (!decode_modifiers(p, CTX_PAT, &pat_patctl, NULL)) return PR_SKIP;
if (pat_patctl.jit == 0 && (pat_patctl.control & CTL_JITVERIFY) != 0) if (pat_patctl.jit == 0 && (pat_patctl.control & CTL_JITVERIFY) != 0)
pat_patctl.jit = 7; pat_patctl.jit = 7;
utf = (pat_patctl.options & PCRE2_UTF) != 0; utf = (pat_patctl.options & PCRE2_UTF) != 0;
/* Now copy the pattern to pbuffer8 for use in 8-bit testing and for reflecting /* Now copy the pattern to pbuffer8 for use in 8-bit testing and for reflecting
@ -3668,18 +3668,15 @@ if ((pat_patctl.control & CTL_POSIX) != 0)
modes. */ modes. */
#ifdef SUPPORT_PCRE2_8 #ifdef SUPPORT_PCRE2_8
if (test_mode == PCRE8_MODE) if (test_mode == PCRE8_MODE) errorcode = 0;
errorcode = 0;
#endif #endif
#ifdef SUPPORT_PCRE2_16 #ifdef SUPPORT_PCRE2_16
if (test_mode == PCRE16_MODE) if (test_mode == PCRE16_MODE) errorcode = to16(pbuffer8, utf, &patlen);
errorcode = to16(pbuffer8, utf, &patlen);
#endif #endif
#ifdef SUPPORT_PCRE2_32 #ifdef SUPPORT_PCRE2_32
if (test_mode == PCRE32_MODE) if (test_mode == PCRE32_MODE) errorcode = to32(pbuffer8, utf, &patlen);
errorcode = to32(pbuffer8, utf, &patlen);
#endif #endif
switch(errorcode) switch(errorcode)
@ -3749,8 +3746,8 @@ if (TEST(compiled_code, ==, NULL))
fprintf(outfile, "\n"); fprintf(outfile, "\n");
return PR_SKIP; return PR_SKIP;
} }
/* Remember the maximum lookbehind, for partial matching. */ /* Remember the maximum lookbehind, for partial matching. */
if (pattern_info(PCRE2_INFO_MAXLOOKBEHIND, &maxlookbehind, FALSE) != 0) if (pattern_info(PCRE2_INFO_MAXLOOKBEHIND, &maxlookbehind, FALSE) != 0)
return PR_ABEND; return PR_ABEND;
@ -4437,16 +4434,16 @@ if ((dat_datctl.control & (CTL_DFA|CTL_FINDLIMITS)) == (CTL_DFA|CTL_FINDLIMITS))
fprintf(outfile, "** Finding match limits is not relevant for DFA matching: ignored\n"); fprintf(outfile, "** Finding match limits is not relevant for DFA matching: ignored\n");
dat_datctl.control &= ~CTL_FINDLIMITS; dat_datctl.control &= ~CTL_FINDLIMITS;
} }
/* ALLUSEDTEXT is not supported with JIT, but JIT is not used with DFA /* ALLUSEDTEXT is not supported with JIT, but JIT is not used with DFA
matching, even if the JIT compiler was used. */ matching, even if the JIT compiler was used. */
if ((dat_datctl.control & (CTL_ALLUSEDTEXT|CTL_DFA)) == CTL_ALLUSEDTEXT && if ((dat_datctl.control & (CTL_ALLUSEDTEXT|CTL_DFA)) == CTL_ALLUSEDTEXT &&
FLD(compiled_code, executable_jit) != NULL) FLD(compiled_code, executable_jit) != NULL)
{ {
fprintf(outfile, "** Showing all consulted text is not supported by JIT: ignored\n"); fprintf(outfile, "** Showing all consulted text is not supported by JIT: ignored\n");
dat_datctl.control &= ~CTL_ALLUSEDTEXT; dat_datctl.control &= ~CTL_ALLUSEDTEXT;
} }
/* As pcre2_match_data_create() imposes a minimum of 1 on the ovector count, we /* As pcre2_match_data_create() imposes a minimum of 1 on the ovector count, we
must do so too. */ must do so too. */
@ -4564,7 +4561,7 @@ for (gmatched = 0;; gmatched++)
if ((dat_datctl.control & CTL_FINDLIMITS) != 0) if ((dat_datctl.control & CTL_FINDLIMITS) != 0)
{ {
capcount = check_match_limit(pp, ulen, PCRE2_ERROR_MATCHLIMIT, "match"); capcount = check_match_limit(pp, ulen, PCRE2_ERROR_MATCHLIMIT, "match");
if (FLD(compiled_code, executable_jit) == NULL) if (FLD(compiled_code, executable_jit) == NULL)
(void)check_match_limit(pp, ulen, PCRE2_ERROR_RECURSIONLIMIT, (void)check_match_limit(pp, ulen, PCRE2_ERROR_RECURSIONLIMIT,
"recursion"); "recursion");
} }
@ -4623,7 +4620,7 @@ for (gmatched = 0;; gmatched++)
{ {
int i; int i;
uint8_t *nptr; uint8_t *nptr;
/* This is a check against a lunatic return value. */ /* This is a check against a lunatic return value. */
if (capcount > (int)dat_datctl.oveccount) if (capcount > (int)dat_datctl.oveccount)
@ -4690,27 +4687,27 @@ for (gmatched = 0;; gmatched++)
continue; continue;
} }
/* When JIT is not being used, ALLUSEDTEXT may be set. (It if is set with /* When JIT is not being used, ALLUSEDTEXT may be set. (It if is set with
JIT, it is disabled above, with a comment.) When the match is done by the JIT, it is disabled above, with a comment.) When the match is done by the
interpreter, leftchar and rightchar are available, and if ALLUSEDTEXT is interpreter, leftchar and rightchar are available, and if ALLUSEDTEXT is
set, and if the leftmost consulted character is before the start of the set, and if the leftmost consulted character is before the start of the
match or the rightmost consulted character is past the end of the match, match or the rightmost consulted character is past the end of the match,
we want to show all consulted characters for the main matched string, and we want to show all consulted characters for the main matched string, and
indicate which were lookarounds. */ indicate which were lookarounds. */
if (i == 0) if (i == 0)
{ {
BOOL showallused; BOOL showallused;
PCRE2_SIZE leftchar, rightchar; PCRE2_SIZE leftchar, rightchar;
if ((dat_datctl.control & CTL_ALLUSEDTEXT) != 0) if ((dat_datctl.control & CTL_ALLUSEDTEXT) != 0)
{ {
leftchar = FLD(match_data, leftchar); leftchar = FLD(match_data, leftchar);
rightchar = FLD(match_data, rightchar); rightchar = FLD(match_data, rightchar);
showallused = i == 0 && (leftchar < start || rightchar > end); showallused = i == 0 && (leftchar < start || rightchar > end);
} }
else showallused = FALSE; else showallused = FALSE;
if (showallused) if (showallused)
{ {
PCHARS(lleft, pp, leftchar, start - leftchar, utf, outfile); PCHARS(lleft, pp, leftchar, start - leftchar, utf, outfile);
@ -4721,10 +4718,10 @@ for (gmatched = 0;; gmatched++)
{ {
PCHARSV(pp, start, end - start, utf, outfile); PCHARSV(pp, start, end - start, utf, outfile);
} }
if ((pat_patctl.control & CTL_JITVERIFY) != 0 && jit_was_used) if ((pat_patctl.control & CTL_JITVERIFY) != 0 && jit_was_used)
fprintf(outfile, " (JIT)"); fprintf(outfile, " (JIT)");
if (showallused) if (showallused)
{ {
PCRE2_SIZE j; PCRE2_SIZE j;
@ -4734,16 +4731,16 @@ for (gmatched = 0;; gmatched++)
for (j = 0; j < lright; j++) fprintf(outfile, ">"); for (j = 0; j < lright; j++) fprintf(outfile, ">");
} }
} }
/* Not the main matched string. Just show it unadorned. */ /* Not the main matched string. Just show it unadorned. */
else else
{ {
PCHARSV(pp, start, end - start, utf, outfile); PCHARSV(pp, start, end - start, utf, outfile);
} }
fprintf(outfile, "\n"); fprintf(outfile, "\n");
/* Note: don't use the start/end variables here because we want to /* Note: don't use the start/end variables here because we want to
show the text from what is reported as the end. */ show the text from what is reported as the end. */
@ -4797,12 +4794,13 @@ for (gmatched = 0;; gmatched++)
for (;;) for (;;)
{ {
int rc; int rc;
PCRE2_SIZE cnl;
PCRE2_SIZE length; PCRE2_SIZE length;
uint32_t copybuffer[256]; uint32_t copybuffer[256];
int namelen = strlen((const char *)nptr); int namelen = strlen((const char *)nptr);
#if defined SUPPORT_PCRE2_16 || defined SUPPORT_PCRE2_32
PCRE2_SIZE cnl = namelen;
#endif
if (namelen == 0) break; if (namelen == 0) break;
cnl = namelen;
#ifdef SUPPORT_PCRE2_8 #ifdef SUPPORT_PCRE2_8
if (test_mode == PCRE8_MODE) strcpy((char *)pbuffer8, (char *)nptr); if (test_mode == PCRE8_MODE) strcpy((char *)pbuffer8, (char *)nptr);
@ -4862,13 +4860,14 @@ for (gmatched = 0;; gmatched++)
nptr = dat_datctl.get_names; nptr = dat_datctl.get_names;
for (;;) for (;;)
{ {
PCRE2_SIZE cnl;
PCRE2_SIZE length; PCRE2_SIZE length;
void *gotbuffer; void *gotbuffer;
int rc; int rc;
int namelen = strlen((const char *)nptr); int namelen = strlen((const char *)nptr);
#if defined SUPPORT_PCRE2_16 || defined SUPPORT_PCRE2_32
PCRE2_SIZE cnl = namelen;
#endif
if (namelen == 0) break; if (namelen == 0) break;
cnl = namelen;
#ifdef SUPPORT_PCRE2_8 #ifdef SUPPORT_PCRE2_8
if (test_mode == PCRE8_MODE) strcpy((char *)pbuffer8, (char *)nptr); if (test_mode == PCRE8_MODE) strcpy((char *)pbuffer8, (char *)nptr);
@ -4928,15 +4927,15 @@ for (gmatched = 0;; gmatched++)
} }
} /* End of handling a successful match */ } /* End of handling a successful match */
/* There was a partial match. The value of ovector[0] is the bumpalong point, /* There was a partial match. The value of ovector[0] is the bumpalong point,
that is, startchar, not any \K point that might have been passed. */ that is, startchar, not any \K point that might have been passed. */
else if (capcount == PCRE2_ERROR_PARTIAL) else if (capcount == PCRE2_ERROR_PARTIAL)
{ {
PCRE2_SIZE poffset; PCRE2_SIZE poffset;
int backlength; int backlength;
int rubriclength = 0; int rubriclength = 0;
fprintf(outfile, "Partial match"); fprintf(outfile, "Partial match");
if ((dat_datctl.control & CTL_MARK) != 0 && if ((dat_datctl.control & CTL_MARK) != 0 &&
TESTFLD(match_data, mark, !=, NULL)) TESTFLD(match_data, mark, !=, NULL))
@ -4946,24 +4945,24 @@ for (gmatched = 0;; gmatched++)
rubriclength += 7; rubriclength += 7;
} }
fprintf(outfile, ": "); fprintf(outfile, ": ");
rubriclength += 15; rubriclength += 15;
poffset = backchars(pp, ovector[0], maxlookbehind, utf); poffset = backchars(pp, ovector[0], maxlookbehind, utf);
PCHARS(backlength, pp, poffset, ovector[0] - poffset, utf, outfile); PCHARS(backlength, pp, poffset, ovector[0] - poffset, utf, outfile);
PCHARSV(pp, ovector[0], ulen - ovector[0], utf, outfile); PCHARSV(pp, ovector[0], ulen - ovector[0], utf, outfile);
if ((pat_patctl.control & CTL_JITVERIFY) != 0 && jit_was_used) if ((pat_patctl.control & CTL_JITVERIFY) != 0 && jit_was_used)
fprintf(outfile, " (JIT)"); fprintf(outfile, " (JIT)");
fprintf(outfile, "\n"); fprintf(outfile, "\n");
if (backlength != 0) if (backlength != 0)
{ {
int i; int i;
for (i = 0; i < rubriclength; i++) fprintf(outfile, " "); for (i = 0; i < rubriclength; i++) fprintf(outfile, " ");
for (i = 0; i < backlength; i++) fprintf(outfile, "<"); for (i = 0; i < backlength; i++) fprintf(outfile, "<");
fprintf(outfile, "\n"); fprintf(outfile, "\n");
} }
break; /* Out of the /g loop */ break; /* Out of the /g loop */
} /* End of handling partial match */ } /* End of handling partial match */
@ -5200,9 +5199,9 @@ printf(" ebcdic-nl NL code if compiled for EBCDIC\n");
printf(" jit just-in-time compiler supported [0, 1]\n"); printf(" jit just-in-time compiler supported [0, 1]\n");
printf(" linksize internal link size [2, 3, 4]\n"); printf(" linksize internal link size [2, 3, 4]\n");
printf(" newline newline type [CR, LF, CRLF, ANYCRLF, ANY]\n"); printf(" newline newline type [CR, LF, CRLF, ANYCRLF, ANY]\n");
printf(" pcre8 8 bit library support enabled [0, 1]\n"); printf(" pcre2_8 8 bit library support enabled [0, 1]\n");
printf(" pcre16 16 bit library support enabled [0, 1]\n"); printf(" pcre2_16 16 bit library support enabled [0, 1]\n");
printf(" pcre32 32 bit library support enabled [0, 1]\n"); printf(" pcre2_32 32 bit library support enabled [0, 1]\n");
printf(" unicode Unicode and UTF support enabled [0, 1]\n"); printf(" unicode Unicode and UTF support enabled [0, 1]\n");
printf(" -d set default pattern control 'debug'\n"); printf(" -d set default pattern control 'debug'\n");
printf(" -dfa set default subject control 'dfa'\n"); printf(" -dfa set default subject control 'dfa'\n");
@ -5323,21 +5322,21 @@ if (rc != 0)
printf(" UTF and UCP support ("); printf(" UTF and UCP support (");
print_unicode_version(stdout); print_unicode_version(stdout);
printf(")\n"); printf(")\n");
} }
else printf(" No UTF or UCP support\n"); else printf(" No UTF or UCP support\n");
(void)PCRE2_CONFIG(PCRE2_CONFIG_JIT, &rc, sizeof(rc)); (void)PCRE2_CONFIG(PCRE2_CONFIG_JIT, &rc, sizeof(rc));
if (rc != 0) if (rc != 0)
{ {
printf(" Just-in-time compiler support: "); printf(" Just-in-time compiler support: ");
print_jit_target(stdout); print_jit_target(stdout);
printf("\n"); printf("\n");
} }
else else
{ {
printf(" No just-in-time compiler support\n"); printf(" No just-in-time compiler support\n");
} }
(void)PCRE2_CONFIG(PCRE2_CONFIG_NEWLINE, &rc, sizeof(rc)); (void)PCRE2_CONFIG(PCRE2_CONFIG_NEWLINE, &rc, sizeof(rc));
print_newline_config(rc, FALSE); print_newline_config(rc, FALSE);
(void)PCRE2_CONFIG(PCRE2_CONFIG_BSR, &rc, sizeof(rc)); (void)PCRE2_CONFIG(PCRE2_CONFIG_BSR, &rc, sizeof(rc));
@ -5395,7 +5394,7 @@ if (PO(options) != DO(options) || PO(control) != DO(control))
PCRE2_CONFIG(PCRE2_CONFIG_VERSION, version, sizeof(VERSION_TYPE)*VERSION_SIZE); PCRE2_CONFIG(PCRE2_CONFIG_VERSION, version, sizeof(VERSION_TYPE)*VERSION_SIZE);
PCRE2_CONFIG(PCRE2_CONFIG_UNICODE_VERSION, uversion, PCRE2_CONFIG(PCRE2_CONFIG_UNICODE_VERSION, uversion,
sizeof(VERSION_TYPE)*VERSION_SIZE); sizeof(VERSION_TYPE)*VERSION_SIZE);
PCRE2_CONFIG(PCRE2_CONFIG_JITTARGET, jittarget, PCRE2_CONFIG(PCRE2_CONFIG_JITTARGET, jittarget,
sizeof(VERSION_TYPE)*VERSION_SIZE); sizeof(VERSION_TYPE)*VERSION_SIZE);
/* Get buffers from malloc() so that valgrind will check their misuse when /* Get buffers from malloc() so that valgrind will check their misuse when