longstanding bug in parsing "require VERSION", could reallocate
authorGurusamy Sarathy <gsar@cpan.org>
Thu, 10 Feb 2000 19:17:09 +0000 (19:17 +0000)
committerGurusamy Sarathy <gsar@cpan.org>
Thu, 10 Feb 2000 19:17:09 +0000 (19:17 +0000)
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

t/comp/require.t
t/comp/use.t
toke.c

index d4c9d8c..f963a8c 100755 (executable)
@@ -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; };
index 2594f0a..dbbda5c 100755 (executable)
@@ -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 (file)
--- 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;