diff options
author | TAKAI Kousuke <62541129+t-a-k@users.noreply.github.com> | 2020-10-22 23:23:57 +0900 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2020-12-07 21:52:14 -0700 |
commit | b728918b483f9049ab74984ee11e359e8a769b08 (patch) | |
tree | 0a3fceb4b3806fc4858d621412559a8146df56ce /toke.c | |
parent | 53443c95ef3bc199725ac4c021e83f6414852f7f (diff) | |
download | perl-b728918b483f9049ab74984ee11e359e8a769b08.tar.gz |
toke.c: Recognize "0odddd" octal literals.
t/base/num.t: Add some test for "0odddd" octals.
Diffstat (limited to 'toke.c')
-rw-r--r-- | toke.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -11366,7 +11366,7 @@ Perl_scan_str(pTHX_ char *start, int keep_bracketed_quoted, int keep_delims, int \d(_?\d)*(\.(\d(_?\d)*)?)?[Ee][\+\-]?(\d(_?\d)*) 12 12.34 12. \.\d(_?\d)*[Ee][\+\-]?(\d(_?\d)*) .34 0b[01](_?[01])* binary integers - 0[0-7](_?[0-7])* octal integers + 0o?[0-7](_?[0-7])* octal integers 0x[0-9A-Fa-f](_?[0-9A-Fa-f])* hexadecimal integers 0x[0-9A-Fa-f](_?[0-9A-Fa-f])*(?:\.\d*)?p[+-]?[0-9]+ hexadecimal floats @@ -11478,6 +11478,10 @@ Perl_scan_num(pTHX_ const char *start, YYSTYPE* lvalp) else { shift = 3; s++; + if (isALPHA_FOLD_EQ(*s, 'o')) { + s++; + just_zero = FALSE; + } } if (*s == '_') { @@ -11755,8 +11759,8 @@ Perl_scan_num(pTHX_ const char *start, YYSTYPE* lvalp) } } - if (shift != 3 && !has_digs) { - /* 0x or 0b with no digits, treat it as an error. + if (!just_zero && !has_digs) { + /* 0x, 0o or 0b with no digits, treat it as an error. Originally this backed up the parse before the b or x, but that has the potential for silent changes in behaviour, like for: "0x.3" and "0x+$foo". @@ -11766,7 +11770,7 @@ Perl_scan_num(pTHX_ const char *start, YYSTYPE* lvalp) if (*d) ++d; /* so the user sees the bad non-digit */ PL_bufptr = (char *)d; /* so yyerror reports the context */ yyerror(Perl_form(aTHX_ "No digits found for %s literal", - shift == 4 ? "hexadecimal" : "binary")); + base)); PL_bufptr = oldbp; } |