autoquote barewords followed by newline and arrow properly
Gurusamy Sarathy [Thu, 27 Apr 2000 21:07:29 +0000 (21:07 +0000)]
(variant of fix suggested by Rick Delaney and M.J.T. Guy)

p4raw-id: //depot/perl@5977

t/pragma/warn/toke
toke.c

index 5aeef82..f001ff7 100644 (file)
@@ -290,6 +290,9 @@ Can't use \1 to mean $1 in expression at - line 4.
 # toke.c
 use warnings 'reserved' ;
 $a = abc;
+$a = { def
+
+=> 1 };
 no warnings 'reserved' ;
 $a = abc;
 EXPECT
diff --git a/toke.c b/toke.c
index 2035c3f..7d4e937 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -3619,7 +3619,7 @@ Perl_yylex(pTHX)
        tmp = keyword(PL_tokenbuf, len);
 
        /* Is this a word before a => operator? */
-       if (strnEQ(d,"=>",2)) {
+       if (*d == '=' && d[1] == '>') {
            CLINE;
            yylval.opval = (OP*)newSVOP(OP_CONST, 0, newSVpv(PL_tokenbuf,0));
            yylval.opval->op_private = OPpCONST_BARE;
@@ -3774,10 +3774,18 @@ Perl_yylex(pTHX)
                    }
                }
 
-               /* If followed by a paren, it's certainly a subroutine. */
 
                PL_expect = XOPERATOR;
                s = skipspace(s);
+
+               /* Is this a word before a => operator? */
+               if (*s == '=' && s[1] == '>') {
+                   CLINE;
+                   sv_setpv(((SVOP*)yylval.opval)->op_sv, PL_tokenbuf);
+                   TERM(WORD);
+               }
+
+               /* If followed by a paren, it's certainly a subroutine. */
                if (*s == '(') {
                    CLINE;
                    if (gv && GvCVu(gv)) {