[Pcre-svn] [993] code/trunk: Fix a firstline related bug int…

Góra strony
Delete this message
Autor: Subversion repository
Data:  
Dla: pcre-svn
Temat: [Pcre-svn] [993] code/trunk: Fix a firstline related bug introduced in r986, and use TMP3 as temporary storage for firstline
Revision: 993
          http://vcs.pcre.org/viewvc?view=rev&revision=993
Author:   zherczeg
Date:     2012-07-10 05:33:00 +0100 (Tue, 10 Jul 2012)


Log Message:
-----------
Fix a firstline related bug introduced in r986, and use TMP3 as temporary storage for firstline

Modified Paths:
--------------
    code/trunk/pcre_jit_compile.c
    code/trunk/pcre_jit_test.c


Modified: code/trunk/pcre_jit_compile.c
===================================================================
--- code/trunk/pcre_jit_compile.c    2012-07-08 17:10:07 UTC (rev 992)
+++ code/trunk/pcre_jit_compile.c    2012-07-10 04:33:00 UTC (rev 993)
@@ -2419,7 +2419,7 @@
   {
   /* Search for the end of the first line. */
   SLJIT_ASSERT(common->first_line_end != 0);
-  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0, STR_PTR, 0);
+  OP1(SLJIT_MOV, TMP3, 0, STR_PTR, 0);
   OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->first_line_end, STR_END, 0);


   if (common->nltype == NLTYPE_FIXED && common->newline > 255)
@@ -2447,7 +2447,7 @@
     }


JUMPHERE(end);
- OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0);
+ OP1(SLJIT_MOV, STR_PTR, 0, TMP3, 0);
}

start = JUMP(SLJIT_JUMP);
@@ -2647,7 +2647,8 @@

if (firstline)
{
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE0, STR_END, 0);
+ SLJIT_ASSERT(common->first_line_end != 0);
+ OP1(SLJIT_MOV, TMP3, 0, STR_END, 0);
OP2(SLJIT_SUB, STR_END, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->first_line_end, SLJIT_IMM, 1);
}
else
@@ -2698,8 +2699,9 @@
JUMPHERE(quit);

if (firstline)
- OP1(SLJIT_MOV, STR_END, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE0);
-OP2(SLJIT_ADD, STR_END, 0, STR_END, 0, SLJIT_IMM, 1);
+ OP1(SLJIT_MOV, STR_END, 0, TMP3, 0);
+else
+ OP2(SLJIT_ADD, STR_END, 0, STR_END, 0, SLJIT_IMM, 1);
return TRUE;
}

@@ -2713,7 +2715,8 @@

if (firstline)
{
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE0, STR_END, 0);
+ SLJIT_ASSERT(common->first_line_end != 0);
+ OP1(SLJIT_MOV, TMP3, 0, STR_END, 0);
OP1(SLJIT_MOV, STR_END, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->first_line_end);
}

@@ -2756,7 +2759,7 @@
JUMPHERE(quit);

if (firstline)
- OP1(SLJIT_MOV, STR_END, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE0);
+ OP1(SLJIT_MOV, STR_END, 0, TMP3, 0);
}

static SLJIT_INLINE void fast_forward_newline(compiler_common *common, BOOL firstline)
@@ -2772,7 +2775,8 @@

if (firstline)
{
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE0, STR_END, 0);
+ SLJIT_ASSERT(common->first_line_end != 0);
+ OP1(SLJIT_MOV, TMP3, 0, STR_END, 0);
OP1(SLJIT_MOV, STR_END, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->first_line_end);
}

@@ -2841,7 +2845,7 @@
JUMPHERE(firstchar);

if (firstline)
- OP1(SLJIT_MOV, STR_END, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE0);
+ OP1(SLJIT_MOV, STR_END, 0, TMP3, 0);
}

static SLJIT_INLINE void fast_forward_start_bits(compiler_common *common, sljit_uw start_bits, BOOL firstline)
@@ -2856,7 +2860,8 @@

if (firstline)
{
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE0, STR_END, 0);
+ SLJIT_ASSERT(common->first_line_end != 0);
+ OP1(SLJIT_MOV, TMP3, 0, STR_END, 0);
OP1(SLJIT_MOV, STR_END, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->first_line_end);
}

@@ -2908,7 +2913,7 @@
JUMPHERE(quit);

if (firstline)
- OP1(SLJIT_MOV, STR_END, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE0);
+ OP1(SLJIT_MOV, STR_END, 0, TMP3, 0);
}

 static SLJIT_INLINE struct sljit_jump *search_requested_char(compiler_common *common, pcre_uchar req_char, BOOL caseless, BOOL has_firstchar)
@@ -7800,7 +7805,7 @@
     {
     if (mode == JIT_COMPILE && fast_forward_first_two_chars(common, (re->options & PCRE_FIRSTLINE) != 0))
       /* Do nothing */;
-    if ((re->flags & PCRE_FIRSTSET) != 0)
+    else if ((re->flags & PCRE_FIRSTSET) != 0)
       fast_forward_first_char(common, (pcre_uchar)re->first_char, (re->flags & PCRE_FCH_CASELESS) != 0, (re->options & PCRE_FIRSTLINE) != 0);
     else if ((re->flags & PCRE_STARTLINE) != 0)
       fast_forward_newline(common, (re->options & PCRE_FIRSTLINE) != 0);


Modified: code/trunk/pcre_jit_test.c
===================================================================
--- code/trunk/pcre_jit_test.c    2012-07-08 17:10:07 UTC (rev 992)
+++ code/trunk/pcre_jit_test.c    2012-07-10 04:33:00 UTC (rev 993)
@@ -592,6 +592,7 @@
     { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_CRLF | PCRE_FIRSTLINE, 0 | F_NOMATCH, "ba", "bbb\r\nba" },
     { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_CRLF | PCRE_FIRSTLINE, 0 | F_NOMATCH | F_PROPERTY, "\\p{Any}{4}|a", "\r\na" },
     { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_CRLF | PCRE_FIRSTLINE, 1, ".", "\r\n" },
+    { PCRE_FIRSTLINE | PCRE_NEWLINE_LF | PCRE_DOTALL, 0 | F_NOMATCH, "ab.", "ab" },


     /* Recurse. */
     { MUA, 0, "(a)(?1)", "aa" },
@@ -992,7 +993,7 @@
                 pcre_free(re8);
                 re8 = NULL;
             }
-            if (!(extra8->flags & PCRE_EXTRA_EXECUTABLE_JIT)) {
+            else if (!(extra8->flags & PCRE_EXTRA_EXECUTABLE_JIT)) {
                 printf("\n8 bit: JIT compiler does not support: %s\n", current->pattern);
                 pcre_free_study(extra8);
                 pcre_free(re8);
@@ -1023,7 +1024,7 @@
                 pcre16_free(re16);
                 re16 = NULL;
             }
-            if (!(extra16->flags & PCRE_EXTRA_EXECUTABLE_JIT)) {
+            else if (!(extra16->flags & PCRE_EXTRA_EXECUTABLE_JIT)) {
                 printf("\n16 bit: JIT compiler does not support: %s\n", current->pattern);
                 pcre16_free_study(extra16);
                 pcre16_free(re16);