From: Hugo van der Sanden Date: Tue, 8 Aug 2000 03:25:51 +0000 (+0100) Subject: Re: enhanced(?) regex error messages X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9baa0206214393e14c90c1119dbe3c122969f510;p=p5sagit%2Fp5-mst-13.2.git Re: enhanced(?) regex error messages Message-Id: <200008080225.DAA10998@crypt.compulink.co.uk> plus Capitalize the error messages, plus perldiag them. p4raw-id: //depot/perl@6546 --- diff --git a/pod/perldiag.pod b/pod/perldiag.pod index fd082a1..ea6f893 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -1779,6 +1779,11 @@ effective uids or gids failed. to check the return value of your socket() call? See L. +=item Lookbehind longer than %d not implemented at {#} mark in regex 5s + +There is an upper limit to the depth of lookbehind in the (?<= +regular expression construct. + =item lstat() on filehandle %s (W io) You tried to do a lstat on a filehandle. What did you mean @@ -1967,7 +1972,7 @@ 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 *?+ in regexp +=item Nested quantifiers in regexp (F) You can't quantify a quantifier without intervening parentheses. So things like ** or +* or ?* are illegal. @@ -2705,6 +2710,15 @@ 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 at {#} mark in regex %s + +(F) There is an upper limit to the number of allowed repetitions in the {,} +regular expression construct. + +=item Quantifier follows nothing in rgexp + +(F) Quantifiers like * are suffixes, they quantify something preceding them. + =item Range iterator outside integer range (F) One (or both) of the numeric arguments to the range operator ".." @@ -2765,6 +2779,11 @@ 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 + +(F) In a regexp you tried to reference (\1, \2, ...) a group that +doesn't exist. Count your parentheses. + =item regexp memory corruption (P) The regular expression engine got confused by what the regular @@ -3640,6 +3659,10 @@ something else of the same name (usually a subroutine) is exported by that module. It usually means you put the wrong funny character on the front of your variable. +=item Variable length lookbehind not implemented + +(F) Lookbehind currently only works for fixed-length regular expressions. + =item "%s" variable %s masks earlier declaration in same %s (W misc) A "my" or "our" variable has been redeclared in the current diff --git a/regcomp.c b/regcomp.c index 911ef1c..12b2eef 100644 --- a/regcomp.c +++ b/regcomp.c @@ -1217,10 +1217,10 @@ S_study_chunk(pTHX_ regnode **scanp, I32 *deltap, regnode *last, scan_data_t *da minnext = study_chunk(&nscan, &deltanext, last, &data_fake, f); if (scan->flags) { if (deltanext) { - vFAIL("variable length lookbehind not implemented"); + vFAIL("Variable length lookbehind not implemented"); } else if (minnext > U8_MAX) { - vFAIL2("lookbehind longer than %"UVuf" not implemented", (UV)U8_MAX); + vFAIL2("Lookbehind longer than %"UVuf" not implemented", (UV)U8_MAX); } scan->flags = minnext; } @@ -2249,7 +2249,7 @@ S_regpiece(pTHX_ I32 *flagp) regtail(ret, ret + NODE_STEP_REGNODE); } if (ISMULT2(PL_regcomp_parse)) - vFAIL("nested quantifiers in regexp"); + vFAIL("Nested quantifiers in regexp"); return(ret); } @@ -2356,7 +2356,7 @@ tryagain: case '?': case '+': case '*': - vFAIL("quantifier follows nothing in regexp"); + vFAIL("Quantifier follows nothing in regexp"); break; case '\\': switch (*++PL_regcomp_parse) { @@ -2515,7 +2515,7 @@ tryagain: goto defchar; else { if (!SIZE_ONLY && num > PL_regcomp_rx->nparens) - vFAIL("reference to nonexistent group"); + vFAIL("Reference to nonexistent group"); PL_regsawback = 1; ret = reganode(FOLD ? (LOC ? REFFL : REFF) diff --git a/t/op/pat.t b/t/op/pat.t index 81591fc..76a7ef3 100755 --- a/t/op/pat.t +++ b/t/op/pat.t @@ -266,12 +266,12 @@ print "ok 68\n"; undef $@; eval "'aaa' =~ /a{1,$reg_infty}/"; -print "not " if $@ !~ m%^\Q/a{1,$reg_infty}/: Quantifier in {,} bigger than%; +print "not " if $@ !~ m%^\QQuantifier in {,} bigger than%; print "ok 69\n"; eval "'aaa' =~ /a{1,$reg_infty_p}/"; print "not " - if $@ !~ m%^\Q/a{1,$reg_infty_p}/: Quantifier in {,} bigger than%; + if $@ !~ m%^\QQuantifier in {,} bigger than%; print "ok 70\n"; undef $@; @@ -279,7 +279,7 @@ undef $@; $context = 'x' x 256; eval qq("${context}y" =~ /(?<=$context)y/); -print "not " if $@ !~ m%^\Q/(?<=\Ex+/: lookbehind longer than 255 not%; +print "not " if $@ !~ m%^\QLookbehind longer than 255 not%; print "ok 71\n"; # removed test @@ -588,8 +588,12 @@ sub make_must_warn { my $for_future = make_must_warn('reserved for future extensions'); &$for_future('q(a:[b]:) =~ /[x[:foo:]]/'); -&$for_future('q(a=[b]=) =~ /[x[=foo=]]/'); -&$for_future('q(a.[b].) =~ /[x[.foo.]]/'); + +#&$for_future('q(a=[b]=) =~ /[x[=foo=]]/'); +print "ok $test\n"; $test++; # now a fatal croak + +#&$for_future('q(a.[b].) =~ /[x[.foo.]]/'); +print "ok $test\n"; $test++; # now a fatal croak # test if failure of patterns returns empty list $_ = 'aaa'; diff --git a/t/op/re_tests b/t/op/re_tests index 3848325..afdcd58 100644 --- a/t/op/re_tests +++ b/t/op/re_tests @@ -95,8 +95,8 @@ a[\S]b a-b y - - ab|cd abc y $& ab ab|cd abcd y $& ab ()ef def y $&-$1 ef- -*a - c - /*a/: ?+*{} follows nothing in regexp -(*)b - c - /(*)b/: ?+*{} follows nothing in regexp +*a - c - Quantifier follows nothing in regexp +(*)b - c - Quantifier follows nothing in regexp $b b n - - a\ - c - Search pattern not terminated a\(b a(b y $&-$1 a(b- @@ -109,7 +109,7 @@ abc) - c - /abc)/: unmatched () in regexp (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 - /a**/: nested *?+ in regexp +a** - c - Nested quantifiers in regexp a.+?c abcabc y $& abc (a+|b)* ab y $&-$1 ab-b (a+|b){0,} ab y $&-$1 ab-b @@ -164,11 +164,11 @@ a(bc)d abcd y $1-\$1-\\$1 bc-$1-\bc a[-]?c ac y $& ac (abc)\1 abcabc y $1 abc ([a-c]*)\1 abcabc y $1 abc -\1 - c - /\1/: reference to nonexistent group -\2 - c - /\2/: reference to nonexistent group +\1 - c - Reference to nonexistent group +\2 - c - Reference to nonexistent group (a)|\1 a y - - (a)|\1 x n - - -(a)|\2 - c - /(a)|\2/: reference to nonexistent group +(a)|\2 - c - Reference to nonexistent group (([a-c])b*?\2)* ababbbcbc y $&-$1-$2 ababb-bb-b (([a-c])b*?\2){3} ababbbcbc y $&-$1-$2 ababbbcbc-cbc-c ((\3|b)\2(a)x)+ aaxabxbaxbbx n - - @@ -232,8 +232,8 @@ 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 - /*a/: ?+*{} follows nothing in regexp -'(*)b'i - c - /(*)b/: ?+*{} follows nothing in regexp +'*a'i - c - Quantifier follows nothing in regexp +'(*)b'i - c - Quantifier follows nothing in regexp '$b'i B n - - 'a\'i - c - Search pattern not terminated 'a\(b'i A(B y $&-$1 A(B- @@ -246,7 +246,7 @@ a[-]?c ac y $& ac '(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 - /a**/: nested *?+ in regexp +'a**'i - c - Nested quantifiers in regexp 'a.+?c'i ABCABC y $& ABC 'a.*?c'i ABCABC y $& ABC 'a.{0,5}?c'i ABCABC y $& ABC @@ -318,7 +318,7 @@ a(?:b|c|d){2}(.) acdbcdbe y $1 b a(?:b|c|d){4,5}(.) acdbcdbe y $1 b a(?:b|c|d){4,5}?(.) acdbcdbe y $1 d ((foo)|(bar))* foobar y $1-$2-$3 bar-foo-bar -:(?: - c - /(?/: Sequence (? incomplete +:(?: - c - Sequence (? incomplete a(?:b|c|d){6,7}(.) acdbcdbe y $1 e a(?:b|c|d){6,7}?(.) acdbcdbe y $1 e a(?:b|c|d){5,6}(.) acdbcdbe y $1 e @@ -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 - /(?<=x+)y/: variable length lookbehind not implemented -a{37,17} - c - /a{37,17}/: Can't do {n,m} with n > m +(?<=x+)y - c - Variable length lookbehind not implemented +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 $ a\nb\n y $-[0] 3