From: Marcus Holland-Moritz Date: Tue, 6 Jul 2004 21:43:05 +0000 (+0000) Subject: Failing matches don't reset numbered variables. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=30799d55fe07dcf79e95d2823efbd5ec4c2e3bf4;p=p5sagit%2Fp5-mst-13.2.git Failing matches don't reset numbered variables. Change #22997 could cause Text::ParseWords to loop forever if the regex didn't not match. Explicitly return if the match fails. p4raw-id: //depot/perl@23060 --- diff --git a/lib/Text/ParseWords.pm b/lib/Text/ParseWords.pm index cca28bf..94e6db7 100644 --- a/lib/Text/ParseWords.pm +++ b/lib/Text/ParseWords.pm @@ -63,7 +63,7 @@ sub parse_line { ^((?:\\.|[^\\"'])*?) # an $unquoted text (\Z(?!\n)|(?-x:$delimiter)|(?!^)(?=["'])) # plus EOL, delimiter, or quote - //xs; # extended layout + //xs or return; # extended layout my($quote, $quoted, $unquoted, $delim) = ($1, $2, $3, $4); return() unless( defined($quote) || length($unquoted) || length($delim)); diff --git a/lib/Text/ParseWords.t b/lib/Text/ParseWords.t index c776e66..74c2733 100755 --- a/lib/Text/ParseWords.t +++ b/lib/Text/ParseWords.t @@ -8,7 +8,7 @@ BEGIN { use warnings; use Text::ParseWords; -print "1..21\n"; +print "1..22\n"; @words = shellwords(qq(foo "bar quiz" zoo)); print "not " if $words[0] ne 'foo'; @@ -125,3 +125,10 @@ $string = qq{"field1"\x{1234}"field2\\\x{1234}still field2"\x{1234}"field3"}; $result = join('|', parse_line("\x{1234}", 0, $string)); print "not " unless $result eq "field1|field2\x{1234}still field2|field3"; print "ok 21\n"; + +# missing quote after matching regex used to hang after change #22997 +"1234" =~ /(1)(2)(3)(4)/; +$string = qq{"missing quote}; +$result = join('|', shellwords($string)); +print "not " unless $result eq ""; +print "ok 22\n";