From: Rafael Garcia-Suarez Date: Tue, 3 Jul 2007 14:26:13 +0000 (+0000) Subject: Forbid \g0. (tests coming later) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b72d83b24cdb1d001335c456a4657b1b2d868451;p=p5sagit%2Fp5-mst-13.2.git Forbid \g0. (tests coming later) p4raw-id: //depot/perl@31524 --- diff --git a/pod/perldiag.pod b/pod/perldiag.pod index d0cedfc..338fd12 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -3556,6 +3556,13 @@ 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 invalid group 0 + +(F) You used C<\g0> or similar in a regular expression. You may refer to +capturing parentheses only with strictly positive integers (normal +backreferences) or with stricly negative integers (relative +backreferences), but using 0 does not make sense. + =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 diff --git a/regcomp.c b/regcomp.c index 60b31ed..cada4cd 100644 --- a/regcomp.c +++ b/regcomp.c @@ -7052,6 +7052,8 @@ tryagain: goto parse_named_seq; } } num = atoi(RExC_parse); + if (isg && num == 0) + vFAIL("Reference to invalid group 0"); if (isrel) { num = RExC_npar - num; if (num < 1)