[Pcre-svn] [1481] code/trunk: Give error for \x{} and \o{}.

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [1481] code/trunk: Give error for \x{} and \o{}.
Revision: 1481
          http://vcs.pcre.org/viewvc?view=rev&revision=1481
Author:   ph10
Date:     2014-05-27 19:24:42 +0100 (Tue, 27 May 2014)


Log Message:
-----------
Give error for \x{} and \o{}.

Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/pcre_compile.c
    code/trunk/pcre_internal.h
    code/trunk/pcreposix.c
    code/trunk/testdata/testinput2
    code/trunk/testdata/testoutput2


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2014-05-27 18:02:51 UTC (rev 1480)
+++ code/trunk/ChangeLog    2014-05-27 18:24:42 UTC (rev 1481)
@@ -43,6 +43,9 @@


 8.  Fixed a bug that was incorrectly auto-possessifying \w+ in the pattern
     ^\w+(?>\s*)(?<=\w) which caused it not to match "test test". 
+    
+9.  Give a compile-time error for \o{} (as Perl does) and for \x{} (which Perl 
+    doesn't). 



Version 8.35 04-April-2014

Modified: code/trunk/pcre_compile.c
===================================================================
--- code/trunk/pcre_compile.c    2014-05-27 18:02:51 UTC (rev 1480)
+++ code/trunk/pcre_compile.c    2014-05-27 18:24:42 UTC (rev 1481)
@@ -549,6 +549,7 @@
   "group name must start with a non-digit\0"
   /* 85 */
   "parentheses are too deeply nested (stack check)\0"
+  "digits missing in \\x{} or \\o{}\0" 
   ;


/* Table to identify digits and hex digits. This is used when compiling
@@ -1259,6 +1260,7 @@

     case CHAR_o:
     if (ptr[1] != CHAR_LEFT_CURLY_BRACKET) *errorcodeptr = ERR81; else
+    if (ptr[2] == CHAR_RIGHT_CURLY_BRACKET) *errorcodeptr = ERR86; else 
       {
       ptr += 2;
       c = 0;
@@ -1328,6 +1330,11 @@
       if (ptr[1] == CHAR_LEFT_CURLY_BRACKET)
         {
         ptr += 2;
+        if (*ptr == CHAR_RIGHT_CURLY_BRACKET)
+          {
+          *errorcodeptr = ERR86;
+          break;
+          }    
         c = 0;
         overflow = FALSE;
         while (MAX_255(*ptr) && (digitab[*ptr] & ctype_xdigit) != 0)


Modified: code/trunk/pcre_internal.h
===================================================================
--- code/trunk/pcre_internal.h    2014-05-27 18:02:51 UTC (rev 1480)
+++ code/trunk/pcre_internal.h    2014-05-27 18:24:42 UTC (rev 1481)
@@ -2281,7 +2281,7 @@
        ERR50, ERR51, ERR52, ERR53, ERR54, ERR55, ERR56, ERR57, ERR58, ERR59,
        ERR60, ERR61, ERR62, ERR63, ERR64, ERR65, ERR66, ERR67, ERR68, ERR69,
        ERR70, ERR71, ERR72, ERR73, ERR74, ERR75, ERR76, ERR77, ERR78, ERR79,
-       ERR80, ERR81, ERR82, ERR83, ERR84, ERR85, ERRCOUNT };
+       ERR80, ERR81, ERR82, ERR83, ERR84, ERR85, ERR86, ERRCOUNT };


/* JIT compiling modes. The function list is indexed by them. */


Modified: code/trunk/pcreposix.c
===================================================================
--- code/trunk/pcreposix.c    2014-05-27 18:02:51 UTC (rev 1480)
+++ code/trunk/pcreposix.c    2014-05-27 18:24:42 UTC (rev 1481)
@@ -172,7 +172,8 @@
   REG_BADPAT,  /* invalid range in character class */
   REG_BADPAT,  /* group name must start with a non-digit */
   /* 85 */
-  REG_BADPAT   /* parentheses too deeply nested (stack check) */
+  REG_BADPAT,  /* parentheses too deeply nested (stack check) */
+  REG_BADPAT   /* missing digits in \x{} or \o{} */ 
 };


/* Table of texts corresponding to POSIX error codes */

Modified: code/trunk/testdata/testinput2
===================================================================
--- code/trunk/testdata/testinput2    2014-05-27 18:02:51 UTC (rev 1480)
+++ code/trunk/testdata/testinput2    2014-05-27 18:24:42 UTC (rev 1481)
@@ -4064,4 +4064,16 @@


/^\w+(?>\s*)(?<=\w)/BZ

+/\othing/
+
+/\o{}/
+
+/\o{whatever}/
+
+/\xthing/
+
+/\x{}/
+
+/\x{whatever}/
+
/-- End of testinput2 --/

Modified: code/trunk/testdata/testoutput2
===================================================================
--- code/trunk/testdata/testoutput2    2014-05-27 18:02:51 UTC (rev 1480)
+++ code/trunk/testdata/testoutput2    2014-05-27 18:24:42 UTC (rev 1481)
@@ -14165,4 +14165,21 @@
         End
 ------------------------------------------------------------------


+/\othing/
+Failed: missing opening brace after \o at offset 1
+
+/\o{}/
+Failed: digits missing in \x{} or \o{} at offset 1
+
+/\o{whatever}/
+Failed: non-octal character in \o{} (closing brace missing?) at offset 3
+
+/\xthing/
+
+/\x{}/
+Failed: digits missing in \x{} or \o{} at offset 3
+
+/\x{whatever}/
+Failed: non-hex character in \x{} (closing brace missing?) at offset 3
+
/-- End of testinput2 --/