From: Jeffrey Friedl Date: Sun, 16 Jul 2000 17:55:29 +0000 (-0700) Subject: Make the unimplemented POSIX regex features [[.cc.]] and [[=c=]] X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3802429d267c8d589218258636c61462cb33dd22;p=p5sagit%2Fp5-mst-13.2.git Make the unimplemented POSIX regex features [[.cc.]] and [[=c=]] to be fatal errors (instead of by default ignoring them, and ignoring with a bug: even though -w gave an error, the opening [ was left in) Reported in: Subject: [ID 20000716.024] [=cc=] / [:blank:] Message-Id: <200007170055.RAA23528@fummy.dsl.yahoo.com> p4raw-id: //depot/perl@6439 --- diff --git a/pod/perldiag.pod b/pod/perldiag.pod index a10f9df..baa088c 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -1031,23 +1031,23 @@ Perhaps you need to copy the value to a temporary, and repeat that. I character classes, the [] are part of the construct, for example: /[012[:alpha:]345]/. Note that [= =] and [. .] are not currently implemented; they are simply placeholders for future -extensions. +extensions and will cause fatal errors. =item Character class syntax [. .] is reserved for future extensions -(W regexp) Within regular expression character classes ([]) the syntax +(F regexp) Within regular expression character classes ([]) the syntax beginning with "[." and ending with ".]" is reserved for future -extensions. If you need to represent those character sequences inside a -regular expression character class, just quote the square brackets with -the backslash: "\[." and ".\]". +extensions. If you need to represent those character sequences inside +a regular expression character class, just quote the square brackets +with the backslash: "\[." and ".\]". =item Character class syntax [= =] is reserved for future extensions -(W regexp) Within regular expression character classes ([]) the syntax +(F) Within regular expression character classes ([]) the syntax beginning with "[=" and ending with "=]" is reserved for future -extensions. If you need to represent those character sequences inside a -regular expression character class, just quote the square brackets with -the backslash: "\[=" and "=\]". +extensions. If you need to represent those character sequences inside +a regular expression character class, just quote the square brackets +with the backslash: "\[=" and "=\]". =item Character class [:%s:] unknown diff --git a/regcomp.c b/regcomp.c index bbdfdc3..a15eb23 100644 --- a/regcomp.c +++ b/regcomp.c @@ -2842,10 +2842,10 @@ S_regpposixcc(pTHX_ I32 value) Perl_croak(aTHX_ "Character class [:%.*s:] unknown", t - s - 1, s + 1); - } else if (ckWARN(WARN_REGEXP) && !SIZE_ONLY) + } else if (!SIZE_ONLY) /* [[=foo=]] and [[.foo.]] are still future. */ - Perl_warner(aTHX_ WARN_REGEXP, - "Character class syntax [%c %c] is reserved for future extensions", c, c); + Perl_croak(aTHX_ + "Character class syntax [%c %c] is reserved for future extensions", c, c); } else { /* Maternal grandfather: * "[:" ending in ":" but not in ":]" */ @@ -2873,8 +2873,8 @@ S_checkposixcc(pTHX) Perl_warner(aTHX_ WARN_REGEXP, "Character class syntax [%c %c] belongs inside character classes", c, c); if (c == '=' || c == '.') - Perl_warner(aTHX_ WARN_REGEXP, - "Character class syntax [%c %c] is reserved for future extensions", c, c); + Perl_croak(aTHX_ + "Character class syntax [%c %c] is reserved for future extensions", c, c); } } } diff --git a/t/pragma/warn/regcomp b/t/pragma/warn/regcomp index 5d0c291..ef87b7f 100644 --- a/t/pragma/warn/regcomp +++ b/t/pragma/warn/regcomp @@ -11,10 +11,6 @@ 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] - Character class syntax [%c %c] belongs inside character classes [S_checkposixcc] /%.127s/: false [] range \"%*.*s\" in regexp [S_regclass] @@ -58,32 +54,37 @@ BEGIN { $ENV{PERL_DESTRUCT_LEVEL} = 0 unless $ENV{PERL_DESTRUCT_LEVEL} > 3 } use warnings 'regexp' ; $_ = "" ; /[:alpha:]/; -/[.bar.]/; -/[=zog=]/; -/[[:alpha:]]/; -/[[.foo.]]/; -/[[=bar=]]/; /[:zog:]/; /[[:zog:]]/; no warnings 'regexp' ; /[:alpha:]/; -/[.foo.]/; -/[=bar=]/; -/[[:alpha:]]/; -/[[.foo.]]/; -/[[=bar=]]/; -/[[:zog:]]/; /[:zog:]/; +/[[:zog:]]/; EXPECT Character class syntax [: :] belongs inside character classes at - line 5. -Character class syntax [. .] belongs inside character classes at - line 6. -Character class syntax [. .] is reserved for future extensions at - line 6. -Character class syntax [= =] belongs inside character classes at - line 7. -Character class syntax [= =] is reserved for future extensions at - line 7. -Character class syntax [. .] is reserved for future extensions at - line 9. -Character class syntax [= =] is reserved for future extensions at - line 10. -Character class syntax [: :] belongs inside character classes at - line 11. -Character class [:zog:] unknown at - line 12. +Character class syntax [: :] belongs inside character classes at - line 6. +Character class [:zog:] unknown at - line 7. +######## +# regcomp.c [S_checkposixcc] +BEGIN { $ENV{PERL_DESTRUCT_LEVEL} = 0 unless $ENV{PERL_DESTRUCT_LEVEL} > 3 } +use warnings 'regexp' ; +$_ = "" ; +/[.zog.]/; +no warnings 'regexp' ; +/[.zog.]/; +EXPECT +Character class syntax [. .] belongs inside character classes at - line 5. +Character class syntax [. .] is reserved for future extensions at - line 5. +######## +# regcomp.c [S_checkposixcc] +BEGIN { $ENV{PERL_DESTRUCT_LEVEL} = 0 unless $ENV{PERL_DESTRUCT_LEVEL} > 3 } +use warnings 'regexp' ; +$_ = "" ; +/[[.zog.]]/; +no warnings 'regexp' ; +/[[.zog.]]/; +EXPECT +Character class syntax [. .] is reserved for future extensions at - line 5. ######## # regcomp.c [S_regclass] $_ = "";