From: Jarkko Hietaniemi Date: Fri, 3 Mar 2000 02:09:45 +0000 (+0000) Subject: /[[:alpha]/ now dies on unmatched [] instead of X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ac561586bbd0bfbbfcc37c0f7e0dbc30423d438f;p=p5sagit%2Fp5-mst-13.2.git /[[:alpha]/ now dies on unmatched [] instead of "an unknown character class" (spotted by Tom Christiansen) p4raw-id: //depot/cfgperl@5465 --- diff --git a/regcomp.c b/regcomp.c index 271c20c..7c6b761 100644 --- a/regcomp.c +++ b/regcomp.c @@ -2820,12 +2820,12 @@ S_regpposixcc(pTHX_ I32 value) } break; } - if ((namedclass == OOB_NAMEDCLASS || - !(posixcc + skip + 2 < PL_regxend && - (posixcc[skip] == ':' && - posixcc[skip + 1] == ']')))) - Perl_croak(aTHX_ "Character class [:%.*s:] unknown", - t - s - 1, s + 1); + if (namedclass == OOB_NAMEDCLASS || + posixcc[skip] != ':' || + posixcc[skip+1] != ']') + Perl_croak(aTHX_ + "Character class [:%.*s:] unknown", + t - s - 1, s + 1); } else if (ckWARN(WARN_REGEXP) && !SIZE_ONLY) /* [[=foo=]] and [[.foo.]] are still future. */ Perl_warner(aTHX_ WARN_REGEXP, diff --git a/t/pragma/warn/regcomp b/t/pragma/warn/regcomp index 7d485f2..5de01c6 100644 --- a/t/pragma/warn/regcomp +++ b/t/pragma/warn/regcomp @@ -6,9 +6,11 @@ %.*s matches null string many times [S_regpiece] $a = "ABC123" ; $a =~ /(?=a)*/' - /%.127s/: Unrecognized escape \\%c passed through" [S_regatom] + /%.127s/: Unrecognized escape \\%c passed through [S_regatom] $x = '\m' ; /$x/ + Character class [:%.*s:] unknown [S_regpposixcc] + Character class syntax [. .] is reserved for future extensions [S_regpposixcc] Character class syntax [= =] is reserved for future extensions [S_checkposixcc] @@ -61,6 +63,7 @@ $_ = "" ; /[[.foo.]]/; /[[=bar=]]/; /[:zog:]/; +/[[:zog:]]/; no warnings 'regexp' ; /[:alpha:]/; /[.foo.]/; @@ -68,9 +71,9 @@ no warnings 'regexp' ; /[[:alpha:]]/; /[[.foo.]]/; /[[=bar=]]/; -/[:zog:]/; BEGIN { $ENV{PERL_DESTRUCT_LEVEL} = 0 unless $ENV{PERL_DESTRUCT_LEVEL} > 3 } /[[:zog:]]/; +/[:zog:]/; EXPECT Character class syntax [: :] belongs inside character classes at - line 4. Character class syntax [. .] belongs inside character classes at - line 5. @@ -80,7 +83,7 @@ Character class syntax [= =] is reserved for future extensions at - line 6. Character class syntax [. .] is reserved for future extensions at - line 8. Character class syntax [= =] is reserved for future extensions at - line 9. Character class syntax [: :] belongs inside character classes at - line 10. -Character class [:zog:] unknown at - line 20. +Character class [:zog:] unknown at - line 11. ######## # regcomp.c [S_regclass] $_ = "";