From: Gurusamy Sarathy Date: Thu, 10 Feb 2000 19:17:09 +0000 (+0000) Subject: longstanding bug in parsing "require VERSION", could reallocate X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9f3d182ed95630da223ec0d99832141e262ccc05;p=p5sagit%2Fp5-mst-13.2.git longstanding bug in parsing "require VERSION", could reallocate current line and not know it; exposed by change#5004; manifested as parse failure of C<{require 5.003}> p4raw-link: @5004 on //depot/perl: 18b095192e336ba31465f4d3dab1ecc90871c3a9 p4raw-id: //depot/perl@5061 --- diff --git a/t/comp/require.t b/t/comp/require.t index d4c9d8c..f963a8c 100755 --- a/t/comp/require.t +++ b/t/comp/require.t @@ -7,7 +7,7 @@ BEGIN { # don't make this lexical $i = 1; -print "1..16\n"; +print "1..20\n"; sub do_require { %INC = (); @@ -23,6 +23,24 @@ sub write_file { close REQ; } +eval {require 5.005}; +print "# $@\nnot " if $@; +print "ok ",$i++,"\n"; + +eval { require 5.005 }; +print "# $@\nnot " if $@; +print "ok ",$i++,"\n"; + +eval { require 5.005; }; +print "# $@\nnot " if $@; +print "ok ",$i++,"\n"; + +eval { + require 5.005 +}; +print "# $@\nnot " if $@; +print "ok ",$i++,"\n"; + # new style version numbers eval { require v5.5.630; }; diff --git a/t/comp/use.t b/t/comp/use.t index 2594f0a..dbbda5c 100755 --- a/t/comp/use.t +++ b/t/comp/use.t @@ -5,9 +5,15 @@ BEGIN { unshift @INC, '../lib'; } -print "1..14\n"; +print "1..15\n"; my $i = 1; +eval "use 5.000"; # implicit semicolon +if ($@) { + print STDERR $@,"\n"; + print "not "; +} +print "ok ",$i++,"\n"; eval "use 5.000;"; if ($@) { diff --git a/toke.c b/toke.c index 34599bd..44b3023 100644 --- a/toke.c +++ b/toke.c @@ -825,7 +825,7 @@ S_force_version(pTHX_ char *s) if (*d == 'v') d++; for (; isDIGIT(*d) || *d == '_' || *d == '.'; d++); - if ((*d == ';' || isSPACE(*d)) && *(skipspace(d)) != ',') { + if (*d == ';' || isSPACE(*d) || *d == '}' || !*d) { s = scan_num(s); /* real VERSION number -- GBARR */ version = yylval.opval;