From: Gurusamy Sarathy Date: Thu, 27 Apr 2000 21:07:29 +0000 (+0000) Subject: autoquote barewords followed by newline and arrow properly X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1c3923b3a96ff7f6cc3c12f9f8554b36d12daf1b;p=p5sagit%2Fp5-mst-13.2.git autoquote barewords followed by newline and arrow properly (variant of fix suggested by Rick Delaney and M.J.T. Guy) p4raw-id: //depot/perl@5977 --- diff --git a/t/pragma/warn/toke b/t/pragma/warn/toke index 5aeef82..f001ff7 100644 --- a/t/pragma/warn/toke +++ b/t/pragma/warn/toke @@ -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 --- 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)) {