Skip to content

Commit

Permalink
WIP - handle ${10} properly - Issue #12948
Browse files Browse the repository at this point in the history
Karl asked me for some help investigating #12948, this is what I came up with.

I have not even run "make test" so likely this is broken in important ways, but
it should be enough of a thread for Karl to pull on that hopefull the whole shirt
comes apart. So to speak. :-)

What it does do is make ${10} parse the same way as $10
  • Loading branch information
demerphq committed Feb 6, 2020
1 parent d130120 commit 129f03f
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions toke.c
Original file line number Diff line number Diff line change
Expand Up @@ -9848,12 +9848,17 @@ S_scan_ident(pTHX_ char *s, char *dest, STRLEN destlen, I32 ck_uni)

if (isSPACE(*s) || !*s)
s = skipspace(s);
if (isDIGIT(*s)) {
while (isDIGIT(*s)) {
if (d >= e)
Perl_croak(aTHX_ "%s", ident_too_long);
*d++ = *s++;
}
if (isDIGIT(*s)) { /* handle $0 and $1 $2 and $10 and etc */
if (*s == '0') {
/* the only digit var that starts with '0' is $0 */
*d++ = *s++;
} else {
do {
if (d >= e)
Perl_croak(aTHX_ "%s", ident_too_long);
*d++ = *s++;
} while (isDIGIT(*s));
}
}
else { /* See if it is a "normal" identifier */
parse_ident(&s, &d, e, 1, is_utf8, FALSE, TRUE);
Expand Down Expand Up @@ -9905,6 +9910,15 @@ S_scan_ident(pTHX_ char *s, char *dest, STRLEN destlen, I32 ck_uni)
}
else {
*d = *s++;
/* special case to handle ${10}, ${11} the same way we handle ${1} etc */
if (isDIGIT(*d) && *d != '0') {
do {
d++;
if (d >= e)
Perl_croak(aTHX_ "%s", ident_too_long);
*d= *s++;
} while (isDIGIT(*s));
}
d[1] = '\0';
}
}
Expand Down

0 comments on commit 129f03f

Please sign in to comment.