94 lines
2.5 KiB
Diff
94 lines
2.5 KiB
Diff
From 3da5528b47b88c32224cf9d14d8a4e80cd7a0815 Mon Sep 17 00:00:00 2001
|
|
From: ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>
|
|
Date: Sat, 6 Feb 2016 16:54:14 +0000
|
|
Subject: [PATCH] Fix pcretest bad behaviour for callout in lookbehind.
|
|
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@1625 2f5784b3-3f2a-0410-8824-cb99058d5e15
|
|
|
|
Petr Písař: Ported to 8.38.
|
|
|
|
diff --git a/pcretest.c b/pcretest.c
|
|
index 488e419..63869fd 100644
|
|
--- a/pcretest.c
|
|
+++ b/pcretest.c
|
|
@@ -2250,7 +2250,7 @@ data is not zero. */
|
|
static int callout(pcre_callout_block *cb)
|
|
{
|
|
FILE *f = (first_callout | callout_extra)? outfile : NULL;
|
|
-int i, pre_start, post_start, subject_length;
|
|
+int i, current_position, pre_start, post_start, subject_length;
|
|
|
|
if (callout_extra)
|
|
{
|
|
@@ -2280,14 +2280,19 @@ printed lengths of the substrings. */
|
|
|
|
if (f != NULL) fprintf(f, "--->");
|
|
|
|
+/* If a lookbehind is involved, the current position may be earlier than the
|
|
+match start. If so, use the match start instead. */
|
|
+
|
|
+current_position = (cb->current_position >= cb->start_match)?
|
|
+ cb->current_position : cb->start_match;
|
|
+
|
|
PCHARS(pre_start, cb->subject, 0, cb->start_match, f);
|
|
PCHARS(post_start, cb->subject, cb->start_match,
|
|
- cb->current_position - cb->start_match, f);
|
|
+ current_position - cb->start_match, f);
|
|
|
|
PCHARS(subject_length, cb->subject, 0, cb->subject_length, NULL);
|
|
|
|
-PCHARSV(cb->subject, cb->current_position,
|
|
- cb->subject_length - cb->current_position, f);
|
|
+PCHARSV(cb->subject, current_position, cb->subject_length - current_position, f);
|
|
|
|
if (f != NULL) fprintf(f, "\n");
|
|
|
|
@@ -5740,3 +5745,4 @@ return yield;
|
|
}
|
|
|
|
/* End of pcretest.c */
|
|
+
|
|
diff --git a/testdata/testinput2 b/testdata/testinput2
|
|
index 967a241..086e0f4 100644
|
|
--- a/testdata/testinput2
|
|
+++ b/testdata/testinput2
|
|
@@ -4235,4 +4235,8 @@ backtracking verbs. --/
|
|
/(?=a\K)/
|
|
ring bpattingbobnd $ 1,oern cou \rb\L
|
|
|
|
+/(?<=((?C)0))/
|
|
+ 9010
|
|
+ abcd
|
|
+
|
|
/-- End of testinput2 --/
|
|
diff --git a/testdata/testoutput2 b/testdata/testoutput2
|
|
index 5fb28d5..d414a72 100644
|
|
--- a/testdata/testoutput2
|
|
+++ b/testdata/testoutput2
|
|
@@ -14650,4 +14650,19 @@ Start of matched string is beyond its end - displaying from end to start.
|
|
0: a
|
|
0L
|
|
|
|
+/(?<=((?C)0))/
|
|
+ 9010
|
|
+--->9010
|
|
+ 0 ^ 0
|
|
+ 0 ^ 0
|
|
+ 0:
|
|
+ 1: 0
|
|
+ abcd
|
|
+--->abcd
|
|
+ 0 ^ 0
|
|
+ 0 ^ 0
|
|
+ 0 ^ 0
|
|
+ 0 ^ 0
|
|
+No match
|
|
+
|
|
/-- End of testinput2 --/
|
|
--
|
|
2.5.0
|
|
|