Skip to content

Commit

Permalink
longstanding bug in parsing "require VERSION", could reallocate
Browse files Browse the repository at this point in the history
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: 18b0951

p4raw-id: //depot/perl@5061
  • Loading branch information
Gurusamy Sarathy committed Feb 10, 2000
1 parent 1acb48c commit 9f3d182
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
20 changes: 19 additions & 1 deletion t/comp/require.t
Expand Up @@ -7,7 +7,7 @@ BEGIN {

# don't make this lexical
$i = 1;
print "1..16\n";
print "1..20\n";

sub do_require {
%INC = ();
Expand All @@ -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; };
Expand Down
8 changes: 7 additions & 1 deletion t/comp/use.t
Expand Up @@ -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 ($@) {
Expand Down
2 changes: 1 addition & 1 deletion toke.c
Expand Up @@ -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;
Expand Down

0 comments on commit 9f3d182

Please sign in to comment.