summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2007-11-17 16:53:53 +0000
committerph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2007-11-17 16:53:53 +0000
commit0e5661b91ca6b911345a010516d404eb658cd516 (patch)
tree5af8105532a6f813d0b356ca9941477e43eaf341
parent9b74a6dd7d56bbff011d81bac8716b209560a022 (diff)
downloadpcre-0e5661b91ca6b911345a010516d404eb658cd516.tar.gz
Generalize wording for (?&) error as it also applies to \k'' and other cases.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@272 2f5784b3-3f2a-0410-8824-cb99058d5e15
-rw-r--r--ChangeLog5
-rw-r--r--pcre_compile.c6
-rw-r--r--pcreposix.c2
-rw-r--r--testdata/testinput210
-rw-r--r--testdata/testoutput217
5 files changed, 35 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index bb67f68..eba06b2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -21,7 +21,10 @@ Version 7.5 12-Nov-07
5. The construct (?&) was not diagnosed as a syntax error (it referenced the
first named subpattern) and a construct such as (?&a) would reference the
first named subpattern whose name started with "a" (in other words, the
- length check was missing).
+ length check was missing). Both these problems are fixed. "Subpattern name
+ expected" is now given for (?&) (a zero-length name), and this patch also
+ makes it give the same error for \k'' (previously it complained that that
+ was a reference to a non-existent subpattern).
6. The erroneous patterns (?+-a) and (?-+a) give different error messages;
this is right because (?- can be followed by option settings as well as by
diff --git a/pcre_compile.c b/pcre_compile.c
index 21b1a8b..937853e 100644
--- a/pcre_compile.c
+++ b/pcre_compile.c
@@ -301,7 +301,7 @@ static const char error_texts[] =
/* 60 */
"(*VERB) not recognized\0"
"number is too big\0"
- "subpattern name expected after (?&\0"
+ "subpattern name expected\0"
"digit expected after (?+";
@@ -4523,7 +4523,9 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
/* We come here from the Python syntax above that handles both
references (?P=name) and recursion (?P>name), as well as falling
- through from the Perl recursion syntax (?&name). */
+ through from the Perl recursion syntax (?&name). We also come here from
+ the Perl \k<name> or \k'name' back reference syntax and the \k{name}
+ .NET syntax. */
NAMED_REF_OR_RECURSE:
name = ++ptr;
diff --git a/pcreposix.c b/pcreposix.c
index 1ddf6ae..7e2798e 100644
--- a/pcreposix.c
+++ b/pcreposix.c
@@ -125,7 +125,7 @@ static const int eint[] = {
REG_BADPAT, /* \g is not followed followed by an (optionally braced) non-zero number */
REG_BADPAT, /* (?+ or (?- must be followed by a non-zero number */
REG_BADPAT, /* number is too big */
- REG_BADPAT, /* subpattern name expected after (?& */
+ REG_BADPAT, /* subpattern name expected */
REG_BADPAT /* digit expected after (?+ */
};
diff --git a/testdata/testinput2 b/testdata/testinput2
index 828fe45..9b153dc 100644
--- a/testdata/testinput2
+++ b/testdata/testinput2
@@ -2553,4 +2553,14 @@ a random value. /Ix
/(?(2))()()/
+/\k''/
+
+/\k<>/
+
+/\k{}/
+
+/(?P=)/
+
+/(?P>)/
+
/ End of testinput2 /
diff --git a/testdata/testoutput2 b/testdata/testoutput2
index 5cd103a..c7ae26f 100644
--- a/testdata/testoutput2
+++ b/testdata/testoutput2
@@ -9304,7 +9304,7 @@ First char = 'a'
Need char = 'b'
/(?<a>)(?&)/
-Failed: subpattern name expected after (?& at offset 9
+Failed: subpattern name expected at offset 9
/(?<abc>)(?&a)/
Failed: reference to non-existent subpattern at offset 12
@@ -9331,4 +9331,19 @@ Failed: reference to non-existent subpattern at offset 6
/(?(2))()()/
+/\k''/
+Failed: subpattern name expected at offset 3
+
+/\k<>/
+Failed: subpattern name expected at offset 3
+
+/\k{}/
+Failed: subpattern name expected at offset 3
+
+/(?P=)/
+Failed: subpattern name expected at offset 4
+
+/(?P>)/
+Failed: subpattern name expected at offset 4
+
/ End of testinput2 /