[Pcre-svn] [661] code/trunk: Fix bug introduced by 8.13/ 37 …

トップ ページ
このメッセージを削除
著者: Subversion repository
日付:  
To: pcre-svn
題目: [Pcre-svn] [661] code/trunk: Fix bug introduced by 8.13/ 37 concerning POSIX class recognition
Revision: 661
          http://vcs.pcre.org/viewvc?view=rev&revision=661
Author:   ph10
Date:     2011-08-21 10:00:54 +0100 (Sun, 21 Aug 2011)


Log Message:
-----------
Fix bug introduced by 8.13/37 concerning POSIX class recognition

Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/pcre_compile.c


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2011-08-16 09:50:57 UTC (rev 660)
+++ code/trunk/ChangeLog    2011-08-21 09:00:54 UTC (rev 661)
@@ -1,6 +1,15 @@
 ChangeLog for PCRE
 ------------------


+Version 8.20
+------------
+
+1. Change 37 of 8.13 broke patterns like [:a]...[b:] because it thought it had
+a POSIX class. After further experiments with Perl, which convinced me that
+Perl has bugs and confusions, a closing square bracket is no longer allowed in
+a POSIX name.
+
+
Version 8.13 16-Aug-2011
------------------------

@@ -189,7 +198,7 @@
     For example, [:a[:digit:]b:] matches "a", "b", ":", or a digit. Also,
     unescaped square brackets may also appear as part of class names. For
     example, [:a[:abc]b:] gives unknown class "[:abc]b:]". PCRE now behaves
-    more like Perl.
+    more like Perl. (But see 8.20/1 above.)


 38. PCRE was giving an error for \N with a braced quantifier such as {1,} (this
     was because it thought it was \N{name}, which is not supported).


Modified: code/trunk/pcre_compile.c
===================================================================
--- code/trunk/pcre_compile.c    2011-08-16 09:50:57 UTC (rev 660)
+++ code/trunk/pcre_compile.c    2011-08-21 09:00:54 UTC (rev 661)
@@ -2295,9 +2295,14 @@
 A user pointed out that PCRE was rejecting [:a[:digit:]] whereas Perl was not.
 It seems that the appearance of a nested POSIX class supersedes an apparent
 external class. For example, [:a[:digit:]b:] matches "a", "b", ":", or
-a digit. Also, unescaped square brackets may also appear as part of class
-names. For example, [:a[:abc]b:] gives unknown class "[:abc]b:]"in Perl.
+a digit. 


+In Perl, unescaped square brackets may also appear as part of class names. For
+example, [:a[:abc]b:] gives unknown POSIX class "[:abc]b:]". However, for
+[:a[:abc]b][b:] it gives unknown POSIX class "[:abc]b][b:]", which does not
+seem right at all. PCRE does not allow closing square brackets in POSIX class 
+names.
+
 Arguments:
   ptr      pointer to the initial [
   endptr   where to return the end pointer
@@ -2314,6 +2319,7 @@
   {
   if (*ptr == CHAR_BACKSLASH && ptr[1] == CHAR_RIGHT_SQUARE_BRACKET)
     ptr++;
+  else if (*ptr == CHAR_RIGHT_SQUARE_BRACKET) return FALSE;   
   else
     {
     if (*ptr == terminator && ptr[1] == CHAR_RIGHT_SQUARE_BRACKET)