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
# one need be.
$sim ./pcre2test -C pcre8 >/dev/null
$sim ./pcre2test -C pcre2_8 >/dev/null
support8=$?
$sim ./pcre2test -C pcre16 >/dev/null
$sim ./pcre2test -C pcre2_16 >/dev/null
support16=$?
$sim ./pcre2test -C pcre32 >/dev/null
$sim ./pcre2test -C pcre2_32 >/dev/null
support32=$?
# Initialize all bitsizes skipped
@ -686,6 +686,6 @@ fi
done
# 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

View File

@ -117,9 +117,9 @@ to the same value:
.sp
ebcdic compiled for an EBCDIC environment
jit just-in-time support is available
pcre16 the 16-bit library was built
pcre32 the 32-bit library was built
pcre8 the 8-bit library was built
pcre2_16 the 16-bit library was built
pcre2_32 the 32-bit library was built
pcre2_8 the 8-bit library was built
unicode Unicode support is available
.sp
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()
{
rm -f *_unittest
rm -f $srcdir/pcre2test $srcdir/pcre2grep $srcdir/pcre2_jit_test
testcount=`expr $testcount + 1`
if [ "$opts" = "" ] ; then
@ -119,34 +119,45 @@ function runtest()
fi
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
jit=$?
./pcre2test -C utf >/dev/null
./pcre2test -C unicode >/dev/null
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"
$srcdir/RunTest $valgrind >teststdout
if [ $? -ne 0 ]; then
$srcdir/RunTest $valgrind >teststdout 2>teststderr
if [ $? -ne 0 -o -s teststderr ]; then
echo " "
echo "**** Test failed ****"
cat teststdout
cat teststderr
if [ -s teststdout ] ; then cat teststdout; fi
exit 1
fi
else
echo "Skipping C library tests: newline is $nl"
fi
if [ "$nl" = "LF" ]; then
if [ $nlok -gt 0 -a $pcre2_8 -gt 0 ]; then
echo "Running pcre2grep tests $withvalgrind"
$srcdir/RunGrepTest $valgrind >teststdout 2>teststderr
if [ $? -ne 0 ]; then
if [ $? -ne 0 -o -s teststderr ]; then
echo " "
echo "**** Test failed ****"
cat teststderr
cat teststdout
exit 1
fi
elif [ $nlok -gt 0 ]; then
echo "Skipping pcre2grep tests: 8-bit library not compiled"
else
echo "Skipping pcre2grep tests: newline is $nl"
fi
@ -154,7 +165,7 @@ function runtest()
if [ "$jit" -gt 0 -a $utf -gt 0 ]; then
echo "Running JIT regression tests $withvalgrind"
$cvalgrind $srcdir/pcre2_jit_test >teststdout 2>teststderr
if [ $? -ne 0 ]; then
if [ $? -ne 0 -o -s teststderr ]; then
echo " "
echo "**** Test failed ****"
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 <locale.h>
#define PCRE2_CODE_UNIT_WIDTH 0 /* Must be set, but not relevant here */
#include "pcre2_internal.h"
#define DFTABLES /* pcre2_maketables.c notices this */
#define DFTABLES /* pcre2_maketables.c notices this */
#include "pcre2_maketables.c"
int main(int argc, char **argv)

View File

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

View File

@ -56,6 +56,7 @@ just to undefine them all. */
#undef BYTES2CU
#undef CU2BYTES
#undef FORWARDCHAR
#undef FORWARDCHARTEST
#undef GET
#undef GET2
#undef GETCHAR
@ -261,6 +262,7 @@ UTF support is omitted, we don't even define them. */
/* #define GETCHARLENTEST(c, eptr, len) */
/* #define BACKCHAR(eptr) */
/* #define FORWARDCHAR(eptr) */
/* #define FORWARCCHARTEST(eptr,end) */
/* #define ACROSSCHAR(condition, eptr, action) */
#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. */
#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. */
#define ACROSSCHAR(condition, eptr, action) \
@ -444,6 +447,7 @@ code. */
/* Same as above, just in the other direction. */
#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. */
#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. */
#define FORWARDCHAR(eptr) do { } while (0)
#define FORWARDCHARTEST(eptr,end) do { } while (0)
/* 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)
{
#ifndef SUPPORT_JIT
(void)jit_stack;
#else /* SUPPORT_JIT */
/* Dummy code */
if (jit_stack != NULL)
{
sljit_free_stack((struct sljit_stack *)(jit_stack->stack), &jit_stack->memctl);
jit_stack->memctl.free(jit_stack, jit_stack->memctl.memory_data);
}
#endif /* SUPPORT_JIT */
}
@ -196,7 +190,11 @@ if (jit_stack != NULL)
const char*
PRIV(jit_get_target)(void)
{
#ifndef SUPPORT_JIT
return "JIT is not supported";
#else /* SUPPORT_JIT */
return sljit_get_platform_name();
#endif /* SUPPORT_JIT */
}
@ -208,16 +206,12 @@ size_t
PRIV(jit_get_size)(void *executable_jit)
{
#ifndef SUPPORT_JIT
(void)executable_jit;
return 0;
#else /* SUPPORT_JIT */
sljit_uw *executable_sizes = ((executable_functions *)executable_jit)->executable_sizes;
SLJIT_COMPILE_ASSERT(JIT_NUMBER_OF_COMPILE_MODES == 3, number_of_compile_modes_changed);
return executable_sizes[0] + executable_sizes[1] + executable_sizes[2];
#endif
}

View File

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

View File

@ -574,9 +574,9 @@ static coptstruct coptlist[] = {
{ "jit", CONF_INT, PCRE2_CONFIG_JIT },
{ "linksize", CONF_INT, PCRE2_CONFIG_LINKSIZE },
{ "newline", CONF_NL, PCRE2_CONFIG_NEWLINE },
{ "pcre16", CONF_FIX, SUPPORT_16 },
{ "pcre32", CONF_FIX, SUPPORT_32 },
{ "pcre8", CONF_FIX, SUPPORT_8 },
{ "pcre2_16", CONF_FIX, SUPPORT_16 },
{ "pcre2_32", CONF_FIX, SUPPORT_32 },
{ "pcre2_8", CONF_FIX, SUPPORT_8 },
{ "unicode", CONF_INT, PCRE2_CONFIG_UNICODE }
};
@ -1304,9 +1304,9 @@ the three different cases. */
#define PCRE2_JIT_STACK_ASSIGN(a,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_MAKETABLES(a) a = pcre2_maketables_8(NULL)
#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))
#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_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)
@ -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))
#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_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_SET_CALLOUT(a,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) \
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_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_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_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_SET_CALLOUT(a,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) \
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_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)
define PCRE2_SUBSTRING_GET_BYNUMBER(a,b,c,d,e) \
a = pcre2_substring_get_bynumber_32(G(b,32),c,(PCRE2_UCHAR32 **)d)
#define PCRE2_SUBSTRING_LIST_GET(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,e)
#define PCRE2_SUBSTRING_LIST_GET(a,b,c,d) \
a = pcre2_substring_list_get_32(G(b,32),(PCRE2_UCHAR32 ***)c,d)
#define PCRE2_SUBSTRING_LIST_FREE(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 SETOP(x,y,z) G(x,32) z 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 SUB2(a,b,c) G(a,32)(G(b,32),G(c,32))
#define TEST(x,r,y) (G(x,32) r (y))
@ -2321,7 +2321,7 @@ if (!utf || test_mode == PCRE32_MODE) yield = offset - count;
else if (test_mode == PCRE8_MODE)
{
PCRE2_SPTR8 pp = (PCRE2_SPTR8)subject + offset;
for (; count > 0; count--)
for (; count > 0 && pp > (PCRE2_SPTR8)subject; count--)
{
pp--;
while ((*pp & 0xc0) == 0x80) pp--;
@ -2332,7 +2332,7 @@ else if (test_mode == PCRE8_MODE)
else /* 16-bit mode */
{
PCRE2_SPTR16 pp = (PCRE2_SPTR16)subject + offset;
for (; count > 0; count--)
for (; count > 0 && pp > (PCRE2_SPTR16)subject; count--)
{
pp--;
if ((*pp & 0xfc00) == 0xdc00) pp--;
@ -3668,18 +3668,15 @@ if ((pat_patctl.control & CTL_POSIX) != 0)
modes. */
#ifdef SUPPORT_PCRE2_8
if (test_mode == PCRE8_MODE)
errorcode = 0;
if (test_mode == PCRE8_MODE) errorcode = 0;
#endif
#ifdef SUPPORT_PCRE2_16
if (test_mode == PCRE16_MODE)
errorcode = to16(pbuffer8, utf, &patlen);
if (test_mode == PCRE16_MODE) errorcode = to16(pbuffer8, utf, &patlen);
#endif
#ifdef SUPPORT_PCRE2_32
if (test_mode == PCRE32_MODE)
errorcode = to32(pbuffer8, utf, &patlen);
if (test_mode == PCRE32_MODE) errorcode = to32(pbuffer8, utf, &patlen);
#endif
switch(errorcode)
@ -4797,12 +4794,13 @@ for (gmatched = 0;; gmatched++)
for (;;)
{
int rc;
PCRE2_SIZE cnl;
PCRE2_SIZE length;
uint32_t copybuffer[256];
int namelen = strlen((const char *)nptr);
#if defined SUPPORT_PCRE2_16 || defined SUPPORT_PCRE2_32
PCRE2_SIZE cnl = namelen;
#endif
if (namelen == 0) break;
cnl = namelen;
#ifdef SUPPORT_PCRE2_8
if (test_mode == PCRE8_MODE) strcpy((char *)pbuffer8, (char *)nptr);
@ -4862,13 +4860,14 @@ for (gmatched = 0;; gmatched++)
nptr = dat_datctl.get_names;
for (;;)
{
PCRE2_SIZE cnl;
PCRE2_SIZE length;
void *gotbuffer;
int rc;
int namelen = strlen((const char *)nptr);
#if defined SUPPORT_PCRE2_16 || defined SUPPORT_PCRE2_32
PCRE2_SIZE cnl = namelen;
#endif
if (namelen == 0) break;
cnl = namelen;
#ifdef SUPPORT_PCRE2_8
if (test_mode == PCRE8_MODE) strcpy((char *)pbuffer8, (char *)nptr);
@ -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(" linksize internal link size [2, 3, 4]\n");
printf(" newline newline type [CR, LF, CRLF, ANYCRLF, ANY]\n");
printf(" pcre8 8 bit library support enabled [0, 1]\n");
printf(" pcre16 16 bit library support enabled [0, 1]\n");
printf(" pcre32 32 bit library support enabled [0, 1]\n");
printf(" pcre2_8 8 bit library support enabled [0, 1]\n");
printf(" pcre2_16 16 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(" -d set default pattern control 'debug'\n");
printf(" -dfa set default subject control 'dfa'\n");