[perl #24482] Fix sort and require to treat CORE:: as keyword
authorFather Chrysostomos <sprout@cpan.org>
Sat, 8 Jun 2013 03:16:23 +0000 (20:16 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 8 Jun 2013 03:28:39 +0000 (20:28 -0700)
t/comp/require.t
t/op/sort.t
toke.c

index ac71132..475388f 100644 (file)
@@ -34,7 +34,7 @@ if (grep -e, @files_to_delete) {
 
 my $Is_EBCDIC = (ord('A') == 193) ? 1 : 0;
 my $Is_UTF8   = (${^OPEN} || "") =~ /:utf8/;
-my $total_tests = 54;
+my $total_tests = 55;
 if ($Is_EBCDIC || $Is_UTF8) { $total_tests -= 3; }
 print "1..$total_tests\n";
 
@@ -211,6 +211,15 @@ if($@ =~ /Can't locate threads in \@INC/) {
     print "not ok - RT #24404$i\n";
 }
 
+# require CORE::foo
+eval ' require CORE::lc "THREADS" ';
+$i++;
+if($@ =~ /Can't locate threads in \@INC/) {
+    print "ok $i - [perl #24482] require CORE::foo\n";
+} else {
+    print "not ok - [perl #24482] require CORE::foo\n";
+}
+
 
 write_file('bleah.pm', qq(die "This is an expected error";\n));
 delete $INC{"bleah.pm"}; ++$::i;
index 03d2ce1..ca749a0 100644 (file)
@@ -6,7 +6,7 @@ BEGIN {
     require 'test.pl';
 }
 use warnings;
-plan( tests => 176 );
+plan( tests => 177 );
 
 # these shouldn't hang
 {
@@ -119,6 +119,10 @@ cmp_ok("@b",'eq','1 2 3 4','map then sort');
 cmp_ok("@b",'eq','1 2 3 4','reverse then sort');
 
 
+@b = sort CORE::reverse (4,1,3,2);
+cmp_ok("@b",'eq','1 2 3 4','CORE::reverse then sort');
+
+
 
 sub twoface { no warnings 'redefine'; *twoface = sub { $a <=> $b }; &twoface }
 eval { @b = sort twoface 4,1,3,2 };
diff --git a/toke.c b/toke.c
index 1fdaa7e..d3bc457 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -2129,8 +2129,13 @@ S_force_word(pTHX_ char *start, int token, int check_keyword, int allow_pack, in
        (allow_initial_tick && *s == '\'') )
     {
        s = scan_word(s, PL_tokenbuf, sizeof PL_tokenbuf, allow_pack, &len);
-       if (check_keyword && keyword(PL_tokenbuf, len, 0))
+       if (check_keyword) {
+         char *s2 = PL_tokenbuf;
+         if (allow_pack && len > 6 && strnEQ(s2, "CORE::", 6))
+           s2 += 6, len -= 6;
+         if (keyword(s2, len, 0))
            return start;
+       }
        start_force(PL_curforce);
        if (PL_madskills)
            curmad('X', newSVpvn(start,s-start));