summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzherczeg <zherczeg@2f5784b3-3f2a-0410-8824-cb99058d5e15>2011-12-15 11:57:39 +0000
committerzherczeg <zherczeg@2f5784b3-3f2a-0410-8824-cb99058d5e15>2011-12-15 11:57:39 +0000
commitedeb17f511c2d107140e8dadfb8755d70901e90b (patch)
tree4851202670a31315739c71bf94d8df3002c5f376
parentf852abd1323afc800c9a761e7041b961f03c1de2 (diff)
downloadpcre-edeb17f511c2d107140e8dadfb8755d70901e90b.tar.gz
lcc and inline printint.c fixes
git-svn-id: svn://vcs.exim.org/pcre/code/branches/pcre16@806 2f5784b3-3f2a-0410-8824-cb99058d5e15
-rw-r--r--pcre_compile.c11
-rw-r--r--pcre_dfa_exec.c3
-rw-r--r--pcre_exec.c6
-rw-r--r--pcre_jit_test.c27
-rw-r--r--pcre_printint.c15
-rw-r--r--pcre_study.c3
6 files changed, 46 insertions, 19 deletions
diff --git a/pcre_compile.c b/pcre_compile.c
index 1a13eb4..bcc10f3 100644
--- a/pcre_compile.c
+++ b/pcre_compile.c
@@ -59,7 +59,10 @@ library. We do not need to select pcre16_printint.c specially, because the
COMPILE_PCREx macro will already be appropriately set. */
#ifdef PCRE_DEBUG
+/* pcre_printint.c should not include any headers */
+#define PCRE_INCLUDED
#include "pcre_printint.c"
+#undef PCRE_INCLUDED
#endif
@@ -3060,7 +3063,7 @@ if (next >= 0) switch(op_code)
}
else
#endif /* SUPPORT_UTF */
- return (c != cd->fcc[next]); /* Non-UTF-8 mode */
+ return (c != TABLE_GET(next, cd->fcc, next)); /* Non-UTF-8 mode */
/* For OP_NOT and OP_NOTI, the data is always a single-byte character. These
opcodes are not used for multi-byte characters, because they are coded using
@@ -3085,7 +3088,7 @@ if (next >= 0) switch(op_code)
}
else
#endif /* SUPPORT_UTF */
- return (c == cd->fcc[next]); /* Non-UTF-8 mode */
+ return (c == TABLE_GET(next, cd->fcc, next)); /* Non-UTF-8 mode */
/* Note that OP_DIGIT etc. are generated only when PCRE_UCP is *not* set.
When it is set, \d etc. are converted into OP_(NOT_)PROP codes. */
@@ -4400,7 +4403,7 @@ for (;; ptr++)
classbits[c/8] |= (1 << (c&7));
if ((options & PCRE_CASELESS) != 0)
{
- int uc = cd->fcc[c]; /* flip case */
+ int uc = cd->fcc[c]; /* flip case */
classbits[uc/8] |= (1 << (uc&7));
}
}
@@ -4522,7 +4525,7 @@ for (;; ptr++)
classbits[c/8] |= (1 << (c&7));
if ((options & PCRE_CASELESS) != 0)
{
- c = cd->fcc[c]; /* flip case */
+ c = cd->fcc[c]; /* flip case */
classbits[c/8] |= (1 << (c&7));
}
}
diff --git a/pcre_dfa_exec.c b/pcre_dfa_exec.c
index 9bfe614..a7d2037 100644
--- a/pcre_dfa_exec.c
+++ b/pcre_dfa_exec.c
@@ -2012,7 +2012,8 @@ for (;;)
#endif /* SUPPORT_UTF */
/* Not UTF mode */
{
- if (lcc[c] == lcc[d]) { ADD_NEW(state_offset + 2, 0); }
+ if (TABLE_GET(c, lcc, c) == TABLE_GET(d, lcc, d))
+ { ADD_NEW(state_offset + 2, 0); }
}
break;
diff --git a/pcre_exec.c b/pcre_exec.c
index d699445..3631845 100644
--- a/pcre_exec.c
+++ b/pcre_exec.c
@@ -204,7 +204,11 @@ if (caseless)
{
if (eptr + length > md->end_subject) return -1;
while (length-- > 0)
- { if (md->lcc[*p++] != md->lcc[*eptr++]) return -1; }
+ {
+ if (TABLE_GET(*p, md->lcc, *p) != TABLE_GET(*eptr, md->lcc, *eptr)) return -1;
+ p++;
+ eptr++;
+ }
}
}
diff --git a/pcre_jit_test.c b/pcre_jit_test.c
index 8ba9509..50eb653 100644
--- a/pcre_jit_test.c
+++ b/pcre_jit_test.c
@@ -638,6 +638,8 @@ static struct regression_test_case regression_test_cases[] = {
{ CMA, 0 | F_FORCECONV, "\\d*\\s*\\w*\xed\xa0\x80\xed\xa0\x80", "\xed\xa0\x80\xed\xa0\x80" },
{ CMA, 0 | F_FORCECONV | F_NOMATCH, "\\d*?\\D*?\\s*?\\S*?\\w*?\\W*?##", "\xed\xa0\x80\xed\xa0\x80\xed\xa0\x80\xed\xa0\x80#" },
{ CMA | PCRE_EXTENDED, 0 | F_FORCECONV, "\xed\xa0\x80 \xed\xb0\x80 !", "\xed\xa0\x80\xed\xb0\x80!" },
+ { CMA, 0 | F_FORCECONV, "\xed\xa0\x80+#[^#]+\xed\xa0\x80", "\xed\xa0\x80#a\xed\xa0\x80" },
+ { CMA, 0 | F_FORCECONV, "(\xed\xa0\x80+)#\\1", "\xed\xa0\x80\xed\xa0\x80#\xed\xa0\x80\xed\xa0\x80" },
/* Deep recursion. */
{ MUA, 0, "((((?:(?:(?:\\w)+)?)*|(?>\\w)+?)+|(?>\\w)?\?)*)?\\s", "aaaaa+ " },
@@ -654,7 +656,7 @@ static struct regression_test_case regression_test_cases[] = {
{ 0, 0, NULL, NULL }
};
-static const unsigned char *tables(int release)
+static const unsigned char *tables(int mode)
{
/* The purpose of this function to allow valgrind
for reporting invalid reads and writes. */
@@ -669,7 +671,7 @@ static const unsigned char *tables(int release)
PCRE_SCHAR16 null_str[1] = { 0 };
#endif
- if (release) {
+ if (mode) {
if (tables_copy)
free(tables_copy);
tables_copy = NULL;
@@ -697,8 +699,8 @@ static const unsigned char *tables(int release)
if (!default_tables)
return NULL;
- /* This value cannot get from pcre_fullinfo. Since this is a test program,
- we can live with it at the moment. */
+ /* Unfortunately this value cannot get from pcre_fullinfo.
+ Since this is a test program, this is acceptable at the moment. */
tables_copy = (unsigned char *)malloc(1088);
if (!tables_copy)
return NULL;
@@ -712,15 +714,19 @@ static pcre_jit_stack* callback(void *arg)
return (pcre_jit_stack *)arg;
}
-static void setstack(pcre_extra *extra, int alloc_again)
+static void setstack(pcre_extra *extra)
{
static pcre_jit_stack *stack;
- if (alloc_again) {
+ if (!extra) {
if (stack)
pcre_jit_stack_free(stack);
- stack = pcre_jit_stack_alloc(1, 1024 * 1024);
+ stack = NULL;
+ return;
}
+
+ if (!stack)
+ stack = pcre_jit_stack_alloc(1, 1024 * 1024);
/* Extra can be NULL. */
pcre_assign_jit_stack(extra, callback, stack);
}
@@ -913,7 +919,7 @@ static int regression_tests(void)
counter++;
if ((counter & 0x3) != 0)
- setstack(NULL, 1);
+ setstack(NULL);
#ifdef SUPPORT_PCRE8
return_value8_1 = -1000;
@@ -923,7 +929,7 @@ static int regression_tests(void)
for (i = 0; i < 32; ++i)
ovector8_2[i] = -2;
if (re8) {
- setstack(extra8, 0);
+ setstack(extra8);
return_value8_1 = pcre_exec(re8, extra8, current->input, strlen(current->input), current->start_offset & OFFSET_MASK,
current->flags & (PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART), ovector8_1, 32);
return_value8_2 = pcre_exec(re8, NULL, current->input, strlen(current->input), current->start_offset & OFFSET_MASK,
@@ -939,7 +945,7 @@ static int regression_tests(void)
for (i = 0; i < 32; ++i)
ovector16_2[i] = -2;
if (re16) {
- setstack(extra16, 0);
+ setstack(extra16);
if ((current->flags & PCRE_UTF8) || (current->start_offset & F_FORCECONV))
length16 = convert_utf8_to_utf16(current->input, regtest_buf, regtest_offsetmap, REGTEST_MAX_LENGTH);
else
@@ -1079,6 +1085,7 @@ static int regression_tests(void)
current++;
}
tables(1);
+ setstack(NULL);
if (total == successful) {
printf("\nAll JIT regression tests are successfully passed.\n");
diff --git a/pcre_printint.c b/pcre_printint.c
index a61a797..2fcf985 100644
--- a/pcre_printint.c
+++ b/pcre_printint.c
@@ -44,11 +44,13 @@ local functions. This source file is used in two places:
(1) It is #included by pcre_compile.c when it is compiled in debugging mode
(PCRE_DEBUG defined in pcre_internal.h). It is not included in production
-compiles.
+compiles. In this case PCRE_INCLUDED is defined.
(2) It is also compiled separately and linked with pcretest.c, which can be
asked to print out a compiled regex for debugging purposes. */
+#ifndef PCRE_INCLUDED
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -68,10 +70,14 @@ appropriately for an application, not for building PCRE. */
/* These are the funtions that are contained within. It doesn't seem worth
having a separate .h file just for this. */
+#endif /* PCRE_INCLUDED */
+
+#ifdef PCRE_INCLUDED
+static /* Keep the following function as private. */
+#endif
#ifdef COMPILE_PCRE8
void pcre_printint(pcre *external_re, FILE *f, BOOL print_lengths);
-#endif
-#ifdef COMPILE_PCRE16
+#else
void pcre16_printint(pcre *external_re, FILE *f, BOOL print_lengths);
#endif
@@ -230,6 +236,9 @@ print_lengths flag controls whether offsets and lengths of items are printed.
They can be turned off from pcretest so that automatic tests on bytecode can be
written that do not depend on the value of LINK_SIZE. */
+#ifdef PCRE_INCLUDED
+static /* Keep the following function as private. */
+#endif
#ifdef COMPILE_PCRE8
void
pcre_printint(pcre *external_re, FILE *f, BOOL print_lengths)
diff --git a/pcre_study.c b/pcre_study.c
index 4914c62..41ed829 100644
--- a/pcre_study.c
+++ b/pcre_study.c
@@ -577,7 +577,10 @@ return p + 1;
#ifdef COMPILE_PCRE16
if (c > 0xff)
+ {
c = 0xff;
+ caseless = FALSE;
+ }
SET_BIT(c);
#ifdef SUPPORT_UTF