PATCH: [perl #114220] /\h/ not equiv to /[\h]/
authorKarl Williamson <public@khwilliamson.com>
Sat, 21 Jul 2012 18:12:33 +0000 (12:12 -0600)
committerRicardo Signes <rjbs@cpan.org>
Thu, 11 Oct 2012 18:32:23 +0000 (14:32 -0400)
\h matches the No-Break space even under /d.  It is the only
(non-complemented) Posix-like character class that has matches under /d
in the Latin1 range above ASCII.  A special case is made for it, and \H
to make sure they have the correct code points.

regcomp.c
t/re/re_tests

index 143f349..2254159 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -10885,6 +10885,7 @@ parseit:
                 * A similar issue a little earlier when switching on value.
                 * --jhi */
                switch ((I32)namedclass) {
+                   int i;  /* loop counter */
 
                case ANYOF_ALNUMC: /* C's alnum, in contrast to \w */
                    DO_POSIX_LATIN1_ONLY_KNOWN(ret, namedclass, properties,
@@ -10957,16 +10958,32 @@ parseit:
                         PL_PosixGraph, PL_L1PosixGraph, "XPosixGraph", listsv);
                    break;
                case ANYOF_HORIZWS:
-                   /* For these, we use the nonbitmap, as /d doesn't make a
-                    * difference in what these match.  There would be problems
-                    * if these characters had folds other than themselves, as
-                    * nonbitmap is subject to folding.  It turns out that \h
-                    * is just a synonym for XPosixBlank */
+                   /* NBSP matches this, and needs to be added unconditionally
+                    * to the bit map as it matches even under /d, unlike all
+                    * the rest of the Posix-like classes (\v doesn't have any
+                    * matches in the Latin1 range, so it is unaffected.) which
+                    * Otherwise, we use the nonbitmap, as /d doesn't make a
+                    * difference in what these match.  It turns out that \h is
+                    * just a synonym for XPosixBlank */
                    _invlist_union(nonbitmap, PL_XPosixBlank, &nonbitmap);
+                   stored += set_regclass_bit(pRExC_state, ret,
+                                              UNI_TO_NATIVE(0xA0),
+                                              &l1_fold_invlist,
+                                              &unicode_alternate);
+
                    break;
                case ANYOF_NHORIZWS:
                     _invlist_union_complement_2nd(nonbitmap,
                                                  PL_XPosixBlank, &nonbitmap);
+                   for (i = 128; i < 256; i++) {
+                       if (i == 0xA0) {
+                           continue;
+                       }
+                       stored += set_regclass_bit(pRExC_state, ret,
+                                                  UNI_TO_NATIVE(i),
+                                                  &l1_fold_invlist,
+                                                  &unicode_alternate);
+                   }
                    break;
                case ANYOF_LOWER:
                case ANYOF_NLOWER:
index 4d78a6a..cfc813f 100644 (file)
@@ -1595,6 +1595,11 @@ abc\N{def        -       c       -       \\N{NAME} must be resolved by the lexer
 /[[:word:]]/   \x{2c1} y       -       -
 /[[:word:]]/   \x{2c2} n       -       -
 
+# [perl #114220]
+/[\h]/ \x{A0}  y       $&      \xA0
+/[\H]/ \x{BF}  y       $&      \xBF
+/[\H]/ \x{A0}  n       -       -
+/[\H]/ \x{A1}  y       $&      \xA1
 
 
 # vim: softtabstop=0 noexpandtab