diff options
author | Brian Fraser <fraserbn@gmail.com> | 2013-03-14 21:05:23 -0300 |
---|---|---|
committer | Karl Williamson <public@khwilliamson.com> | 2013-03-15 13:48:41 -0600 |
commit | a21046adfc98d4af022406a8e4bb48fecec7749c (patch) | |
tree | f47e2a6dd54c8e22d17b88959d0f4a0da9412bdc | |
parent | 1bd59f2c8b61c62045c3168ba7470136f276702d (diff) | |
download | perl-a21046adfc98d4af022406a8e4bb48fecec7749c.tar.gz |
toke.c, S_scan_ident: Ignore whitespace on both sides of ${ ... }
${ var } (and ${ \7LOBAL_PHASE}) were broken by 32833930e. However,
it turns out that the behavior prior to that commit was already
strange:
${ .}; # Legal
${. }; # Illegal
${ . }; # Illegal
${ \7LOBAL_PHASE}; # Legal
${ ^GLOBAL_PHASE}; # Illegal
${^GLOBAL_PHASE }; # Illegal
This commit restores ${ var } and makes all of the above work by
always ignoring spaces on both sides of ${ ... }.
-rw-r--r-- | t/uni/variables.t | 28 | ||||
-rw-r--r-- | toke.c | 15 |
2 files changed, 33 insertions, 10 deletions
diff --git a/t/uni/variables.t b/t/uni/variables.t index 9a469d6e42..cee681fd08 100644 --- a/t/uni/variables.t +++ b/t/uni/variables.t @@ -12,7 +12,7 @@ use utf8; use open qw( :utf8 :std ); no warnings qw(misc reserved); -plan (tests => 65856); +plan (tests => 65869); # ${single:colon} should not be valid syntax { @@ -201,3 +201,29 @@ EOP ); } } + +{ + # bleadperl v5.17.9-109-g3283393 breaks JEREMY/File-Signature-1.009.tar.gz + # https://rt.perl.org/rt3/Ticket/Display.html?id=117145 + local $@; + my $var = 10; + eval ' ${ var }'; + + is( + $@, + '', + '${ var } works under strict' + ); + + { + no strict; + for my $var ( '$', "\7LOBAL_PHASE", "^GLOBAL_PHASE", "^V" ) { + eval "\${ $var}"; + is($@, '', "\${ $var} works" ); + eval "\${$var }"; + is($@, '', "\${$var } works" ); + eval "\${ $var }"; + is($@, '', "\${ $var } works" ); + } + } +} @@ -9292,6 +9292,8 @@ S_scan_ident(pTHX_ char *s, const char *send, char *dest, STRLEN destlen, I32 ck if (*s == '{') { bracket = s; s++; + while (s < send && SPACE_OR_TAB(*s)) + s++; } #define VALID_LEN_ONE_IDENT(d, u) (isPUNCT_A((U8)*(d)) \ @@ -9320,15 +9322,6 @@ S_scan_ident(pTHX_ char *s, const char *send, char *dest, STRLEN destlen, I32 ck else if (ck_uni && !bracket) check_uni(); if (bracket) { - if (isSPACE(s[-1])) { - while (s < send) { - const char ch = *s++; - if (!SPACE_OR_TAB(ch)) { - *d = ch; - break; - } - } - } if (isIDFIRST_lazy_if(d,is_utf8)) { d += is_utf8 ? UTF8SKIP(d) : 1; parse_ident(&s, &d, e, 1, is_utf8); @@ -9364,6 +9357,10 @@ S_scan_ident(pTHX_ char *s, const char *send, char *dest, STRLEN destlen, I32 ck Perl_croak(aTHX_ "%s", ident_too_long); *d = '\0'; } + + while (s < send && SPACE_OR_TAB(*s)) + s++; + if (*s == '}') { s++; if (PL_lex_state == LEX_INTERPNORMAL && !PL_lex_brackets) { |