Blame SOURCES/perl-5.16.1-perl-105924-require-1-2.patch

9572a7
From d546938a7c8b111c463b733910db885b24724b42 Mon Sep 17 00:00:00 2001
9572a7
From: Father Chrysostomos <sprout@cpan.org>
9572a7
Date: Thu, 20 Sep 2012 06:24:25 -0700
9572a7
Subject: [PATCH] require 1 << 2
9572a7
MIME-Version: 1.0
9572a7
Content-Type: text/plain; charset=UTF-8
9572a7
Content-Transfer-Encoding: 8bit
9572a7
9572a7
Port to 5.16.1:
9572a7
9572a7
commit c31f6d3b869d78bbd101e694fd3b384b47a77f6d
9572a7
Author: Father Chrysostomos <sprout@cpan.org>
9572a7
Date:   Thu Sep 20 06:24:25 2012 -0700
9572a7
9572a7
    [perl #105924] require 1 << 2
9572a7
9572a7
Setting PL_expect after force_next has no effect, as force_next
9572a7
(called by force_version and force_word) picks up the current value of
9572a7
PL_expect and arranges for it to be reset thereto after the forced
9572a7
token is force-fed to the parser.
9572a7
9572a7
The KEY_require case should be setting PL_expect to XTERM (as it
9572a7
already does) when there is no forced token (version or bareword),
9572a7
because we expect a term after ‘require’, but to XOPERATOR when
9572a7
there is a forced token, because we expect an operator after that
9572a7
forced token.
9572a7
9572a7
Since the PL_expect assignment has no effect after force_next, we can
9572a7
set it to XOPERATOR before calling potentially calling force_next, and
9572a7
then to XTERM afterwards.
9572a7
9572a7
Loop exits had the same bug, so this fixes them all.
9572a7
---
9572a7
 t/base/lex.t | 10 +++++++++-
9572a7
 toke.c       |  6 ++++++
9572a7
 2 files changed, 15 insertions(+), 1 deletion(-)
9572a7
9572a7
diff --git a/t/base/lex.t b/t/base/lex.t
9572a7
index ce16ef1..c2a6cc3 100644
9572a7
--- a/t/base/lex.t
9572a7
+++ b/t/base/lex.t
9572a7
@@ -1,6 +1,6 @@
9572a7
 #!./perl
9572a7
 
9572a7
-print "1..57\n";
9572a7
+print "1..63\n";
9572a7
 
9572a7
 $x = 'x';
9572a7
 
9572a7
@@ -273,3 +273,11 @@ $test++;
9572a7
 @a = (1,2,3);
9572a7
 print "not " unless($a[~~2] == 3);
9572a7
 print "ok 57\n";
9572a7
+
9572a7
+$test = 58;
9572a7
+for(qw< require goto last next redo dump >) {
9572a7
+    eval "sub { $_ foo << 2 }";
9572a7
+    print "not " if $@;
9572a7
+    print "ok ", $test++, " - [perl #105924] $_ WORD << ...\n";
9572a7
+    print "# $@" if $@;
9572a7
+}
9572a7
diff --git a/toke.c b/toke.c
9572a7
index 1d18550..aa2c3b6 100644
9572a7
--- a/toke.c
9572a7
+++ b/toke.c
9572a7
@@ -7344,6 +7344,7 @@ Perl_yylex(pTHX)
9572a7
 	    UNI(OP_DBMCLOSE);
9572a7
 
9572a7
 	case KEY_dump:
9572a7
+	    PL_expect = XOPERATOR;
9572a7
 	    s = force_word(s,WORD,TRUE,FALSE,FALSE);
9572a7
 	    LOOPX(OP_DUMP);
9572a7
 
9572a7
@@ -7476,6 +7477,7 @@ Perl_yylex(pTHX)
9572a7
 	    LOP(OP_GREPSTART, XREF);
9572a7
 
9572a7
 	case KEY_goto:
9572a7
+	    PL_expect = XOPERATOR;
9572a7
 	    s = force_word(s,WORD,TRUE,FALSE,FALSE);
9572a7
 	    LOOPX(OP_GOTO);
9572a7
 
9572a7
@@ -7598,6 +7600,7 @@ Perl_yylex(pTHX)
9572a7
 	    LOP(OP_KILL,XTERM);
9572a7
 
9572a7
 	case KEY_last:
9572a7
+	    PL_expect = XOPERATOR;
9572a7
 	    s = force_word(s,WORD,TRUE,FALSE,FALSE);
9572a7
 	    LOOPX(OP_LAST);
9572a7
 	
9572a7
@@ -7695,6 +7698,7 @@ Perl_yylex(pTHX)
9572a7
 	    OPERATOR(MY);
9572a7
 
9572a7
 	case KEY_next:
9572a7
+	    PL_expect = XOPERATOR;
9572a7
 	    s = force_word(s,WORD,TRUE,FALSE,FALSE);
9572a7
 	    LOOPX(OP_NEXT);
9572a7
 
9572a7
@@ -7880,6 +7884,7 @@ Perl_yylex(pTHX)
9572a7
 
9572a7
 	case KEY_require:
9572a7
 	    s = SKIPSPACE1(s);
9572a7
+	    PL_expect = XOPERATOR;
9572a7
 	    if (isDIGIT(*s)) {
9572a7
 		s = force_version(s, FALSE);
9572a7
 	    }
9572a7
@@ -7911,6 +7916,7 @@ Perl_yylex(pTHX)
9572a7
 	    UNI(OP_RESET);
9572a7
 
9572a7
 	case KEY_redo:
9572a7
+	    PL_expect = XOPERATOR;
9572a7
 	    s = force_word(s,WORD,TRUE,FALSE,FALSE);
9572a7
 	    LOOPX(OP_REDO);
9572a7
 
9572a7
-- 
9572a7
1.7.11.4
9572a7