From 7253e4e3a1f0c024bb2c5e2cff0df31194419994 Mon Sep 17 00:00:00 2001 From: "Ronald J. Kimball" Date: Wed, 16 May 2001 09:04:43 -0400 Subject: [PATCH] Re: [PATCH] HERE mark in regex Message-ID: <20010516130443.E1516273@linguist.thayer.dartmouth.edu> p4raw-id: //depot/perl@10136 --- pod/perldiag.pod | 196 +++++++++++++++++++++++++++----------------------- regcomp.c | 6 +- t/op/misc.t | 2 +- t/op/re_tests | 60 ++++++++-------- t/op/regmesg.t | 70 +++++++++--------- t/pragma/warn/regcomp | 52 +++++++------- 6 files changed, 200 insertions(+), 186 deletions(-) diff --git a/pod/perldiag.pod b/pod/perldiag.pod index 7b69b63..19ac8f3 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -567,10 +567,10 @@ C<-i.bak>, or some such. characters and Perl was unable to create a unique filename during inplace editing with the B<-i> switch. The file was ignored. -=item Can't do {n,m} with n > m before << HERE in regex m/%s/ +=item Can't do {n,m} with n > m in regex; marked by <-- HERE in m/%s/ (F) Minima must be less than or equal to maxima. If you really want your -regexp to match something 0 times, just put {0}. The << HERE shows in the +regexp to match something 0 times, just put {0}. The <-- HERE shows in the regular expression about where the problem was discovered. See L. =item Can't do setegid! @@ -1363,12 +1363,13 @@ Check the #! line, or manually feed your script into Perl yourself. END subroutine. Processing of the remainder of the queue of such routines has been prematurely ended. -=item false [] range "%s" in regexp +=item False [] range "%s" in regex; marked by <-- HERE in m/%s/ (W regexp) A character class range must start and end at a literal -character, not another character class like C<\d> or C<[:alpha:]>. The -"-" in your false range is interpreted as a literal "-". Consider -quoting the "-", "\-". See L. +character, not another character class like C<\d> or C<[:alpha:]>. The "-" +in your false range is interpreted as a literal "-". Consider quoting the +"-", "\-". The <-- HERE shows in the regular expression about where the +problem was discovered. See L. =item Fatal VMS error at %s, line %d @@ -1417,11 +1418,11 @@ some time before now. Check your control flow. flock() operates on filehandles. Are you attempting to call flock() on a dirhandle by the same name? -=item Quantifier follows nothing before << HERE in regex m/%s/ +=item Quantifier follows nothing in regex; marked by <-- HERE in m/%s/ (F) You started a regular expression with a quantifier. Backslash it if you -meant it literally. The << HERE shows in the regular expression about where the -problem was discovered. See L. +meant it literally. The <-- HERE shows in the regular expression about +where the problem was discovered. See L. =item Format not terminated @@ -1667,10 +1668,10 @@ transparently promotes all numbers to a floating point representation internally--subject to loss of precision errors in subsequent operations. -=item Internal disaster before << HERE in regex m/%s/ +=item Internal disaster in regex; marked by <-- HERE in m/%s/ (P) Something went badly wrong in the regular expression parser. -The << HERE shows in the regular expression about where the problem was +The <-- HERE shows in the regular expression about where the problem was discovered. @@ -1683,10 +1684,11 @@ L). Somehow, this count has become scrambled, so Perl is making a guess and treating this C as a request to terminate the Perl script and execute the specified command. -=item Internal urp before << HERE in regex m/%s/ +=item Internal urp in regex; marked by <-- HERE in m/%s/ -(P) Something went badly awry in the regular expression parser. The <<. (W printf) Perl does not understand the given format conversion. See L. -=item invalid [] range "%s" in regexp +=item Invalid [] range "%s" in regex; marked by <-- HERE in m/%s/ (F) The range specified in a character class had a minimum character -greater than the maximum character. One possibility is that you -forgot the C<{}> from your ending C<\x{}> - C<\x> without the curly -braces can go only up to C. See L. +greater than the maximum character. One possibility is that you forgot the +C<{}> from your ending C<\x{}> - C<\x> without the curly braces can go only +up to C. The <-- HERE shows in the regular expression about where the +problem was discovered. See L. -=item invalid [] range "%s" in transliteration operator +=item Invalid [] range "%s" in transliteration operator (F) The range specified in the tr/// or y/// operator had a minimum character greater than the maximum character. See L. @@ -1813,11 +1816,11 @@ instead on the filehandle.) values cannot be returned in subroutines used in lvalue context. See L. -=item Lookbehind longer than %d not implemented before << HERE %s +=item Lookbehind longer than %d not implemented in regex; marked by <-- HERE in m/%s/ (F) There is currently a limit on the length of string which lookbehind can -handle. This restriction may be eased in a future release. The << HERE shows in -the regular expression about where the problem was discovered. +handle. This restriction may be eased in a future release. The <-- HERE +shows in the regular expression about where the problem was discovered. =item Malformed PERLLIB_PREFIX @@ -1843,11 +1846,12 @@ Perl detected something that didn't comply with UTF-8 encoding rules. Perl thought it was reading UTF-16 encoded character data but while doing it Perl met a malformed Unicode surrogate. -=item %s matches null string many times +=item %s matches null string many times in regex; marked by <-- HERE in m/%s/ (W regexp) The pattern you've specified would be an infinite loop if the -regular expression engine didn't specifically check for that. See -L. +regular expression engine didn't specifically check for that. The <-- HERE +shows in the regular expression about where the problem was discovered. +See L. =item % may only be used in unpack @@ -2008,16 +2012,15 @@ provided for this purpose. (F) You tried to do a read/write/send/recv operation with a buffer length that is less than 0. This is difficult to imagine. -=item Nested quantifiers before << HERE in regex m/%s/ +=item Nested quantifiers in regex; marked by <-- HERE in m/%s/ (F) You can't quantify a quantifier without intervening parentheses. So -things like ** or +* or ?* are illegal. The << HERE shows in the regular +things like ** or +* or ?* are illegal. The <-- HERE shows in the regular expression about where the problem was discovered. -Note, however, that the minimal matching quantifiers, C<*?>, C<+?>, and +Note that the minimal matching quantifiers, C<*?>, C<+?>, and C appear to be nested quantifiers, but aren't. See L. - =item %s never introduced (S internal) The symbol in question was declared but somehow went out of @@ -2658,34 +2661,38 @@ value of the environment variable PERLIO. process which isn't a subprocess of the current process. While this is fine from VMS' perspective, it's probably not what you intended. -=item POSIX syntax [%s] belongs inside character classes +=item POSIX syntax [%s] belongs inside character classes in regex; marked by <-- HERE in m/%s/ (W unsafe) The character class constructs [: :], [= =], and [. .] go -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 and will cause fatal errors. +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 and will +cause fatal errors. The <-- HERE shows in the regular expression about +where the problem was discovered. See L. -=item POSIX syntax [. .] is reserved for future extensions +=item POSIX syntax [. .] is reserved for future extensions in regex; marked by <-- HERE in m/%s/ (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 ".\]". +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 ".\]". The <-- HERE shows in the regular expression +about where the problem was discovered. See L. -=item POSIX syntax [= =] is reserved for future extensions +=item POSIX syntax [= =] is reserved for future extensions in regex; marked by <-- HERE in m/%s/ -(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 "=\]". +(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 "=\]". The <-- HERE shows in the regular expression about where the +problem was discovered. See L. -=item POSIX class [:%s:] unknown +=item POSIX class [:%s:] unknown in regex; marked by <-- HERE in m/%s/ -(F) The class in the character class [: :] syntax is unknown. See -L. +(F) The class in the character class [: :] syntax is unknown. The <-- HERE +shows in the regular expression about where the problem was discovered. +See L. =item POSIX getpgrp can't take an argument @@ -2809,13 +2816,13 @@ in L. (S unsafe) The subroutine being declared or defined had previously been declared or defined with a different function prototype. -=item Quantifier in {,} bigger than %d before << HERE in regex m/%s/ +=item Quantifier in {,} bigger than %d in regex; marked by <-- HERE in m/%s/ (F) There is currently a limit to the size of the min and max values of the -{min,max} construct. The << HERE shows in the regular expression about where +{min,max} construct. The <-- HERE shows in the regular expression about where the problem was discovered. See L. -=item Quantifier unexpected on zero-length expression before << HERE %s +=item Quantifier unexpected on zero-length expression; marked by <-- HERE in m/%s/ (W regexp) You applied a regular expression quantifier in a place where it makes no sense, such as on a zero-width assertion. Try putting the @@ -2823,6 +2830,9 @@ quantifier inside the assertion instead. For example, the way to match "abc" provided that it is followed by three repetitions of "xyz" is C, not C. +The <-- HERE shows in the regular expression about where the problem was +discovered. + =item Range iterator outside integer range (F) One (or both) of the numeric arguments to the range operator ".." @@ -2883,14 +2893,14 @@ Doing so has no effect. (W internal) The internal sv_replace() function was handed a new SV with a reference count of other than 1. -=item Reference to nonexistent group before << HERE in regex m/%s/ +=item Reference to nonexistent group in regex; marked by <-- HERE in m/%s/ (F) You used something like C<\7> in your regular expression, but there are not at least seven sets of capturing parentheses in the expression. If you wanted to have the character with value 7 inserted into the regular expression, prepend a zero to make the number at least two digits: C<\07> -The << HERE shows in the regular expression about where the problem was +The <-- HERE shows in the regular expression about where the problem was discovered. =item regexp memory corruption @@ -3007,34 +3017,37 @@ scalar that had previously been marked as free. (W closed) The socket you're sending to got itself closed sometime before now. Check your control flow. -=item Sequence (? incomplete before << HERE mark in regex m/%s/ +=item Sequence (? incomplete in regex; marked by <-- HERE in m/%s/ -(F) A regular expression ended with an incomplete extension (?. The <<. -=item Sequence (?{...}) not terminated or not {}-balanced in %s +=item Sequence (?{...}) not terminated or not {}-balanced in regex; marked by <-- HERE in m/%s/ (F) If the contents of a (?{...}) clause contains braces, they must balance -for Perl to properly detect the end of the clause. See L. +for Perl to properly detect the end of the clause. The <-- HERE shows in +the regular expression about where the problem was discovered. See +L. -=item Sequence (?%s...) not implemented before << HERE mark in %s +=item Sequence (?%s...) not implemented in regex; marked by <-- HERE in m/%s/ (F) A proposed regular expression extension has the character reserved but -has not yet been written. The << HERE shows in the regular expression about +has not yet been written. The <-- HERE shows in the regular expression about where the problem was discovered. See L. -=item Sequence (?%s...) not recognized before << HERE mark in %s +=item Sequence (?%s...) not recognized in regex; marked by <-- HERE in m/%s/ -(F) You used a regular expression extension that doesn't make sense. -The << HERE shows in the regular expression about -where the problem was discovered. -See L. +(F) You used a regular expression extension that doesn't make sense. The +<-- HERE shows in the regular expression about where the problem was +discovered. See L. -=item Sequence (?#... not terminated in regex m/%s/ +=item Sequence (?#... not terminated in regex; marked by <-- HERE in m/%s/ (F) A regular expression comment must be terminated by a closing -parenthesis. Embedded parentheses aren't allowed. See L. +parenthesis. Embedded parentheses aren't allowed. The <-- HERE shows in +the regular expression about where the problem was discovered. See +L. =item 500 Server error @@ -3215,7 +3228,7 @@ assignment or as a subroutine argument for example). (F) Your Perl was compiled with B<-D>SETUID_SCRIPTS_ARE_SECURE_NOW, but a version of the setuid emulator somehow got run anyway. -=item Switch (?(condition)... contains too many branches before << HE%s +=item Switch (?(condition)... contains too many branches in regex; marked by <-- HERE in m/%s/ (F) A (?(condition)if-clause|else-clause) construct can have at most two branches (the if-clause and the else-clause). If you want one or both to @@ -3224,13 +3237,13 @@ clustering parentheses: (?(condition)(?:this|that|other)|else-clause) -The << HERE shows in the regular expression about where the problem was +The <-- HERE shows in the regular expression about where the problem was discovered. See L. -=item Switch condition not recognized before << HERE in regex m/%s/ +=item Switch condition not recognized in regex; marked by <-- HERE in m/%s/ (F) If the argument to the (?(...)if-clause|else-clause) construct is a -number, it can be only a number. The << HERE shows in the regular expression +number, it can be only a number. The <-- HERE shows in the regular expression about where the problem was discovered. See L. =item switching effective %s is not implemented @@ -3394,7 +3407,7 @@ Check the #! line, or manually feed your script into Perl yourself. =item Too many ('s -=item trailing \ in regexp +=item Trailing \ in regex m/%s/ (F) The regular expression ends with an unbackslashed backslash. Backslash it. See L. @@ -3508,15 +3521,16 @@ representative, who probably put it there in the first place. (F) There are no byte-swapping functions for a machine with this byte order. -=item Unknown switch condition (?(%.2s before << HERE in regex m/%s/ +=item Unknown switch condition (?(%.2s in regex; marked by <-- HERE in m/%s/ -(F) The condition of a (?(condition)if-clause|else-clause) construct is not -known. The condition may be lookaround (the condition is true if the -lookaround is true), a (?{...}) construct (the condition is true if the -code evaluates to a true value), or a number (the condition is true if the -set of capturing parentheses named by the number is defined). +(F) The condition part of a (?(condition)if-clause|else-clause) construct +is not known. The condition may be lookahead or lookbehind (the condition +is true if the lookahead or lookbehind is true), a (?{...}) construct (the +condition is true if the code evaluates to a true value), or a number (the +condition is true if the set of capturing parentheses named by the number +matched). -The << HERE shows in the regular expression about where the problem was +The <-- HERE shows in the regular expression about where the problem was discovered. See L. =item Unknown open() mode '%s' @@ -3532,18 +3546,19 @@ iterating over it, and someone else stuck a message in the stream of data Perl expected. Someone's very confused, or perhaps trying to subvert Perl's population of %ENV for nefarious purposes. -=item unmatched [ before << HERE mark in regex m/%s/ +=item unmatched [ in regex; marked by <-- HERE in m/%s/ (F) The brackets around a character class must match. If you wish to include a closing bracket in a character class, backslash it or put it -first. See L. The << HERE shows in the regular expression about -where the escape was discovered. +first. The <-- HERE shows in the regular expression about where the problem +was discovered. See L. -=item unmatched ( in regexp before << HERE mark in regex m/%s/ +=item unmatched ( in regex; marked by <-- HERE in m/%s/ (F) Unbackslashed parentheses must always be balanced in regular -expressions. If you're a vi user, the % key is valuable for finding the -matching parenthesis. See L. +expressions. If you're a vi user, the % key is valuable for finding the +matching parenthesis. The <-- HERE shows in the regular expression about +where the problem was discovered. See L. =item Unmatched right %s bracket @@ -3571,14 +3586,13 @@ script, a binary program, or a directory as a Perl program. recognized by Perl inside character classes. The character was understood literally. -=item Unrecognized escape \\%c passed through before << HERE in m/%s/ +=item Unrecognized escape \\%c passed through in regex; marked by <-- HERE in m/%s/ (W regexp) You used a backslash-character combination which is not recognized by Perl. This combination appears in an interpolated variable or a C<'>-delimited regular expression. The character was understood -literally. The << HERE shows in the regular expression about where the escape -was discovered. - +literally. The <-- HERE shows in the regular expression about where the +escape was discovered. =item Unrecognized escape \\%c passed through @@ -3905,11 +3919,11 @@ anonymous, using the C syntax. When inner anonymous subs that reference variables in outer subroutines are called or referenced, they are automatically rebound to the current values of such variables. -=item Variable length lookbehind not implemented before << HERE in %s +=item Variable length lookbehind not implemented in regex; marked by <-- HERE in m/%s/ (F) Lookbehind is allowed only for subexpressions whose length is fixed and -known at compile time. The << HERE shows in the regular expression about where -the problem was discovered. +known at compile time. The <-- HERE shows in the regular expression about +where the problem was discovered. See L. =item Version number must be a constant number diff --git a/regcomp.c b/regcomp.c index a1defc6..1fdc44a 100644 --- a/regcomp.c +++ b/regcomp.c @@ -250,10 +250,10 @@ static scan_data_t zero_scan_data = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, * of t/op/regmesg.t, the tests in t/op/re_tests, and those in * op/pragma/warn/regcomp. */ -#define MARKER1 "HERE" /* marker as it appears in the description */ -#define MARKER2 " << HERE " /* marker as it appears within the regex */ +#define MARKER1 "<-- HERE" /* marker as it appears in the description */ +#define MARKER2 " <-- HERE " /* marker as it appears within the regex */ -#define REPORT_LOCATION " before " MARKER1 " mark in regex m/%.*s" MARKER2 "%s/" +#define REPORT_LOCATION " in regex; marked by " MARKER1 " in m/%.*s" MARKER2 "%s/" /* * Calls SAVEDESTRUCTOR_X if needed, then calls Perl_croak with the given diff --git a/t/op/misc.t b/t/op/misc.t index 730e661..8c45342 100755 --- a/t/op/misc.t +++ b/t/op/misc.t @@ -358,7 +358,7 @@ print "you die joe!\n" unless "@x" eq 'x y z'; /(?{"{"})/ # Check it outside of eval too EXPECT Sequence (?{...}) not terminated or not {}-balanced at - line 1, within pattern -Sequence (?{...}) not terminated or not {}-balanced before HERE mark in regex m/(?{ << HERE "{"})/ at - line 1. +Sequence (?{...}) not terminated or not {}-balanced in regex; marked by <-- HERE in m/(?{ <-- HERE "{"})/ at - line 1. ######## /(?{"{"}})/ # Check it outside of eval too EXPECT diff --git a/t/op/re_tests b/t/op/re_tests index 806760f..5636af4 100644 --- a/t/op/re_tests +++ b/t/op/re_tests @@ -45,9 +45,9 @@ a[b-d]e ace y $& ace a[b-d] aac y $& ac a[-b] a- y $& a- a[b-] a- y $& a- -a[b-a] - c - Invalid [] range "b-a" before HERE mark in regex m/a[b-a << HERE ]/ -a[]b - c - Unmatched [ before HERE mark in regex m/a[ << HERE ]b/ -a[ - c - Unmatched [ before HERE mark in regex m/a[ << HERE / +a[b-a] - c - Invalid [] range "b-a" in regex; marked by <-- HERE in m/a[b-a <-- HERE ]/ +a[]b - c - Unmatched [ in regex; marked by <-- HERE in m/a[ <-- HERE ]b/ +a[ - c - Unmatched [ in regex; marked by <-- HERE in m/a[ <-- HERE / a] a] y $& a] a[]]b a]b y $& a]b a[^bc]d aed y $& aed @@ -95,21 +95,21 @@ a[\S]b a-b y - - ab|cd abc y $& ab ab|cd abcd y $& ab ()ef def y $&-$1 ef- -*a - c - Quantifier follows nothing before HERE mark in regex m/* << HERE a/ -(*)b - c - Quantifier follows nothing before HERE mark in regex m/(* << HERE )b/ +*a - c - Quantifier follows nothing in regex; marked by <-- HERE in m/* <-- HERE a/ +(*)b - c - Quantifier follows nothing in regex; marked by <-- HERE in m/(* <-- HERE )b/ $b b n - - a\ - c - Search pattern not terminated a\(b a(b y $&-$1 a(b- a\(*b ab y $& ab a\(*b a((b y $& a((b a\\b a\b y $& a\b -abc) - c - Unmatched ) before HERE mark in regex m/abc) << HERE / -(abc - c - Unmatched ( before HERE mark in regex m/( << HERE abc/ +abc) - c - Unmatched ) in regex; marked by <-- HERE in m/abc) <-- HERE / +(abc - c - Unmatched ( in regex; marked by <-- HERE in m/( <-- HERE abc/ ((a)) abc y $&-$1-$2 a-a-a (a)b(c) abc y $&-$1-$2 abc-a-c a+b+c aabbabc y $& abc a{1,}b{1,}c aabbabc y $& abc -a** - c - Nested quantifiers before HERE mark in regex m/a** << HERE / +a** - c - Nested quantifiers in regex; marked by <-- HERE in m/a** <-- HERE / a.+?c abcabc y $& abc (a+|b)* ab y $&-$1 ab-b (a+|b){0,} ab y $&-$1 ab-b @@ -117,7 +117,7 @@ a.+?c abcabc y $& abc (a+|b){1,} ab y $&-$1 ab-b (a+|b)? ab y $&-$1 a-a (a+|b){0,1} ab y $&-$1 a-a -)( - c - Unmatched ) before HERE mark in regex m/) << HERE (/ +)( - c - Unmatched ) in regex; marked by <-- HERE in m/) <-- HERE (/ [^ab]* cde y $& cde abc n - - a* y $& @@ -218,9 +218,9 @@ a[-]?c ac y $& ac 'a[b-d]'i AAC y $& AC 'a[-b]'i A- y $& A- 'a[b-]'i A- y $& A- -'a[b-a]'i - c - Invalid [] range "b-a" before HERE mark in regex m/a[b-a << HERE ]/ -'a[]b'i - c - Unmatched [ before HERE mark in regex m/a[ << HERE ]b/ -'a['i - c - Unmatched [ before HERE mark in regex m/a[ << HERE / +'a[b-a]'i - c - Invalid [] range "b-a" in regex; marked by <-- HERE in m/a[b-a <-- HERE ]/ +'a[]b'i - c - Unmatched [ in regex; marked by <-- HERE in m/a[ <-- HERE ]b/ +'a['i - c - Unmatched [ in regex; marked by <-- HERE in m/a[ <-- HERE / 'a]'i A] y $& A] 'a[]]b'i A]B y $& A]B 'a[^bc]d'i AED y $& AED @@ -232,21 +232,21 @@ a[-]?c ac y $& ac 'ab|cd'i ABC y $& AB 'ab|cd'i ABCD y $& AB '()ef'i DEF y $&-$1 EF- -'*a'i - c - Quantifier follows nothing before HERE mark in regex m/* << HERE a/ -'(*)b'i - c - Quantifier follows nothing before HERE mark in regex m/(* << HERE )b/ +'*a'i - c - Quantifier follows nothing in regex; marked by <-- HERE in m/* <-- HERE a/ +'(*)b'i - c - Quantifier follows nothing in regex; marked by <-- HERE in m/(* <-- HERE )b/ '$b'i B n - - 'a\'i - c - Search pattern not terminated 'a\(b'i A(B y $&-$1 A(B- 'a\(*b'i AB y $& AB 'a\(*b'i A((B y $& A((B 'a\\b'i A\B y $& A\B -'abc)'i - c - Unmatched ) before HERE mark in regex m/abc) << HERE / -'(abc'i - c - Unmatched ( before HERE mark in regex m/( << HERE abc/ +'abc)'i - c - Unmatched ) in regex; marked by <-- HERE in m/abc) <-- HERE / +'(abc'i - c - Unmatched ( in regex; marked by <-- HERE in m/( <-- HERE abc/ '((a))'i ABC y $&-$1-$2 A-A-A '(a)b(c)'i ABC y $&-$1-$2 ABC-A-C 'a+b+c'i AABBABC y $& ABC 'a{1,}b{1,}c'i AABBABC y $& ABC -'a**'i - c - Nested quantifiers before HERE mark in regex m/a** << HERE / +'a**'i - c - Nested quantifiers in regex; marked by <-- HERE in m/a** <-- HERE / 'a.+?c'i ABCABC y $& ABC 'a.*?c'i ABCABC y $& ABC 'a.{0,5}?c'i ABCABC y $& ABC @@ -257,7 +257,7 @@ a[-]?c ac y $& ac '(a+|b)?'i AB y $&-$1 A-A '(a+|b){0,1}'i AB y $&-$1 A-A '(a+|b){0,1}?'i AB y $&-$1 - -')('i - c - Unmatched ) before HERE mark in regex m/) << HERE (/ +')('i - c - Unmatched ) in regex; marked by <-- HERE in m/) <-- HERE (/ '[^ab]*'i CDE y $& CDE 'abc'i n - - 'a*'i y $& @@ -346,7 +346,7 @@ a(?:b|(c|e){1,2}?|d)+?(.) ace y $1$2 ce (?a+)b) aaab y $1 aaab (?>(a+))b aaab y $1 aaa ((?>[^()]+)|\([^()]*\))+ ((abc(ade)ufh()()x y $& abc(ade)ufh()()x -(?<=x+)y - c - Variable length lookbehind not implemented +(?<=x+)y - c - Variable length lookbehind not implemented in regex; marked by <-- HERE in m/(?<=x+) <-- HERE y/ a{37,17} - c - Can't do {n,m} with n > m \Z a\nb\n y $-[0] 3 \z a\nb\n y $-[0] 4 diff --git a/t/op/regmesg.t b/t/op/regmesg.t index 7ee1bb4..24f6f31 100644 --- a/t/op/regmesg.t +++ b/t/op/regmesg.t @@ -13,8 +13,8 @@ my $debug = 1; ## arrays below. The {#} is a meta-marker -- it marks where the marker should ## go. -my $marker1 = "HERE"; -my $marker2 = " << HERE "; +my $marker1 = "<-- HERE"; +my $marker2 = " <-- HERE "; ## ## Key-value pairs of code/error of code that should have fatal errors. @@ -26,75 +26,75 @@ my $inf_m1 = ($Config{reg_infty} || 32767) - 1; my $inf_p1 = $inf_m1 + 2; my @death = ( - '/[[=foo=]]/' => 'POSIX syntax [= =] is reserved for future extensions before {#} mark in regex m/[[=foo=]{#}]/', + '/[[=foo=]]/' => 'POSIX syntax [= =] is reserved for future extensions in regex; marked by {#} in m/[[=foo=]{#}]/', - '/(?<= .*)/' => 'Variable length lookbehind not implemented before {#} mark in regex m/(?<= .*){#}/', + '/(?<= .*)/' => 'Variable length lookbehind not implemented in regex; marked by {#} in m/(?<= .*){#}/', - '/(?<= x{1000})/' => 'Lookbehind longer than 255 not implemented before {#} mark in regex m/(?<= x{1000}){#}/', + '/(?<= x{1000})/' => 'Lookbehind longer than 255 not implemented in regex; marked by {#} in m/(?<= x{1000}){#}/', - '/(?@)/' => 'Sequence (?@...) not implemented before {#} mark in regex m/(?@{#})/', + '/(?@)/' => 'Sequence (?@...) not implemented in regex; marked by {#} in m/(?@{#})/', - '/(?{ 1/' => 'Sequence (?{...}) not terminated or not {}-balanced before {#} mark in regex m/(?{{#} 1/', + '/(?{ 1/' => 'Sequence (?{...}) not terminated or not {}-balanced in regex; marked by {#} in m/(?{{#} 1/', - '/(?(1x))/' => 'Switch condition not recognized before {#} mark in regex m/(?(1x{#}))/', + '/(?(1x))/' => 'Switch condition not recognized in regex; marked by {#} in m/(?(1x{#}))/', - '/(?(1)x|y|z)/' => 'Switch (?(condition)... contains too many branches before {#} mark in regex m/(?(1)x|y|{#}z)/', + '/(?(1)x|y|z)/' => 'Switch (?(condition)... contains too many branches in regex; marked by {#} in m/(?(1)x|y|{#}z)/', - '/(?(x)y|x)/' => 'Unknown switch condition (?(x) before {#} mark in regex m/(?({#}x)y|x)/', + '/(?(x)y|x)/' => 'Unknown switch condition (?(x) in regex; marked by {#} in m/(?({#}x)y|x)/', - '/(?/' => 'Sequence (? incomplete before {#} mark in regex m/(?{#}/', + '/(?/' => 'Sequence (? incomplete in regex; marked by {#} in m/(?{#}/', - '/(?;x/' => 'Sequence (?;...) not recognized before {#} mark in regex m/(?;{#}x/', - '/(?<;x/' => 'Sequence (?<;...) not recognized before {#} mark in regex m/(?<;{#}x/', + '/(?;x/' => 'Sequence (?;...) not recognized in regex; marked by {#} in m/(?;{#}x/', + '/(?<;x/' => 'Sequence (?<;...) not recognized in regex; marked by {#} in m/(?<;{#}x/', - '/((x)/' => 'Unmatched ( before {#} mark in regex m/({#}(x)/', + '/((x)/' => 'Unmatched ( in regex; marked by {#} in m/({#}(x)/', - "/x{$inf_p1}/" => "Quantifier in {,} bigger than $inf_m1 before {#} mark in regex m/x{{#}$inf_p1}/", + "/x{$inf_p1}/" => "Quantifier in {,} bigger than $inf_m1 in regex; marked by {#} in m/x{{#}$inf_p1}/", - '/x{3,1}/' => 'Can\'t do {n,m} with n > m before {#} mark in regex m/x{3,1}{#}/', + '/x{3,1}/' => 'Can\'t do {n,m} with n > m in regex; marked by {#} in m/x{3,1}{#}/', - '/x**/' => 'Nested quantifiers before {#} mark in regex m/x**{#}/', + '/x**/' => 'Nested quantifiers in regex; marked by {#} in m/x**{#}/', - '/x[/' => 'Unmatched [ before {#} mark in regex m/x[{#}/', + '/x[/' => 'Unmatched [ in regex; marked by {#} in m/x[{#}/', - '/*/', => 'Quantifier follows nothing before {#} mark in regex m/*{#}/', + '/*/', => 'Quantifier follows nothing in regex; marked by {#} in m/*{#}/', - '/\p{x/' => 'Missing right brace on \p{} before {#} mark in regex m/\p{{#}x/', + '/\p{x/' => 'Missing right brace on \p{} in regex; marked by {#} in m/\p{{#}x/', - 'use utf8; /[\p{x]/' => 'Missing right brace on \p{} before {#} mark in regex m/[\p{{#}x]/', + 'use utf8; /[\p{x]/' => 'Missing right brace on \p{} in regex; marked by {#} in m/[\p{{#}x]/', - '/(x)\2/' => 'Reference to nonexistent group before {#} mark in regex m/(x)\2{#}/', + '/(x)\2/' => 'Reference to nonexistent group in regex; marked by {#} in m/(x)\2{#}/', 'my $m = "\\\"; $m =~ $m', => 'Trailing \ in regex m/\/', - '/\x{1/' => 'Missing right brace on \x{} before {#} mark in regex m/\x{{#}1/', + '/\x{1/' => 'Missing right brace on \x{} in regex; marked by {#} in m/\x{{#}1/', - 'use utf8; /[\x{X]/' => 'Missing right brace on \x{} before {#} mark in regex m/[\x{{#}X]/', + 'use utf8; /[\x{X]/' => 'Missing right brace on \x{} in regex; marked by {#} in m/[\x{{#}X]/', - '/[[:barf:]]/' => 'POSIX class [:barf:] unknown before {#} mark in regex m/[[:barf:]{#}]/', + '/[[:barf:]]/' => 'POSIX class [:barf:] unknown in regex; marked by {#} in m/[[:barf:]{#}]/', - '/[[=barf=]]/' => 'POSIX syntax [= =] is reserved for future extensions before {#} mark in regex m/[[=barf=]{#}]/', + '/[[=barf=]]/' => 'POSIX syntax [= =] is reserved for future extensions in regex; marked by {#} in m/[[=barf=]{#}]/', - '/[[.barf.]]/' => 'POSIX syntax [. .] is reserved for future extensions before {#} mark in regex m/[[.barf.]{#}]/', + '/[[.barf.]]/' => 'POSIX syntax [. .] is reserved for future extensions in regex; marked by {#} in m/[[.barf.]{#}]/', - '/[z-a]/' => 'Invalid [] range "z-a" before {#} mark in regex m/[z-a{#}]/', + '/[z-a]/' => 'Invalid [] range "z-a" in regex; marked by {#} in m/[z-a{#}]/', ); ## ## Key-value pairs of code/error of code that should have non-fatal warnings. ## @warning = ( - "m/(?p{ 'a' })/" => "(?p{}) is deprecated - use (??{}) before {#} mark in regex m/(?p{#}{ 'a' })/", + "m/(?p{ 'a' })/" => "(?p{}) is deprecated - use (??{}) in regex; marked by {#} in m/(?p{#}{ 'a' })/", - 'm/\b*/' => '\b* matches null string many times before {#} mark in regex m/\b*{#}/', + 'm/\b*/' => '\b* matches null string many times in regex; marked by {#} in m/\b*{#}/', - 'm/[:blank:]/' => 'POSIX syntax [: :] belongs inside character classes before {#} mark in regex m/[:blank:]{#}/', + 'm/[:blank:]/' => 'POSIX syntax [: :] belongs inside character classes in regex; marked by {#} in m/[:blank:]{#}/', - "m'[\\y]'" => 'Unrecognized escape \y in character class passed through before {#} mark in regex m/[\y{#}]/', + "m'[\\y]'" => 'Unrecognized escape \y in character class passed through in regex; marked by {#} in m/[\y{#}]/', - 'm/[a-\d]/' => 'False [] range "a-\d" before {#} mark in regex m/[a-\d{#}]/', - 'm/[\w-x]/' => 'False [] range "\w-" before {#} mark in regex m/[\w-{#}x]/', - "m'\\y'" => 'Unrecognized escape \y passed through before {#} mark in regex m/\y{#}/', + 'm/[a-\d]/' => 'False [] range "a-\d" in regex; marked by {#} in m/[a-\d{#}]/', + 'm/[\w-x]/' => 'False [] range "\w-" in regex; marked by {#} in m/[\w-{#}x]/', + "m'\\y'" => 'Unrecognized escape \y passed through in regex; marked by {#} in m/\y{#}/', ); my $total = (@death + @warning)/2; diff --git a/t/pragma/warn/regcomp b/t/pragma/warn/regcomp index 8b86b50..7ab4a79 100644 --- a/t/pragma/warn/regcomp +++ b/t/pragma/warn/regcomp @@ -29,7 +29,7 @@ $a =~ /(?=a)*/ ; no warnings 'regexp' ; $a =~ /(?=a)*/ ; EXPECT -(?=a)* matches null string many times before HERE mark in regex m/(?=a)* << HERE / at - line 4. +(?=a)* matches null string many times in regex; marked by <-- HERE in m/(?=a)* <-- HERE / at - line 4. ######## # regcomp.c [S_study_chunk] use warnings 'regexp' ; @@ -38,7 +38,7 @@ $_ = "" ; no warnings 'regexp' ; /(?=a)?/; EXPECT -Quantifier unexpected on zero-length expression before HERE mark in regex m/(?=a)? << HERE / at - line 4. +Quantifier unexpected on zero-length expression in regex; marked by <-- HERE in m/(?=a)? <-- HERE / at - line 4. ######## # regcomp.c [S_regatom] $x = '\m' ; @@ -47,7 +47,7 @@ $a =~ /a$x/ ; no warnings 'regexp' ; $a =~ /a$x/ ; EXPECT -Unrecognized escape \m passed through before HERE mark in regex m/a\m << HERE / at - line 4. +Unrecognized escape \m passed through in regex; marked by <-- HERE in m/a\m <-- HERE / at - line 4. ######## # regcomp.c [S_regpposixcc S_checkposixcc] # @@ -61,9 +61,9 @@ no warnings 'regexp' ; /[:zog:]/; /[[:zog:]]/; EXPECT -POSIX syntax [: :] belongs inside character classes before HERE mark in regex m/[:alpha:] << HERE / at - line 5. -POSIX syntax [: :] belongs inside character classes before HERE mark in regex m/[:zog:] << HERE / at - line 6. -POSIX class [:zog:] unknown before HERE mark in regex m/[[:zog:] << HERE ]/ +POSIX syntax [: :] belongs inside character classes in regex; marked by <-- HERE in m/[:alpha:] <-- HERE / at - line 5. +POSIX syntax [: :] belongs inside character classes in regex; marked by <-- HERE in m/[:zog:] <-- HERE / at - line 6. +POSIX class [:zog:] unknown in regex; marked by <-- HERE in m/[[:zog:] <-- HERE ]/ ######## # regcomp.c [S_checkposixcc] # @@ -73,8 +73,8 @@ $_ = "" ; no warnings 'regexp' ; /[.zog.]/; EXPECT -POSIX syntax [. .] belongs inside character classes before HERE mark in regex m/[.zog.] << HERE / at - line 5. -POSIX syntax [. .] is reserved for future extensions before HERE mark in regex m/[.zog.] << HERE / +POSIX syntax [. .] belongs inside character classes in regex; marked by <-- HERE in m/[.zog.] <-- HERE / at - line 5. +POSIX syntax [. .] is reserved for future extensions in regex; marked by <-- HERE in m/[.zog.] <-- HERE / ######## # regcomp.c [S_checkposixcc] # @@ -84,7 +84,7 @@ $_ = "" ; no warnings 'regexp' ; /[[.zog.]]/; EXPECT -POSIX syntax [. .] is reserved for future extensions before HERE mark in regex m/[[.zog.] << HERE ]/ +POSIX syntax [. .] is reserved for future extensions in regex; marked by <-- HERE in m/[[.zog.] <-- HERE ]/ ######## # regcomp.c [S_regclass] $_ = ""; @@ -109,14 +109,14 @@ no warnings 'regexp' ; /[[:alpha:]-[:digit:]]/; /[[:digit:]-[:alpha:]]/; EXPECT -False [] range "a-\d" before HERE mark in regex m/[a-\d << HERE ]/ at - line 5. -False [] range "\d-" before HERE mark in regex m/[\d- << HERE b]/ at - line 6. -False [] range "\s-" before HERE mark in regex m/[\s- << HERE \d]/ at - line 7. -False [] range "\d-" before HERE mark in regex m/[\d- << HERE \s]/ at - line 8. -False [] range "a-[:digit:]" before HERE mark in regex m/[a-[:digit:] << HERE ]/ at - line 9. -False [] range "[:digit:]-" before HERE mark in regex m/[[:digit:]- << HERE b]/ at - line 10. -False [] range "[:alpha:]-" before HERE mark in regex m/[[:alpha:]- << HERE [:digit:]]/ at - line 11. -False [] range "[:digit:]-" before HERE mark in regex m/[[:digit:]- << HERE [:alpha:]]/ at - line 12. +False [] range "a-\d" in regex; marked by <-- HERE in m/[a-\d <-- HERE ]/ at - line 5. +False [] range "\d-" in regex; marked by <-- HERE in m/[\d- <-- HERE b]/ at - line 6. +False [] range "\s-" in regex; marked by <-- HERE in m/[\s- <-- HERE \d]/ at - line 7. +False [] range "\d-" in regex; marked by <-- HERE in m/[\d- <-- HERE \s]/ at - line 8. +False [] range "a-[:digit:]" in regex; marked by <-- HERE in m/[a-[:digit:] <-- HERE ]/ at - line 9. +False [] range "[:digit:]-" in regex; marked by <-- HERE in m/[[:digit:]- <-- HERE b]/ at - line 10. +False [] range "[:alpha:]-" in regex; marked by <-- HERE in m/[[:alpha:]- <-- HERE [:digit:]]/ at - line 11. +False [] range "[:digit:]-" in regex; marked by <-- HERE in m/[[:digit:]- <-- HERE [:alpha:]]/ at - line 12. ######## # regcomp.c [S_regclassutf8] BEGIN { @@ -148,14 +148,14 @@ no warnings 'regexp' ; /[[:alpha:]-[:digit:]]/; /[[:digit:]-[:alpha:]]/; EXPECT -False [] range "a-\d" before HERE mark in regex m/[a-\d << HERE ]/ at - line 12. -False [] range "\d-" before HERE mark in regex m/[\d- << HERE b]/ at - line 13. -False [] range "\s-" before HERE mark in regex m/[\s- << HERE \d]/ at - line 14. -False [] range "\d-" before HERE mark in regex m/[\d- << HERE \s]/ at - line 15. -False [] range "a-[:digit:]" before HERE mark in regex m/[a-[:digit:] << HERE ]/ at - line 16. -False [] range "[:digit:]-" before HERE mark in regex m/[[:digit:]- << HERE b]/ at - line 17. -False [] range "[:alpha:]-" before HERE mark in regex m/[[:alpha:]- << HERE [:digit:]]/ at - line 18. -False [] range "[:digit:]-" before HERE mark in regex m/[[:digit:]- << HERE [:alpha:]]/ at - line 19. +False [] range "a-\d" in regex; marked by <-- HERE in m/[a-\d <-- HERE ]/ at - line 12. +False [] range "\d-" in regex; marked by <-- HERE in m/[\d- <-- HERE b]/ at - line 13. +False [] range "\s-" in regex; marked by <-- HERE in m/[\s- <-- HERE \d]/ at - line 14. +False [] range "\d-" in regex; marked by <-- HERE in m/[\d- <-- HERE \s]/ at - line 15. +False [] range "a-[:digit:]" in regex; marked by <-- HERE in m/[a-[:digit:] <-- HERE ]/ at - line 16. +False [] range "[:digit:]-" in regex; marked by <-- HERE in m/[[:digit:]- <-- HERE b]/ at - line 17. +False [] range "[:alpha:]-" in regex; marked by <-- HERE in m/[[:alpha:]- <-- HERE [:digit:]]/ at - line 18. +False [] range "[:digit:]-" in regex; marked by <-- HERE in m/[[:digit:]- <-- HERE [:alpha:]]/ at - line 19. ######## # regcomp.c [S_regclass S_regclassutf8] use warnings 'regexp' ; @@ -163,5 +163,5 @@ $a =~ /[a\zb]/ ; no warnings 'regexp' ; $a =~ /[a\zb]/ ; EXPECT -Unrecognized escape \z in character class passed through before HERE mark in regex m/[a\z << HERE b]/ at - line 3. +Unrecognized escape \z in character class passed through in regex; marked by <-- HERE in m/[a\z <-- HERE b]/ at - line 3. -- 2.7.4