8.37 RC1 bump

This commit is contained in:
Petr Písař 2015-04-22 13:57:42 +02:00
parent de20f156dc
commit 9b59610699
13 changed files with 27 additions and 1487 deletions

1
.gitignore vendored
View File

@ -20,3 +20,4 @@ pcre-8.10.tar.bz2
/pcre-8.35.tar.bz2
/pcre-8.36-RC1.tar.bz2
/pcre-8.36.tar.bz2
/pcre-8.37-RC1.tar.bz2

View File

@ -1,146 +0,0 @@
From 9d8c223a96fde36fc21307abad702ed747135809 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Fri, 10 Apr 2015 08:17:18 +0200
Subject: [PATCH] Fix backtracking bug for \C\X* in UTF mode.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Upstream commits ported to 8.36:
commit 4a81b0ca19da65ea9a50c208017a74e55c3fd027
Author: ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>
Date: Wed Apr 8 16:34:24 2015 +0000
Fix backtracking bug for \C\X* in UTF mode.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1545 2f5784b3-3f2a-0410-8824-cb99058d5e15
commit 6719c2cdeb7670d4bf10f15a8511ca15af7ea595
Author: ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>
Date: Wed Apr 8 16:56:28 2015 +0000
Fix other cases of backtracking crashes after \C in UTF mode.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1546 2f5784b3-3f2a-0410-8824-
cb99058d5e15
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
pcre_exec.c | 19 ++++++++++++-------
testdata/testinput4 | 6 ++++++
testdata/testoutput4 | 8 ++++++++
3 files changed, 26 insertions(+), 7 deletions(-)
diff --git a/pcre_exec.c b/pcre_exec.c
index bb5620d..6c9f4d7 100644
--- a/pcre_exec.c
+++ b/pcre_exec.c
@@ -3490,7 +3490,7 @@ for (;;)
if (possessive) continue; /* No backtracking */
for(;;)
{
- if (eptr == pp) goto TAIL_RECURSE;
+ if (eptr <= pp) goto TAIL_RECURSE;
RMATCH(eptr, ecode, offset_top, md, eptrb, RM23);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
#ifdef SUPPORT_UCP
@@ -3911,7 +3911,7 @@ for (;;)
if (possessive) continue; /* No backtracking */
for(;;)
{
- if (eptr == pp) goto TAIL_RECURSE;
+ if (eptr <= pp) goto TAIL_RECURSE;
RMATCH(eptr, ecode, offset_top, md, eptrb, RM30);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
eptr--;
@@ -4046,7 +4046,7 @@ for (;;)
if (possessive) continue; /* No backtracking */
for(;;)
{
- if (eptr == pp) goto TAIL_RECURSE;
+ if (eptr <= pp) goto TAIL_RECURSE;
RMATCH(eptr, ecode, offset_top, md, eptrb, RM34);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
eptr--;
@@ -5617,7 +5617,7 @@ for (;;)
if (possessive) continue; /* No backtracking */
for(;;)
{
- if (eptr == pp) goto TAIL_RECURSE;
+ if (eptr <= pp) goto TAIL_RECURSE;
RMATCH(eptr, ecode, offset_top, md, eptrb, RM44);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
eptr--;
@@ -5659,12 +5659,17 @@ for (;;)
if (possessive) continue; /* No backtracking */
+ /* We use <= pp rather than == pp to detect the start of the run while
+ backtracking because the use of \C in UTF mode can cause BACKCHAR to
+ move back past pp. This is just palliative; the use of \C in UTF mode
+ is fraught with danger. */
+
for(;;)
{
int lgb, rgb;
PCRE_PUCHAR fptr;
- if (eptr == pp) goto TAIL_RECURSE; /* At start of char run */
+ if (eptr <= pp) goto TAIL_RECURSE; /* At start of char run */
RMATCH(eptr, ecode, offset_top, md, eptrb, RM45);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
@@ -5682,7 +5687,7 @@ for (;;)
for (;;)
{
- if (eptr == pp) goto TAIL_RECURSE; /* At start of char run */
+ if (eptr <= pp) goto TAIL_RECURSE; /* At start of char run */
fptr = eptr - 1;
if (!utf) c = *fptr; else
{
@@ -5932,7 +5937,7 @@ for (;;)
if (possessive) continue; /* No backtracking */
for(;;)
{
- if (eptr == pp) goto TAIL_RECURSE;
+ if (eptr <= pp) goto TAIL_RECURSE;
RMATCH(eptr, ecode, offset_top, md, eptrb, RM46);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
eptr--;
diff --git a/testdata/testinput4 b/testdata/testinput4
index 04fca1a..f139c62 100644
--- a/testdata/testinput4
+++ b/testdata/testinput4
@@ -724,4 +724,10 @@
"[\S\V\H]"8
+/\C\X*QT/8
+ Ӆ\x0aT
+
+/\C(\W?ſ)'?{{/8
+ \\C(\\W?ſ)'?{{
+
/-- End of testinput4 --/
diff --git a/testdata/testoutput4 b/testdata/testoutput4
index 340a949..ffd02ea 100644
--- a/testdata/testoutput4
+++ b/testdata/testoutput4
@@ -1273,4 +1273,12 @@ No match
"[\S\V\H]"8
+/\C\X*QT/8
+ Ӆ\x0aT
+No match
+
+/\C(\W?ſ)'?{{/8
+ \\C(\\W?ſ)'?{{
+No match
+
/-- End of testinput4 --/
--
2.1.0

View File

@ -1,71 +0,0 @@
From e2eeaf85f1b5d6c4669b621d309ff904cbf96f4b Mon Sep 17 00:00:00 2001
From: ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>
Date: Wed, 5 Nov 2014 15:08:03 +0000
Subject: [PATCH] Fix bug when there are unset groups prior to (*ACCEPT) within
a capturing group.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1510 2f5784b3-3f2a-0410-8824-cb99058d5e15
Signed-off-by: Petr Písař <ppisar@redhat.com>
Petr Pisar: Ported to 8.36
diff --git a/pcre_exec.c b/pcre_exec.c
index 654eb9e..fdf7067 100644
--- a/pcre_exec.c
+++ b/pcre_exec.c
@@ -1474,7 +1474,18 @@ for (;;)
md->offset_vector[offset] =
md->offset_vector[md->offset_end - number];
md->offset_vector[offset+1] = (int)(eptr - md->start_subject);
- if (offset_top <= offset) offset_top = offset + 2;
+
+ /* If this group is at or above the current highwater mark, ensure that
+ any groups between the current high water mark and this group are marked
+ unset and then update the high water mark. */
+
+ if (offset >= offset_top)
+ {
+ register int *iptr = md->offset_vector + offset_top;
+ register int *iend = md->offset_vector + offset;
+ while (iptr < iend) *iptr++ = -1;
+ offset_top = offset + 2;
+ }
}
ecode += 1 + IMM2_SIZE;
break;
diff --git a/testdata/testinput1 b/testdata/testinput1
index 123e3d3..091e307 100644
--- a/testdata/testinput1
+++ b/testdata/testinput1
@@ -5720,4 +5720,7 @@ AbcdCBefgBhiBqz
/[\Q]a\E]+/
aa]]
+/(?:((abcd))|(((?:(?:(?:(?:abc|(?:abcdef))))b)abcdefghi)abc)|((*ACCEPT)))/
+ 1234abcd
+
/-- End of testinput1 --/
diff --git a/testdata/testoutput1 b/testdata/testoutput1
index 5e71900..ba7ca37 100644
--- a/testdata/testoutput1
+++ b/testdata/testoutput1
@@ -9411,4 +9411,13 @@ No match
aa]]
0: aa]]
+/(?:((abcd))|(((?:(?:(?:(?:abc|(?:abcdef))))b)abcdefghi)abc)|((*ACCEPT)))/
+ 1234abcd
+ 0:
+ 1: <unset>
+ 2: <unset>
+ 3: <unset>
+ 4: <unset>
+ 5:
+
/-- End of testinput1 --/
--
1.9.3

View File

@ -1,125 +0,0 @@
From 9b7e52d469c3c0016efb9e0a74895b187215cecb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Thu, 9 Apr 2015 17:50:59 +0200
Subject: [PATCH] Fix comment between subroutine call and quantifier bug.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Upstream commit ported to 8.36:
commit 0bff93ec6f942ad9703a33416c3ca2ddc060de73
Author: ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>
Date: Sun Mar 29 11:22:24 2015 +0000
Fix comment between subroutine call and quantifier bug.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1538 2f5784b3-3f2a-0410-8824-
cb99058d5e15
Signed-off-by: Petr Písař <ppisar@redhat.com>
diff --git a/pcre_compile.c b/pcre_compile.c
index ce187cd..603e50a 100644
--- a/pcre_compile.c
+++ b/pcre_compile.c
@@ -6426,15 +6426,25 @@ for (;; ptr++)
parenthesis forms. */
case CHAR_LEFT_PARENTHESIS:
- newoptions = options;
- skipbytes = 0;
- bravalue = OP_CBRA;
- save_hwm = cd->hwm;
- reset_bracount = FALSE;
+ ptr++;
- /* First deal with various "verbs" that can be introduced by '*'. */
+ /* First deal with comments. Putting this code right at the start ensures
+ that comments have no bad side effects. */
+
+ if (ptr[0] == CHAR_QUESTION_MARK && ptr[1] == CHAR_NUMBER_SIGN)
+ {
+ ptr += 2;
+ while (*ptr != CHAR_NULL && *ptr != CHAR_RIGHT_PARENTHESIS) ptr++;
+ if (*ptr == CHAR_NULL)
+ {
+ *errorcodeptr = ERR18;
+ goto FAILED;
+ }
+ continue;
+ }
+
+ /* Now deal with various "verbs" that can be introduced by '*'. */
- ptr++;
if (ptr[0] == CHAR_ASTERISK && (ptr[1] == ':'
|| (MAX_255(ptr[1]) && ((cd->ctypes[ptr[1]] & ctype_letter) != 0))))
{
@@ -6555,10 +6565,18 @@ for (;; ptr++)
goto FAILED;
}
+ /* Initialize for "real" parentheses */
+
+ newoptions = options;
+ skipbytes = 0;
+ bravalue = OP_CBRA;
+ save_hwm = cd->hwm;
+ reset_bracount = FALSE;
+
/* Deal with the extended parentheses; all are introduced by '?', and the
appearance of any of them means that this is not a capturing group. */
- else if (*ptr == CHAR_QUESTION_MARK)
+ if (*ptr == CHAR_QUESTION_MARK)
{
int i, set, unset, namelen;
int *optset;
@@ -6567,17 +6585,6 @@ for (;; ptr++)
switch (*(++ptr))
{
- case CHAR_NUMBER_SIGN: /* Comment; skip to ket */
- ptr++;
- while (*ptr != CHAR_NULL && *ptr != CHAR_RIGHT_PARENTHESIS) ptr++;
- if (*ptr == CHAR_NULL)
- {
- *errorcodeptr = ERR18;
- goto FAILED;
- }
- continue;
-
-
/* ------------------------------------------------------------ */
case CHAR_VERTICAL_LINE: /* Reset capture count for each branch */
reset_bracount = TRUE;
diff --git a/testdata/testinput1 b/testdata/testinput1
index 091e307..29f9d2d 100644
--- a/testdata/testinput1
+++ b/testdata/testinput1
@@ -5723,4 +5723,7 @@ AbcdCBefgBhiBqz
/(?:((abcd))|(((?:(?:(?:(?:abc|(?:abcdef))))b)abcdefghi)abc)|((*ACCEPT)))/
1234abcd
+"(?1)(?#?'){8}(a)"
+ baaaaaaaaac
+
/-- End of testinput1 --/
diff --git a/testdata/testoutput1 b/testdata/testoutput1
index ba7ca37..34d1b55 100644
--- a/testdata/testoutput1
+++ b/testdata/testoutput1
@@ -9420,4 +9420,9 @@ No match
4: <unset>
5:
+"(?1)(?#?'){8}(a)"
+ baaaaaaaaac
+ 0: aaaaaaaaa
+ 1: a
+
/-- End of testinput1 --/
--
2.1.0

View File

@ -1,68 +0,0 @@
From 0b2b017da7c68a8cddd3ee3395dcc26c87236402 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Thu, 9 Apr 2015 17:02:59 +0200
Subject: [PATCH] Fix memory bug for [\S\V\H] compile.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This is upstream commit ported to 8.36:
commit ef430ada283aba3ff71d7de496904f4d137280f8
Author: ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>
Date: Fri Mar 27 16:44:50 2015 +0000
Fix memory bug for [\S\V\H] compile.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1536 2f5784b3-3f2a-0410-8824-
cb99058d5e15
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
pcre_compile.c | 6 ++++++
testdata/testinput4 | 2 ++
testdata/testoutput4 | 2 ++
3 files changed, 10 insertions(+)
diff --git a/pcre_compile.c b/pcre_compile.c
index efc0b21..c256ea5 100644
--- a/pcre_compile.c
+++ b/pcre_compile.c
@@ -5472,6 +5472,12 @@ for (;; ptr++)
}
#endif
+ /* Even though any XCLASS list is now discarded, we must allow for
+ its memory. */
+
+ if (lengthptr != NULL)
+ *lengthptr += (int)(class_uchardata - class_uchardata_base);
+
/* If there are no characters > 255, or they are all to be included or
excluded, set the opcode to OP_CLASS or OP_NCLASS, depending on whether the
whole class was negated and whether there were negative specials such as \S
diff --git a/testdata/testinput4 b/testdata/testinput4
index 0110267..04fca1a 100644
--- a/testdata/testinput4
+++ b/testdata/testinput4
@@ -722,4 +722,6 @@
/^#[^\x{ffff}]#[^\x{ffff}]#[^\x{ffff}]#/8
#\x{10000}#\x{100}#\x{10ffff}#
+"[\S\V\H]"8
+
/-- End of testinput4 --/
diff --git a/testdata/testoutput4 b/testdata/testoutput4
index dcf13b0..340a949 100644
--- a/testdata/testoutput4
+++ b/testdata/testoutput4
@@ -1271,4 +1271,6 @@ No match
#\x{10000}#\x{100}#\x{10ffff}#
0: #\x{10000}#\x{100}#\x{10ffff}#
+"[\S\V\H]"8
+
/-- End of testinput4 --/
--
2.1.0

View File

@ -1,60 +0,0 @@
From 9ddce66fd62671186bcd66b1aa72e31cba135c26 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Thu, 9 Apr 2015 17:23:38 +0200
Subject: [PATCH] Fix mutual recursion inside other groups stack overflow bug.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Upstream commit ported to 8.36:
commit e97ec7dc839022a3efe740c532ea3e67e4446430
Author: ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>
Date: Fri Mar 27 17:48:28 2015 +0000
Fix mutual recursion inside other groups stack overflow bug.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1537 2f5784b3-3f2a-0410-8824-cb99058d5e15
Signed-off-by: Petr Písař <ppisar@redhat.com>
diff --git a/pcre_compile.c b/pcre_compile.c
index c256ea5..ce187cd 100644
--- a/pcre_compile.c
+++ b/pcre_compile.c
@@ -2469,8 +2469,8 @@ for (code = first_significant_code(code + PRIV(OP_lengths)[*code], TRUE);
empty_branch = FALSE;
do
{
- if (!empty_branch && could_be_empty_branch(code, endcode, utf, cd, NULL))
- empty_branch = TRUE;
+ if (!empty_branch && could_be_empty_branch(code, endcode, utf, cd,
+ recurses)) empty_branch = TRUE;
code += GET(code, 1);
}
while (*code == OP_ALT);
diff --git a/testdata/testinput2 b/testdata/testinput2
index 015422e..c01a094 100644
--- a/testdata/testinput2
+++ b/testdata/testinput2
@@ -4084,4 +4084,6 @@ backtracking verbs. --/
"(?(?=)?==)(((((((((?=)))))))))"
a
+"((?2)+)((?1))"
+
/-- End of testinput2 --/
diff --git a/testdata/testoutput2 b/testdata/testoutput2
index 9a1b14e..0118730 100644
--- a/testdata/testoutput2
+++ b/testdata/testoutput2
@@ -14216,4 +14216,6 @@ Failed: non-hex character in \x{} (closing brace missing?) at offset 3
a
No match
+"((?2)+)((?1))"
+
/-- End of testinput2 --/
--
2.1.0

View File

@ -1,211 +0,0 @@
From 8f907e8731b5eb4aca840a1979e76eed1b5c8175 Mon Sep 17 00:00:00 2001
From: ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>
Date: Tue, 7 Apr 2015 15:52:11 +0000
Subject: [PATCH] Fix pcregrep loop when \K is used in a lookbehind assertion.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Upstream commit ported to 8.36:
commit b4332d7dd831b3547b3f541495de4a79554e538e
Author: ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>
Date: Tue Apr 7 15:52:11 2015 +0000
Fix pcregrep loop when \K is used in a lookbehind assertion.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1543 2f5784b3-3f2a-0410-8824-cb99058d5e15
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
RunGrepTest | 5 +++
pcregrep.c | 109 ++++++++++++++++++++++++++++++++++------------------
testdata/grepoutput | 8 ++++
3 files changed, 85 insertions(+), 37 deletions(-)
diff --git a/RunGrepTest b/RunGrepTest
index f1b0348..766278b 100755
--- a/RunGrepTest
+++ b/RunGrepTest
@@ -506,6 +506,11 @@ echo "---------------------------- Test 106 -----------------------------" >>tes
(cd $srcdir; echo "a" | $valgrind $pcregrep -M "|a" ) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
+echo "---------------------------- Test 107 -----------------------------" >>testtrygrep
+echo "a" >testtemp1grep
+echo "aaaaa" >>testtemp1grep
+(cd $srcdir; $valgrind $pcregrep --line-offsets '(?<=\Ka)' testtemp1grep) >>testtrygrep 2>&1
+echo "RC=$?" >>testtrygrep
# Now compare the results.
diff --git a/pcregrep.c b/pcregrep.c
index 4f7fa38..b1af129 100644
--- a/pcregrep.c
+++ b/pcregrep.c
@@ -1582,11 +1582,14 @@ while (ptr < endptr)
int endlinelength;
int mrc = 0;
int startoffset = 0;
+ int prevoffsets[2];
unsigned int options = 0;
BOOL match;
char *matchptr = ptr;
char *t = ptr;
size_t length, linelength;
+
+ prevoffsets[0] = prevoffsets[1] = -1;
/* At this point, ptr is at the start of a line. We need to find the length
of the subject string to pass to pcre_exec(). In multiline mode, it is the
@@ -1729,55 +1732,86 @@ while (ptr < endptr)
{
if (!invert)
{
- if (printname != NULL) fprintf(stdout, "%s:", printname);
- if (number) fprintf(stdout, "%d:", linenumber);
-
- /* Handle --line-offsets */
-
- if (line_offsets)
- fprintf(stdout, "%d,%d\n", (int)(matchptr + offsets[0] - ptr),
- offsets[1] - offsets[0]);
-
- /* Handle --file-offsets */
-
- else if (file_offsets)
- fprintf(stdout, "%d,%d\n",
- (int)(filepos + matchptr + offsets[0] - ptr),
- offsets[1] - offsets[0]);
-
- /* Handle --only-matching, which may occur many times */
-
- else
+ int oldstartoffset = startoffset;
+
+ /* It is possible, when a lookbehind assertion contains \K, for the
+ same string to be found again. The code below advances startoffset, but
+ until it is past the "bumpalong" offset that gave the match, the same
+ substring will be returned. The PCRE1 library does not return the
+ bumpalong offset, so all we can do is ignore repeated strings. (PCRE2
+ does this better.) */
+
+ if (prevoffsets[0] != offsets[0] || prevoffsets[1] != offsets[1])
{
- BOOL printed = FALSE;
- omstr *om;
-
- for (om = only_matching; om != NULL; om = om->next)
+ prevoffsets[0] = offsets[0];
+ prevoffsets[1] = offsets[1];
+
+ if (printname != NULL) fprintf(stdout, "%s:", printname);
+ if (number) fprintf(stdout, "%d:", linenumber);
+
+ /* Handle --line-offsets */
+
+ if (line_offsets)
+ fprintf(stdout, "%d,%d\n", (int)(matchptr + offsets[0] - ptr),
+ offsets[1] - offsets[0]);
+
+ /* Handle --file-offsets */
+
+ else if (file_offsets)
+ fprintf(stdout, "%d,%d\n",
+ (int)(filepos + matchptr + offsets[0] - ptr),
+ offsets[1] - offsets[0]);
+
+ /* Handle --only-matching, which may occur many times */
+
+ else
{
- int n = om->groupnum;
- if (n < mrc)
+ BOOL printed = FALSE;
+ omstr *om;
+
+ for (om = only_matching; om != NULL; om = om->next)
{
- int plen = offsets[2*n + 1] - offsets[2*n];
- if (plen > 0)
+ int n = om->groupnum;
+ if (n < mrc)
{
- if (printed) fprintf(stdout, "%s", om_separator);
- if (do_colour) fprintf(stdout, "%c[%sm", 0x1b, colour_string);
- FWRITE(matchptr + offsets[n*2], 1, plen, stdout);
- if (do_colour) fprintf(stdout, "%c[00m", 0x1b);
- printed = TRUE;
+ int plen = offsets[2*n + 1] - offsets[2*n];
+ if (plen > 0)
+ {
+ if (printed) fprintf(stdout, "%s", om_separator);
+ if (do_colour) fprintf(stdout, "%c[%sm", 0x1b, colour_string);
+ FWRITE(matchptr + offsets[n*2], 1, plen, stdout);
+ if (do_colour) fprintf(stdout, "%c[00m", 0x1b);
+ printed = TRUE;
+ }
}
}
+
+ if (printed || printname != NULL || number) fprintf(stdout, "\n");
}
-
- if (printed || printname != NULL || number) fprintf(stdout, "\n");
- }
-
- /* Prepare to repeat to find the next match */
+ }
+
+ /* Prepare to repeat to find the next match. If the patterned contained
+ a lookbehind tht included \K, it is possible that the end of the match
+ might be at or before the actual strting offset we have just used. We
+ need to start one character further on. Unfortunately, for unanchored
+ patterns, the actual start offset can be greater that the one that was
+ set as a result of "bumpalong". PCRE1 does not return the actual start
+ offset, so we have to check against the original start offset. This may
+ lead to duplicates - we we need the fudge above to avoid printing them.
+ (PCRE2 does this better.) */
match = FALSE;
if (line_buffered) fflush(stdout);
rc = 0; /* Had some success */
startoffset = offsets[1]; /* Restart after the match */
+ if (startoffset <= oldstartoffset)
+ {
+ if ((size_t)startoffset >= length)
+ goto END_ONE_MATCH; /* We were at the end */
+ startoffset = oldstartoffset + 1;
+ if (utf8)
+ while ((matchptr[startoffset] & 0xc0) == 0x80) startoffset++;
+ }
goto ONLY_MATCHING_RESTART;
}
}
@@ -1974,6 +2008,7 @@ while (ptr < endptr)
/* Advance to after the newline and increment the line number. The file
offset to the current line is maintained in filepos. */
+ END_ONE_MATCH:
ptr += linelength + endlinelength;
filepos += (int)(linelength + endlinelength);
linenumber++;
diff --git a/testdata/grepoutput b/testdata/grepoutput
index 9bf9d9d..4d61752 100644
--- a/testdata/grepoutput
+++ b/testdata/grepoutput
@@ -743,3 +743,11 @@ RC=0
---------------------------- Test 106 -----------------------------
a
RC=0
+---------------------------- Test 107 -----------------------------
+1:0,1
+2:0,1
+2:1,1
+2:2,1
+2:3,1
+2:4,1
+RC=0
--
2.1.0

View File

@ -1,175 +0,0 @@
From a690f6bf85225c34d3e336664d2437c16f7a7238 Mon Sep 17 00:00:00 2001
From: ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>
Date: Tue, 7 Apr 2015 16:19:03 +0000
Subject: [PATCH] Fix pcretest loop for \K in lookbehind assertion.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Upstream commit ported to 8.36:
commit c3579a7581cb8b3ca3c9617d63083afea29de646
Author: ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>
Date: Tue Apr 7 16:19:03 2015 +0000
Fix pcretest loop for \K in lookbehind assertion.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1544 2f5784b3-3f2a-0410-8824-cb99058d5e15
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
pcretest.c | 30 +++++++++++++++++++++++++++---
testdata/testinput2 | 6 ++++++
testdata/testinput5 | 6 ++++++
testdata/testoutput2 | 28 ++++++++++++++++++++++++++++
testdata/testoutput5 | 28 ++++++++++++++++++++++++++++
5 files changed, 95 insertions(+), 3 deletions(-)
diff --git a/pcretest.c b/pcretest.c
index b8dc3c6..6e6ef48 100644
--- a/pcretest.c
+++ b/pcretest.c
@@ -5618,9 +5618,33 @@ while (!done)
g_notempty = PCRE_NOTEMPTY_ATSTART | PCRE_ANCHORED;
}
- /* For /g, update the start offset, leaving the rest alone */
-
- if (do_g) start_offset = use_offsets[1];
+ /* For /g, update the start offset, leaving the rest alone. There is a
+ tricky case when \K is used in a positive lookbehind assertion. This can
+ cause the end of the match to be less than or equal to the start offset.
+ In this case we restart at one past the start offset. This may return the
+ same match if the original start offset was bumped along during the
+ match, but eventually the new start offset will hit the actual start
+ offset. (In PCRE2 the true start offset is available, and this can be
+ done better. It is not worth doing more than making sure we do not loop
+ at this stage in the life of PCRE1.) */
+
+ if (do_g)
+ {
+ if (g_notempty == 0 && use_offsets[1] <= start_offset)
+ {
+ if (start_offset >= len) break; /* End of subject */
+ start_offset++;
+ if (use_utf)
+ {
+ while (start_offset < len)
+ {
+ if ((bptr[start_offset] & 0xc0) != 0x80) break;
+ start_offset++;
+ }
+ }
+ }
+ else start_offset = use_offsets[1];
+ }
/* For /G, update the pointer and length */
diff --git a/testdata/testinput2 b/testdata/testinput2
index 0fc535a..f8fbced 100644
--- a/testdata/testinput2
+++ b/testdata/testinput2
@@ -4088,4 +4088,10 @@ backtracking verbs. --/
"(?<=((?2))((?1)))"
+/(?<=\Ka)/g+
+ aaaaa
+
+/(?<=\Ka)/G+
+ aaaaa
+
/-- End of testinput2 --/
diff --git a/testdata/testinput5 b/testdata/testinput5
index e36b09d..fe7218d 100644
--- a/testdata/testinput5
+++ b/testdata/testinput5
@@ -790,4 +790,10 @@
/[b-d\x{200}-\x{250}]*[ae-h]?#[\x{200}-\x{250}]{0,8}[\x00-\xff]*#[\x{200}-\x{250}]+[a-z]/8BZ
+/(?<=\K\x{17f})/8g+
+ \x{17f}\x{17f}\x{17f}\x{17f}\x{17f}
+
+/(?<=\K\x{17f})/8G+
+ \x{17f}\x{17f}\x{17f}\x{17f}\x{17f}
+
/-- End of testinput5 --/
diff --git a/testdata/testoutput2 b/testdata/testoutput2
index 45662a9..5233de4 100644
--- a/testdata/testoutput2
+++ b/testdata/testoutput2
@@ -14221,4 +14221,32 @@ No match
"(?<=((?2))((?1)))"
Failed: lookbehind assertion is not fixed length at offset 17
+/(?<=\Ka)/g+
+ aaaaa
+ 0: a
+ 0+ aaaa
+ 0: a
+ 0+ aaaa
+ 0: a
+ 0+ aaa
+ 0: a
+ 0+ aa
+ 0: a
+ 0+ a
+ 0: a
+ 0+
+
+/(?<=\Ka)/G+
+ aaaaa
+ 0: a
+ 0+ aaaa
+ 0: a
+ 0+ aaa
+ 0: a
+ 0+ aa
+ 0: a
+ 0+ a
+ 0: a
+ 0+
+
/-- End of testinput2 --/
diff --git a/testdata/testoutput5 b/testdata/testoutput5
index 5c098e6..b338e23 100644
--- a/testdata/testoutput5
+++ b/testdata/testoutput5
@@ -1897,4 +1897,32 @@ Failed: disallowed Unicode code point (>= 0xd800 && <= 0xdfff) at offset 5
End
------------------------------------------------------------------
+/(?<=\K\x{17f})/8g+
+ \x{17f}\x{17f}\x{17f}\x{17f}\x{17f}
+ 0: \x{17f}
+ 0+ \x{17f}\x{17f}\x{17f}\x{17f}
+ 0: \x{17f}
+ 0+ \x{17f}\x{17f}\x{17f}\x{17f}
+ 0: \x{17f}
+ 0+ \x{17f}\x{17f}\x{17f}
+ 0: \x{17f}
+ 0+ \x{17f}\x{17f}
+ 0: \x{17f}
+ 0+ \x{17f}
+ 0: \x{17f}
+ 0+
+
+/(?<=\K\x{17f})/8G+
+ \x{17f}\x{17f}\x{17f}\x{17f}\x{17f}
+ 0: \x{17f}
+ 0+ \x{17f}\x{17f}\x{17f}\x{17f}
+ 0: \x{17f}
+ 0+ \x{17f}\x{17f}\x{17f}
+ 0: \x{17f}
+ 0+ \x{17f}\x{17f}
+ 0: \x{17f}
+ 0+ \x{17f}
+ 0: \x{17f}
+ 0+
+
/-- End of testinput5 --/
--
2.1.0

View File

@ -1,151 +0,0 @@
From 53469ce0ff5dac0aadfda412c4fa243e341e4b30 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Thu, 9 Apr 2015 18:35:04 +0200
Subject: [PATCH] Fix stack overflow instead of diagnostic for mutual recursion
inside a lookbehind assertion.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Upstream commit porter to 8.36:
commit 256d94987eecd7eb87b37e1c981a4e753ed8ab7a
Author: ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>
Date: Wed Apr 1 15:43:53 2015 +0000
Fix stack overflow instead of diagnostic for mutual recursion inside a
lookbehind assertion.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1542 2f5784b3-3f2a-0410-8824-cb99058d5e15
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
pcre_compile.c | 36 +++++++++++++++++++++++++-----------
testdata/testinput2 | 2 ++
testdata/testoutput2 | 3 +++
3 files changed, 30 insertions(+), 11 deletions(-)
diff --git a/pcre_compile.c b/pcre_compile.c
index 603e50a..ec7ecf4 100644
--- a/pcre_compile.c
+++ b/pcre_compile.c
@@ -866,6 +866,14 @@ static const pcre_uint8 opcode_possessify[] = {
};
+/* Structure for mutual recursion detection. */
+
+typedef struct recurse_check {
+ struct recurse_check *prev;
+ const pcre_uchar *group;
+} recurse_check;
+
+
/*************************************************
* Find an error text *
@@ -1704,6 +1712,7 @@ Arguments:
utf TRUE in UTF-8 / UTF-16 / UTF-32 mode
atend TRUE if called when the pattern is complete
cd the "compile data" structure
+ recurses chain of recurse_check to catch mutual recursion
Returns: the fixed length,
or -1 if there is no fixed length,
@@ -1713,10 +1722,11 @@ Returns: the fixed length,
*/
static int
-find_fixedlength(pcre_uchar *code, BOOL utf, BOOL atend, compile_data *cd)
+find_fixedlength(pcre_uchar *code, BOOL utf, BOOL atend, compile_data *cd,
+ recurse_check *recurses)
{
int length = -1;
-
+recurse_check this_recurse;
register int branchlength = 0;
register pcre_uchar *cc = code + 1 + LINK_SIZE;
@@ -1741,7 +1751,8 @@ for (;;)
case OP_ONCE:
case OP_ONCE_NC:
case OP_COND:
- d = find_fixedlength(cc + ((op == OP_CBRA)? IMM2_SIZE : 0), utf, atend, cd);
+ d = find_fixedlength(cc + ((op == OP_CBRA)? IMM2_SIZE : 0), utf, atend, cd,
+ recurses);
if (d < 0) return d;
branchlength += d;
do cc += GET(cc, 1); while (*cc == OP_ALT);
@@ -1775,7 +1786,15 @@ for (;;)
cs = ce = (pcre_uchar *)cd->start_code + GET(cc, 1); /* Start subpattern */
do ce += GET(ce, 1); while (*ce == OP_ALT); /* End subpattern */
if (cc > cs && cc < ce) return -1; /* Recursion */
- d = find_fixedlength(cs + IMM2_SIZE, utf, atend, cd);
+ else /* Check for mutual recursion */
+ {
+ recurse_check *r = recurses;
+ for (r = recurses; r != NULL; r = r->prev) if (r->group == cs) break;
+ if (r != NULL) return -1; /* Mutual recursion */
+ }
+ this_recurse.prev = recurses;
+ this_recurse.group = cs;
+ d = find_fixedlength(cs + IMM2_SIZE, utf, atend, cd, &this_recurse);
if (d < 0) return d;
branchlength += d;
cc += 1 + LINK_SIZE;
@@ -2334,11 +2353,6 @@ Arguments:
Returns: TRUE if what is matched could be empty
*/
-typedef struct recurse_check {
- struct recurse_check *prev;
- const pcre_uchar *group;
-} recurse_check;
-
static BOOL
could_be_empty_branch(const pcre_uchar *code, const pcre_uchar *endcode,
BOOL utf, compile_data *cd, recurse_check *recurses)
@@ -8225,7 +8239,7 @@ for (;;)
int fixed_length;
*code = OP_END;
fixed_length = find_fixedlength(last_branch, (options & PCRE_UTF8) != 0,
- FALSE, cd);
+ FALSE, cd, NULL);
DPRINTF(("fixed length = %d\n", fixed_length));
if (fixed_length == -3)
{
@@ -9332,7 +9346,7 @@ if (cd->check_lookbehind)
int end_op = *be;
*be = OP_END;
fixed_length = find_fixedlength(cc, (re->options & PCRE_UTF8) != 0, TRUE,
- cd);
+ cd, NULL);
*be = end_op;
DPRINTF(("fixed length = %d\n", fixed_length));
if (fixed_length < 0)
diff --git a/testdata/testinput2 b/testdata/testinput2
index c01a094..0fc535a 100644
--- a/testdata/testinput2
+++ b/testdata/testinput2
@@ -4086,4 +4086,6 @@ backtracking verbs. --/
"((?2)+)((?1))"
+"(?<=((?2))((?1)))"
+
/-- End of testinput2 --/
diff --git a/testdata/testoutput2 b/testdata/testoutput2
index 0118730..45662a9 100644
--- a/testdata/testoutput2
+++ b/testdata/testoutput2
@@ -14218,4 +14218,7 @@ No match
"((?2)+)((?1))"
+"(?<=((?2))((?1)))"
+Failed: lookbehind assertion is not fixed length at offset 17
+
/-- End of testinput2 --/
--
2.1.0

View File

@ -1,68 +0,0 @@
From 48d2472840efc4dc54dfc698d64aa086332a9033 Mon Sep 17 00:00:00 2001
From: ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>
Date: Wed, 19 Nov 2014 20:57:13 +0000
Subject: [PATCH] Fix zero-repeat assertion condition bug.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1513 2f5784b3-3f2a-0410-8824-cb99058d5e15
Signed-off-by: Petr Písař <ppisar@redhat.com>
Petr Pisar: Ported to 8.36.
diff --git a/pcre_exec.c b/pcre_exec.c
index fdf7067..bb5620d 100644
--- a/pcre_exec.c
+++ b/pcre_exec.c
@@ -1404,8 +1404,11 @@ for (;;)
condition = TRUE;
/* Advance ecode past the assertion to the start of the first branch,
- but adjust it so that the general choosing code below works. */
-
+ but adjust it so that the general choosing code below works. If the
+ assertion has a quantifier that allows zero repeats we must skip over
+ the BRAZERO. This is a lunatic thing to do, but somebody did! */
+
+ if (*ecode == OP_BRAZERO) ecode++;
ecode += GET(ecode, 1);
while (*ecode == OP_ALT) ecode += GET(ecode, 1);
ecode += 1 + LINK_SIZE - PRIV(OP_lengths)[condcode];
diff --git a/testdata/testinput2 b/testdata/testinput2
index c6816bf..015422e 100644
--- a/testdata/testinput2
+++ b/testdata/testinput2
@@ -4078,4 +4078,10 @@ backtracking verbs. --/
/\x{whatever}/
+"((?=(?(?=(?(?=(?(?=())))*)))))"
+ a
+
+"(?(?=)?==)(((((((((?=)))))))))"
+ a
+
/-- End of testinput2 --/
diff --git a/testdata/testoutput2 b/testdata/testoutput2
index 1e87026..9a1b14e 100644
--- a/testdata/testoutput2
+++ b/testdata/testoutput2
@@ -14206,4 +14206,14 @@ Failed: digits missing in \x{} or \o{} at offset 3
/\x{whatever}/
Failed: non-hex character in \x{} (closing brace missing?) at offset 3
+"((?=(?(?=(?(?=(?(?=())))*)))))"
+ a
+ 0:
+ 1:
+ 2:
+
+"(?(?=)?==)(((((((((?=)))))))))"
+ a
+No match
+
/-- End of testinput2 --/
--
1.9.3

View File

@ -1,366 +0,0 @@
From acfc48addb7b4fc73985f9f236fbb7e12e2388ef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Thu, 26 Mar 2015 10:55:42 +0100
Subject: [PATCH] Remove computing the JIT read-only data size in advance and
use on-demand memory allocation.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Upstream commit:
commit 3831a81914cf11565bf429dd019c9442b404bc5f
Author: zherczeg <zherczeg@2f5784b3-3f2a-0410-8824-cb99058d5e15>
Date: Thu Mar 5 08:53:37 2015 +0000
Remove computing the JIT read-only data size in advance and use on-demand memory allocation.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1530 2f5784b3-3f2a-0410-8824-cb99058d5e15
ported to 8.36.
<http://bugs.exim.org/show_bug.cgi?id=1597>
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
pcre_jit_compile.c | 123 ++++++++++++++++++----------------------------
sljit/sljitLir.h | 6 +++
sljit/sljitNativeARM_32.c | 4 +-
testdata/testinput12 | 8 +++
testdata/testoutput12 | 8 +++
5 files changed, 74 insertions(+), 75 deletions(-)
diff --git a/pcre_jit_compile.c b/pcre_jit_compile.c
index 256e3a4..53049fe 100644
--- a/pcre_jit_compile.c
+++ b/pcre_jit_compile.c
@@ -179,7 +179,7 @@ typedef struct jit_arguments {
typedef struct executable_functions {
void *executable_funcs[JIT_NUMBER_OF_COMPILE_MODES];
- sljit_uw *read_only_data[JIT_NUMBER_OF_COMPILE_MODES];
+ void *read_only_data_heads[JIT_NUMBER_OF_COMPILE_MODES];
sljit_uw executable_sizes[JIT_NUMBER_OF_COMPILE_MODES];
PUBL(jit_callback) callback;
void *userdata;
@@ -322,14 +322,10 @@ typedef struct compiler_common {
pcre_uchar *start;
/* Maps private data offset to each opcode. */
sljit_si *private_data_ptrs;
- /* This read-only data is available during runtime. */
- sljit_uw *read_only_data;
- /* The total size of the read-only data. */
- sljit_uw read_only_data_size;
- /* The next free entry of the read_only_data. */
- sljit_uw *read_only_data_ptr;
/* Tells whether the capturing bracket is optimized. */
pcre_uint8 *optimized_cbracket;
+ /* Chain list of read-only data ptrs. */
+ void *read_only_data_head;
/* Tells whether the starting offset is a target of then. */
pcre_uint8 *then_offsets;
/* Current position where a THEN must jump. */
@@ -802,16 +798,6 @@ while (cc < ccend)
cc += 1 + IMM2_SIZE;
break;
- case OP_BRA:
- case OP_CBRA:
- case OP_SBRA:
- case OP_SCBRA:
- count = no_alternatives(cc);
- if (count > 4)
- common->read_only_data_size += count * sizeof(sljit_uw);
- cc += 1 + LINK_SIZE + (*cc == OP_CBRA || *cc == OP_SCBRA ? IMM2_SIZE : 0);
- break;
-
case OP_CBRAPOS:
case OP_SCBRAPOS:
common->optimized_cbracket[GET2(cc, 1 + LINK_SIZE)] = 0;
@@ -2114,6 +2100,38 @@ DEFINE_COMPILER;
OP2(SLJIT_SUB, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, size * sizeof(sljit_sw));
}
+static sljit_uw * allocate_read_only_data(compiler_common *common, sljit_uw size)
+{
+DEFINE_COMPILER;
+sljit_uw *result;
+
+if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
+ return NULL;
+
+result = (sljit_uw *)SLJIT_MALLOC(size + sizeof(sljit_uw));
+if (SLJIT_UNLIKELY(result == NULL))
+ {
+ sljit_set_compiler_memory_error(compiler);
+ return NULL;
+ }
+
+*(void**)result = common->read_only_data_head;
+common->read_only_data_head = (void *)result;
+return result + 1;
+}
+
+static void free_read_only_data(void *current)
+{
+void *next;
+
+while (current != NULL)
+ {
+ next = *(void**)current;
+ SLJIT_FREE(current);
+ current = next;
+ }
+}
+
static SLJIT_INLINE void reset_ovector(compiler_common *common, int length)
{
DEFINE_COMPILER;
@@ -3530,9 +3548,6 @@ int range_right = -1, range_len = 3 - 1;
sljit_ub *update_table = NULL;
BOOL in_range;
-/* This is even TRUE, if both are NULL. */
-SLJIT_ASSERT(common->read_only_data_ptr == common->read_only_data);
-
for (i = 0; i < MAX_N_CHARS; i++)
{
chars[i << 1] = NOTACHAR;
@@ -3581,18 +3596,9 @@ for (i = 0; i <= max; i++)
if (range_right >= 0)
{
- /* Since no data is consumed (see the assert in the beginning
- of this function), this space can be reallocated. */
- if (common->read_only_data)
- SLJIT_FREE(common->read_only_data);
-
- common->read_only_data_size += 256;
- common->read_only_data = (sljit_uw *)SLJIT_MALLOC(common->read_only_data_size);
- if (common->read_only_data == NULL)
+ update_table = (sljit_ub *)allocate_read_only_data(common, 256);
+ if (update_table == NULL)
return TRUE;
-
- update_table = (sljit_ub *)common->read_only_data;
- common->read_only_data_ptr = (sljit_uw *)(update_table + 256);
memset(update_table, IN_UCHARS(range_len), 256);
for (i = 0; i < range_len; i++)
@@ -8982,8 +8988,9 @@ else if (has_alternatives)
if (alt_max > 4)
{
/* Table jump if alt_max is greater than 4. */
- next_update_addr = common->read_only_data_ptr;
- common->read_only_data_ptr += alt_max;
+ next_update_addr = allocate_read_only_data(common, alt_max * sizeof(sljit_uw));
+ if (SLJIT_UNLIKELY(next_update_addr == NULL))
+ return;
sljit_emit_ijump(compiler, SLJIT_JUMP, SLJIT_MEM1(TMP1), (sljit_sw)next_update_addr);
add_label_addr(common, next_update_addr++);
}
@@ -9766,9 +9773,7 @@ memset(common, 0, sizeof(compiler_common));
rootbacktrack.cc = (pcre_uchar *)re + re->name_table_offset + re->name_count * re->name_entry_size;
common->start = rootbacktrack.cc;
-common->read_only_data = NULL;
-common->read_only_data_size = 0;
-common->read_only_data_ptr = NULL;
+common->read_only_data_head = NULL;
common->fcc = tables + fcc_offset;
common->lcc = (sljit_sw)(tables + lcc_offset);
common->mode = mode;
@@ -9951,25 +9956,11 @@ if (common->has_then)
set_then_offsets(common, common->start, NULL);
}
-if (common->read_only_data_size > 0)
- {
- common->read_only_data = (sljit_uw *)SLJIT_MALLOC(common->read_only_data_size);
- if (common->read_only_data == NULL)
- {
- SLJIT_FREE(common->optimized_cbracket);
- SLJIT_FREE(common->private_data_ptrs);
- return;
- }
- common->read_only_data_ptr = common->read_only_data;
- }
-
compiler = sljit_create_compiler();
if (!compiler)
{
SLJIT_FREE(common->optimized_cbracket);
SLJIT_FREE(common->private_data_ptrs);
- if (common->read_only_data)
- SLJIT_FREE(common->read_only_data);
return;
}
common->compiler = compiler;
@@ -10008,16 +9999,7 @@ if ((re->options & PCRE_ANCHORED) == 0)
if ((re->options & PCRE_NO_START_OPTIMIZE) == 0)
{
if (mode == JIT_COMPILE && fast_forward_first_n_chars(common, (re->options & PCRE_FIRSTLINE) != 0))
- {
- /* If read_only_data is reallocated, we might have an allocation failure. */
- if (common->read_only_data_size > 0 && common->read_only_data == NULL)
- {
- sljit_free_compiler(compiler);
- SLJIT_FREE(common->optimized_cbracket);
- SLJIT_FREE(common->private_data_ptrs);
- return;
- }
- }
+ ;
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)
@@ -10070,8 +10052,7 @@ if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
sljit_free_compiler(compiler);
SLJIT_FREE(common->optimized_cbracket);
SLJIT_FREE(common->private_data_ptrs);
- if (common->read_only_data)
- SLJIT_FREE(common->read_only_data);
+ free_read_only_data(common->read_only_data_head);
return;
}
@@ -10111,8 +10092,7 @@ if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
sljit_free_compiler(compiler);
SLJIT_FREE(common->optimized_cbracket);
SLJIT_FREE(common->private_data_ptrs);
- if (common->read_only_data)
- SLJIT_FREE(common->read_only_data);
+ free_read_only_data(common->read_only_data_head);
return;
}
@@ -10192,8 +10172,7 @@ while (common->currententry != NULL)
sljit_free_compiler(compiler);
SLJIT_FREE(common->optimized_cbracket);
SLJIT_FREE(common->private_data_ptrs);
- if (common->read_only_data)
- SLJIT_FREE(common->read_only_data);
+ free_read_only_data(common->read_only_data_head);
return;
}
flush_stubs(common);
@@ -10303,7 +10282,6 @@ if (common->getucd != NULL)
}
#endif
-SLJIT_ASSERT(common->read_only_data + (common->read_only_data_size >> SLJIT_WORD_SHIFT) == common->read_only_data_ptr);
SLJIT_FREE(common->optimized_cbracket);
SLJIT_FREE(common->private_data_ptrs);
@@ -10318,8 +10296,7 @@ while (label_addr != NULL)
sljit_free_compiler(compiler);
if (executable_func == NULL)
{
- if (common->read_only_data)
- SLJIT_FREE(common->read_only_data);
+ free_read_only_data(common->read_only_data_head);
return;
}
@@ -10343,8 +10320,7 @@ else
/* This case is highly unlikely since we just recently
freed a lot of memory. Not impossible though. */
sljit_free_code(executable_func);
- if (common->read_only_data)
- SLJIT_FREE(common->read_only_data);
+ free_read_only_data(common->read_only_data_head);
return;
}
memset(functions, 0, sizeof(executable_functions));
@@ -10355,7 +10331,7 @@ else
}
functions->executable_funcs[mode] = executable_func;
-functions->read_only_data[mode] = common->read_only_data;
+functions->read_only_data_heads[mode] = common->read_only_data_head;
functions->executable_sizes[mode] = executable_size;
}
@@ -10542,8 +10518,7 @@ for (i = 0; i < JIT_NUMBER_OF_COMPILE_MODES; i++)
{
if (functions->executable_funcs[i] != NULL)
sljit_free_code(functions->executable_funcs[i]);
- if (functions->read_only_data[i] != NULL)
- SLJIT_FREE(functions->read_only_data[i]);
+ free_read_only_data(functions->read_only_data_heads[i]);
}
SLJIT_FREE(functions);
}
diff --git a/sljit/sljitLir.h b/sljit/sljitLir.h
index 9718871..2e135e2 100644
--- a/sljit/sljitLir.h
+++ b/sljit/sljitLir.h
@@ -419,6 +419,12 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_free_compiler(struct sljit_compiler *compile
these checks increases the performance of the compiling process. */
static SLJIT_INLINE sljit_si sljit_get_compiler_error(struct sljit_compiler *compiler) { return compiler->error; }
+/* Sets the compiler error code to SLJIT_ERR_ALLOC_FAILED. After
+ the error code is set, the compiler behaves as if itself detected
+ an allocation failure. This can greatly simplify error management,
+ since only the compiler needs to be checked after compilation. */
+static SLJIT_INLINE void sljit_set_compiler_memory_error(struct sljit_compiler *compiler) { compiler->error = SLJIT_ERR_ALLOC_FAILED; }
+
/*
Allocate a small amount of memory. The size must be <= 64 bytes on 32 bit,
and <= 128 bytes on 64 bit architectures. The memory area is owned by the
diff --git a/sljit/sljitNativeARM_32.c b/sljit/sljitNativeARM_32.c
index 0998423..44b539c 100644
--- a/sljit/sljitNativeARM_32.c
+++ b/sljit/sljitNativeARM_32.c
@@ -315,11 +315,13 @@ struct future_patch {
sljit_si value;
};
-static SLJIT_INLINE sljit_si resolve_const_pool_index(struct future_patch **first_patch, sljit_uw cpool_current_index, sljit_uw *cpool_start_address, sljit_uw *buf_ptr)
+static sljit_si resolve_const_pool_index(struct sljit_compiler *compiler, struct future_patch **first_patch, sljit_uw cpool_current_index, sljit_uw *cpool_start_address, sljit_uw *buf_ptr)
{
sljit_si value;
struct future_patch *curr_patch, *prev_patch;
+ SLJIT_UNUSED_ARG(compiler);
+
/* Using the values generated by patch_pc_relative_loads. */
if (!*first_patch)
value = (sljit_si)cpool_start_address[cpool_current_index];
diff --git a/testdata/testinput12 b/testdata/testinput12
index 5d727af..d68551f 100644
--- a/testdata/testinput12
+++ b/testdata/testinput12
@@ -87,4 +87,12 @@ and a couple of things that are different with JIT. --/
/^12345678abcd/mS++
12345678abcd
+/-- Test pattern compilation --/
+
+/(?:a|b|c|d|e)(?R)/S++
+
+/(?:a|b|c|d|e)(?R)(?R)/S++
+
+/(a(?:a|b|c|d|e)b){8,16}/S++
+
/-- End of testinput12 --/
diff --git a/testdata/testoutput12 b/testdata/testoutput12
index 67ad2c8..7a1cf69 100644
--- a/testdata/testoutput12
+++ b/testdata/testoutput12
@@ -176,4 +176,12 @@ No match, mark = m (JIT)
12345678abcd
0: 12345678abcd (JIT)
+/-- Test pattern compilation --/
+
+/(?:a|b|c|d|e)(?R)/S++
+
+/(?:a|b|c|d|e)(?R)(?R)/S++
+
+/(a(?:a|b|c|d|e)b){8,16}/S++
+
/-- End of testinput12 --/
--
2.1.0

View File

@ -1,11 +1,28 @@
# This is stable release:
#%%global rcversion RC1
# Is this a stable/testing release:
%global rcversion RC1
Name: pcre
Version: 8.36
Release: %{?rcversion:0.}5%{?rcversion:.%rcversion}%{?dist}
Version: 8.37
Release: %{?rcversion:0.}1%{?rcversion:.%rcversion}%{?dist}
%global myversion %{version}%{?rcversion:-%rcversion}
Summary: Perl-compatible regular expression library
Group: System Environment/Libraries
## Source package only:
# ltmain.sh: (GPLv2+ or BSD) and GPLv3+
# missing: GPLv2+ or BSD
# compile: GPLv2+ or BSD
# config.sub: GPLv3+ or BSD
# m4/ax_pthread.m4: GPLv3+ with exception
# m4/libtool.m4: GPLv2+ or BSD
# m4/ltversion.m4: FSFULLR
# m4/pcre_visibility.m4: FSFULLR
# m4/lt~obsolete.m4: FSFULLR
# m4/ltsugar.m4: FSFULLR
# m4/ltoptions.m4: FSFULLR
# aclocal.m4: (GPLv2+ or BSD) and FSFULLR
# Makefile.in: FSFULLR
# configure: FSFUL
## Binary packages:
# other files: BSD
License: BSD
URL: http://www.pcre.org/
Source: ftp://ftp.csx.cam.ac.uk/pub/software/programming/%{name}/%{?rcversion:Testing/}%{name}-%{myversion}.tar.bz2
@ -13,36 +30,6 @@ Source: ftp://ftp.csx.cam.ac.uk/pub/software/programming/%{name}/%{?rcversion:Te
Patch0: pcre-8.21-multilib.patch
# Refused by upstream, bug #675477
Patch1: pcre-8.32-refused_spelling_terminated.patch
# Reset non-matched groups within capturing group up to forced match,
# bug #1161587, in upstream after 8.36
Patch2: pcre-8.36-Fix-bug-when-there-are-unset-groups-prior-to-ACCEPT-.patch
# Fix unused memory usage on zero-repeat assertion condition, bug #1165626,
# CVE-2014-8964, in upstream after 8.36
Patch3: pcre-8.36-Fix-zero-repeat-assertion-condition-bug.patch
# Fix computing size of JIT read-only data, bug #1206131, upstream bug #1597,
# in upstream after 8.36
Patch4: pcre-8.36-Remove-computing-the-JIT-read-only-data-size-in-adva.patch
# Fix computing size for pattern with a negated special calss in on-UCP mode,
# bug #1210383, in upstream after 8.36
Patch5: pcre-8.36-Fix-memory-bug-for-S-V-H-compile.patch
# Fix compilation of a pattern with mutual recursion nested inside other group,
# bug #1210393, in upstream after 8.36
Patch6: pcre-8.36-Fix-mutual-recursion-inside-other-groups-stack-overf.patch
# Fix compilation of a parenthesized comment, bug #1210410,
# in upstream after 8.36
Patch7: pcre-8.36-Fix-comment-between-subroutine-call-and-quantifier-b.patch
# Fix compliation of mutual recursion inside a lookbehind assertion,
# bug #1210417, in upstream after 8.36
Patch8: pcre-8.36-Fix-stack-overflow-instead-of-diagnostic-for-mutual-.patch
# Fix pcregrep loop when \K is used in a lookbehind assertion, bug #1210423,
# in upstream after 8.36
Patch9: pcre-8.36-Fix-pcregrep-loop-when-K-is-used-in-a-lookbehind-ass.patch
# Fix pcretest loop when \K is used in a lookbehind assertion, bug #1210423,
# in upstream after 8.36
Patch10: pcre-8.36-Fix-pcretest-loop-for-K-in-lookbehind-assertion.patch
# Fix backtracking for \C\X* in UTF-8 mode, bug #1210576,
# in upstream after 8.36
Patch11: pcre-8.36-Fix-backtracking-bug-for-C-X-in-UTF-mode.patch
BuildRequires: readline-devel
# New libtool to get rid of rpath
BuildRequires: autoconf, automake, libtool
@ -84,16 +71,6 @@ Utilities demonstrating PCRE capabilities like pcregrep or pcretest.
# Get rid of rpath
%patch0 -p1 -b .multilib
%patch1 -p1 -b .terminated_typos
%patch2 -p1 -b .reset_groups
%patch3 -p1 -b .zero_repeat_assertion
%patch4 -p1 -b .jit_size
%patch5 -p1 -b .size_special_class
%patch6 -p1 -b .mutual_recursion
%patch7 -p1 -b .parenthesized_comment
%patch8 -p1 -b .mutual_recursion_in_assertion
%patch9 -p1 -b .pcregrep_k_loop
%patch10 -p1 -b .pcretest_k_loop
%patch11 -p1 -b .backtracking_cx8
# Because of rpath patch
libtoolize --copy --force && autoreconf -vif
# One contributor's name is non-UTF-8
@ -109,7 +86,7 @@ done
%global optflags %{optflags} -fno-strict-aliasing
%endif
%configure \
%ifarch s390 s390x sparc64 sparcv9
%ifarch aarch64 s390 s390x sparc64 sparcv9
--disable-jit \
%else
--enable-jit \
@ -164,6 +141,9 @@ make %{?_smp_mflags} check VERBOSE=yes
%{_mandir}/man1/pcretest.*
%changelog
* Wed Apr 22 2015 Petr Pisar <ppisar@redhat.com> - 8.37-0.1.RC1
- 8.37 RC1 bump
* Thu Apr 09 2015 Petr Pisar <ppisar@redhat.com> - 8.36-5
- Fix computing size for pattern with a negated special calss in on-UCP mode
(bug #1210383)

View File

@ -1 +1 @@
b767bc9af0c20bc9c1fe403b0d41ad97 pcre-8.36.tar.bz2
5abcd103968ef38d9911bbfb494cbc73 pcre-8.37-RC1.tar.bz2