summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2007-11-16 16:22:24 +0000
committerph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2007-11-16 16:22:24 +0000
commit0d089a4646853f3c4d3fa08ccbb555684a9ccd0c (patch)
tree4df0cc4b05585bf0b0f7aeed5320ca9833e0bc73
parent0262eef3593e8a8a9d0c918a5f4a72ed67742d5f (diff)
downloadpcre-0d089a4646853f3c4d3fa08ccbb555684a9ccd0c.tar.gz
Improve error messages for (?+-a) and (?-+a).
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@269 2f5784b3-3f2a-0410-8824-cb99058d5e15
-rw-r--r--ChangeLog4
-rw-r--r--pcre_compile.c15
-rw-r--r--pcre_internal.h2
-rw-r--r--pcreposix.c3
-rw-r--r--testdata/testinput24
-rw-r--r--testdata/testoutput220
6 files changed, 36 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 7ca7f72..7e3fbf9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -22,6 +22,10 @@ Version 7.5 12-Nov-07
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).
+
+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
+ digits. I have, however, made the messages clearer.
Version 7.4 21-Sep-07
diff --git a/pcre_compile.c b/pcre_compile.c
index d160e1d..0d579db 100644
--- a/pcre_compile.c
+++ b/pcre_compile.c
@@ -241,7 +241,7 @@ static const char error_texts[] =
/* 10 */
"operand of unlimited repeat could match the empty string\0" /** DEAD **/
"internal error: unexpected repeat\0"
- "unrecognized character after (?\0"
+ "unrecognized character after (? or (?-\0"
"POSIX named classes are supported only within a class\0"
"missing )\0"
/* 15 */
@@ -301,7 +301,8 @@ static const char error_texts[] =
/* 60 */
"(*VERB) not recognized\0"
"number is too big\0"
- "subpattern name expected after (?&";
+ "subpattern name expected after (?&\0"
+ "digit expected after (?+";
/* Table to identify digits and hex digits. This is used when compiling
@@ -4603,7 +4604,15 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
{
const uschar *called;
- if ((refsign = *ptr) == '+') ptr++;
+ if ((refsign = *ptr) == '+')
+ {
+ ptr++;
+ if ((digitab[*ptr] & ctype_digit) == 0)
+ {
+ *errorcodeptr = ERR63;
+ goto FAILED;
+ }
+ }
else if (refsign == '-')
{
if ((digitab[ptr[1]] & ctype_digit) == 0)
diff --git a/pcre_internal.h b/pcre_internal.h
index ca8749a..7ffae2f 100644
--- a/pcre_internal.h
+++ b/pcre_internal.h
@@ -871,7 +871,7 @@ enum { ERR0, ERR1, ERR2, ERR3, ERR4, ERR5, ERR6, ERR7, ERR8, ERR9,
ERR30, ERR31, ERR32, ERR33, ERR34, ERR35, ERR36, ERR37, ERR38, ERR39,
ERR40, ERR41, ERR42, ERR43, ERR44, ERR45, ERR46, ERR47, ERR48, ERR49,
ERR50, ERR51, ERR52, ERR53, ERR54, ERR55, ERR56, ERR57, ERR58, ERR59,
- ERR60, ERR61, ERR62 };
+ ERR60, ERR61, ERR62, ERR63 };
/* The real format of the start of the pcre block; the index of names and the
code vector run on as long as necessary after the end. We store an explicit
diff --git a/pcreposix.c b/pcreposix.c
index 545fbf9..1ddf6ae 100644
--- a/pcreposix.c
+++ b/pcreposix.c
@@ -125,7 +125,8 @@ 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 after (?& */
+ REG_BADPAT /* digit expected after (?+ */
};
/* Table of texts corresponding to POSIX error codes */
diff --git a/testdata/testinput2 b/testdata/testinput2
index 572bcf3..2a180e3 100644
--- a/testdata/testinput2
+++ b/testdata/testinput2
@@ -2541,4 +2541,8 @@ a random value. /Ix
/(?<a>)(?&aaaaaaaaaaaaaaaaaaaaaaa)/
+/(?+-a)/
+
+/(?-+a)/
+
/ End of testinput2 /
diff --git a/testdata/testoutput2 b/testdata/testoutput2
index 6648221..85d931a 100644
--- a/testdata/testoutput2
+++ b/testdata/testoutput2
@@ -109,7 +109,7 @@ Failed: missing ) at offset 4
Failed: missing ) after comment at offset 7
/(?z)abc/
-Failed: unrecognized character after (? at offset 2
+Failed: unrecognized character after (? or (?- at offset 2
/.*b/I
Capturing subpattern count = 0
@@ -310,7 +310,7 @@ No match
No match
/ab(?z)cd/
-Failed: unrecognized character after (? at offset 4
+Failed: unrecognized character after (? or (?- at offset 4
/^abc|def/I
Capturing subpattern count = 0
@@ -946,19 +946,19 @@ Failed: missing ) at offset 4
Failed: unrecognized character after (?< at offset 3
/a(?{)b/
-Failed: unrecognized character after (? at offset 3
+Failed: unrecognized character after (? or (?- at offset 3
/a(?{{})b/
-Failed: unrecognized character after (? at offset 3
+Failed: unrecognized character after (? or (?- at offset 3
/a(?{}})b/
-Failed: unrecognized character after (? at offset 3
+Failed: unrecognized character after (? or (?- at offset 3
/a(?{"{"})b/
-Failed: unrecognized character after (? at offset 3
+Failed: unrecognized character after (? or (?- at offset 3
/a(?{"{"}})b/
-Failed: unrecognized character after (? at offset 3
+Failed: unrecognized character after (? or (?- at offset 3
/(?(1?)a|b)/
Failed: malformed number or name after (?( at offset 4
@@ -9311,4 +9311,10 @@ Failed: reference to non-existent subpattern at offset 12
/(?<a>)(?&aaaaaaaaaaaaaaaaaaaaaaa)/
Failed: reference to non-existent subpattern at offset 32
+/(?+-a)/
+Failed: digit expected after (?+ at offset 3
+
+/(?-+a)/
+Failed: unrecognized character after (? or (?- at offset 3
+
/ End of testinput2 /