[Pcre-svn] [806] code/branches/pcre16: lcc and inline printi…

Startseite
Nachricht löschen
Autor: Subversion repository
Datum:  
To: pcre-svn
Betreff: [Pcre-svn] [806] code/branches/pcre16: lcc and inline printint.c fixes
Revision: 806
          http://vcs.pcre.org/viewvc?view=rev&revision=806
Author:   zherczeg
Date:     2011-12-15 11:57:39 +0000 (Thu, 15 Dec 2011)


Log Message:
-----------
lcc and inline printint.c fixes

Modified Paths:
--------------
    code/branches/pcre16/pcre_compile.c
    code/branches/pcre16/pcre_dfa_exec.c
    code/branches/pcre16/pcre_exec.c
    code/branches/pcre16/pcre_jit_test.c
    code/branches/pcre16/pcre_printint.c
    code/branches/pcre16/pcre_study.c


Modified: code/branches/pcre16/pcre_compile.c
===================================================================
--- code/branches/pcre16/pcre_compile.c    2011-12-14 16:49:20 UTC (rev 805)
+++ code/branches/pcre16/pcre_compile.c    2011-12-15 11:57:39 UTC (rev 806)
@@ -59,7 +59,10 @@
 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 @@
     }
   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 @@
     }
   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 @@
           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 @@
         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));
           }
         }


Modified: code/branches/pcre16/pcre_dfa_exec.c
===================================================================
--- code/branches/pcre16/pcre_dfa_exec.c    2011-12-14 16:49:20 UTC (rev 805)
+++ code/branches/pcre16/pcre_dfa_exec.c    2011-12-15 11:57:39 UTC (rev 806)
@@ -2012,7 +2012,8 @@
 #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;



Modified: code/branches/pcre16/pcre_exec.c
===================================================================
--- code/branches/pcre16/pcre_exec.c    2011-12-14 16:49:20 UTC (rev 805)
+++ code/branches/pcre16/pcre_exec.c    2011-12-15 11:57:39 UTC (rev 806)
@@ -204,7 +204,11 @@
     {
     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++;
+      }
     }
   }



Modified: code/branches/pcre16/pcre_jit_test.c
===================================================================
--- code/branches/pcre16/pcre_jit_test.c    2011-12-14 16:49:20 UTC (rev 805)
+++ code/branches/pcre16/pcre_jit_test.c    2011-12-15 11:57:39 UTC (rev 806)
@@ -638,6 +638,8 @@
     { 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 @@
     { 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 @@
     PCRE_SCHAR16 null_str[1] = { 0 };
 #endif


-    if (release) {
+    if (mode) {
         if (tables_copy)
             free(tables_copy);
         tables_copy = NULL;
@@ -697,8 +699,8 @@
     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 @@
     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 = 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 @@


         counter++;
         if ((counter & 0x3) != 0)
-            setstack(NULL, 1);
+            setstack(NULL);


 #ifdef SUPPORT_PCRE8
         return_value8_1 = -1000;
@@ -923,7 +929,7 @@
         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 @@
         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 @@
         current++;
     }
     tables(1);
+    setstack(NULL);


     if (total == successful) {
         printf("\nAll JIT regression tests are successfully passed.\n");


Modified: code/branches/pcre16/pcre_printint.c
===================================================================
--- code/branches/pcre16/pcre_printint.c    2011-12-14 16:49:20 UTC (rev 805)
+++ code/branches/pcre16/pcre_printint.c    2011-12-15 11:57:39 UTC (rev 806)
@@ -44,11 +44,13 @@


(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 @@
/* 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 @@
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)

Modified: code/branches/pcre16/pcre_study.c
===================================================================
--- code/branches/pcre16/pcre_study.c    2011-12-14 16:49:20 UTC (rev 805)
+++ code/branches/pcre16/pcre_study.c    2011-12-15 11:57:39 UTC (rev 806)
@@ -577,7 +577,10 @@


#ifdef COMPILE_PCRE16
if (c > 0xff)
+ {
c = 0xff;
+ caseless = FALSE;
+ }
SET_BIT(c);

#ifdef SUPPORT_UTF