develooper Front page | perl.perl5.porters | Postings from August 2002

Re: [perl #16773] "abc" =~ /(ab)()(c)??/ broken

Thread Previous
From:
hv
Date:
August 26, 2002 13:34
Subject:
Re: [perl #16773] "abc" =~ /(ab)()(c)??/ broken
Message ID:
200208262039.g7QKdpp26727@crypt.compulink.co.uk
(Randal L. Schwartz) (via RT) <perlbug@perl.org> wrote:
:From at least 5.004_55 to 5.8 (according to #perl denizens),
:"abc" =~ /(ab)()(c)??/ has been broken, returning either
:("ab", undef, "b") or ("ab", "", "b").  In both cases, $3 should
:not be "b".

Thanks for the report; I've applied the patch below as change #17787
to fix this.

Hugo
--- regexec.c.old	Mon Jul 15 05:34:54 2002
+++ regexec.c	Mon Aug 26 21:30:45 2002
@@ -3682,14 +3682,14 @@
 			/* If it could work, try it. */
 		        if (c == (UV)c1 || c == (UV)c2)
 		        {
-			    TRYPAREN(paren, n, PL_reginput);
+			    TRYPAREN(paren, ln, PL_reginput);
 			    REGCP_UNWIND(lastcp);
 		        }
 		    }
 		    /* If it could work, try it. */
 		    else if (c1 == -1000)
 		    {
-			TRYPAREN(paren, n, PL_reginput);
+			TRYPAREN(paren, ln, PL_reginput);
 			REGCP_UNWIND(lastcp);
 		    }
 		    /* Couldn't or didn't -- move forward. */
--- t/op/re_tests.old	Mon Jul 15 05:34:54 2002
+++ t/op/re_tests	Mon Aug 26 21:32:33 2002
@@ -922,3 +922,4 @@
 (.*?)(?<=[bc])c	abcd	y	$1	ab
 2(]*)?$\1	2	y	$&	2
 (??{})	x	y	-	-
+a(b)??	abc	y	<$1>	<>	# undef [perl #16773]

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About