From: Larry Wall Date: Tue, 7 Dec 1999 12:39:30 +0000 (-0800) Subject: patch to fix parser bug in C<${h{${a[0]}}} = 13> X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9059aa122db2d4c1150f251f11957d6ea46db4ae;p=p5sagit%2Fp5-mst-13.2.git patch to fix parser bug in C<${h{${a[0]}}} = 13> Message-Id: <199912072039.MAA13257@kiev.wall.org> Subject: Re: [ID 19991204.002] Inconsistency of ${hash{key}} p4raw-id: //depot/perl@4668 --- diff --git a/embedvar.h b/embedvar.h index 5519520..6611921 100644 --- a/embedvar.h +++ b/embedvar.h @@ -282,7 +282,6 @@ #define PL_lex_defer (PERL_GET_INTERP->Ilex_defer) #define PL_lex_dojoin (PERL_GET_INTERP->Ilex_dojoin) #define PL_lex_expect (PERL_GET_INTERP->Ilex_expect) -#define PL_lex_fakebrack (PERL_GET_INTERP->Ilex_fakebrack) #define PL_lex_formbrack (PERL_GET_INTERP->Ilex_formbrack) #define PL_lex_inpat (PERL_GET_INTERP->Ilex_inpat) #define PL_lex_inwhat (PERL_GET_INTERP->Ilex_inwhat) @@ -548,7 +547,6 @@ #define PL_lex_defer (vTHX->Ilex_defer) #define PL_lex_dojoin (vTHX->Ilex_dojoin) #define PL_lex_expect (vTHX->Ilex_expect) -#define PL_lex_fakebrack (vTHX->Ilex_fakebrack) #define PL_lex_formbrack (vTHX->Ilex_formbrack) #define PL_lex_inpat (vTHX->Ilex_inpat) #define PL_lex_inwhat (vTHX->Ilex_inwhat) @@ -951,7 +949,6 @@ #define PL_lex_defer (aTHXo->interp.Ilex_defer) #define PL_lex_dojoin (aTHXo->interp.Ilex_dojoin) #define PL_lex_expect (aTHXo->interp.Ilex_expect) -#define PL_lex_fakebrack (aTHXo->interp.Ilex_fakebrack) #define PL_lex_formbrack (aTHXo->interp.Ilex_formbrack) #define PL_lex_inpat (aTHXo->interp.Ilex_inpat) #define PL_lex_inwhat (aTHXo->interp.Ilex_inwhat) @@ -1218,7 +1215,6 @@ #define PL_Ilex_defer PL_lex_defer #define PL_Ilex_dojoin PL_lex_dojoin #define PL_Ilex_expect PL_lex_expect -#define PL_Ilex_fakebrack PL_lex_fakebrack #define PL_Ilex_formbrack PL_lex_formbrack #define PL_Ilex_inpat PL_lex_inpat #define PL_Ilex_inwhat PL_lex_inwhat diff --git a/intrpvar.h b/intrpvar.h index 9731bc3..dbf725f 100644 --- a/intrpvar.h +++ b/intrpvar.h @@ -237,7 +237,6 @@ PERLVAR(Ilex_defer, U32) /* state after determined token */ PERLVAR(Ilex_expect, expectation) /* expect after determined token */ PERLVAR(Ilex_brackets, I32) /* bracket count */ PERLVAR(Ilex_formbrack, I32) /* bracket count at outer format level */ -PERLVAR(Ilex_fakebrack, I32) /* outer bracket is mere delimiter */ PERLVAR(Ilex_casemods, I32) /* casemod count */ PERLVAR(Ilex_dojoin, I32) /* doing an array interpolation */ PERLVAR(Ilex_starts, I32) /* how many interps done on level */ diff --git a/objXSUB.h b/objXSUB.h index e9e9114..d57bb10 100644 --- a/objXSUB.h +++ b/objXSUB.h @@ -230,8 +230,6 @@ #define PL_lex_dojoin (*Perl_Ilex_dojoin_ptr(aTHXo)) #undef PL_lex_expect #define PL_lex_expect (*Perl_Ilex_expect_ptr(aTHXo)) -#undef PL_lex_fakebrack -#define PL_lex_fakebrack (*Perl_Ilex_fakebrack_ptr(aTHXo)) #undef PL_lex_formbrack #define PL_lex_formbrack (*Perl_Ilex_formbrack_ptr(aTHXo)) #undef PL_lex_inpat diff --git a/sv.c b/sv.c index 20aa1b0..fddcd7e 100644 --- a/sv.c +++ b/sv.c @@ -6871,7 +6871,6 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags, PL_lex_defer = proto_perl->Ilex_defer; PL_lex_expect = proto_perl->Ilex_expect; PL_lex_formbrack = proto_perl->Ilex_formbrack; - PL_lex_fakebrack = proto_perl->Ilex_fakebrack; PL_lex_dojoin = proto_perl->Ilex_dojoin; PL_lex_starts = proto_perl->Ilex_starts; PL_lex_stuff = sv_dup_inc(proto_perl->Ilex_stuff); diff --git a/toke.c b/toke.c index 9f3f3a1..2acfec9 100644 --- a/toke.c +++ b/toke.c @@ -29,6 +29,9 @@ static char ident_too_long[] = "Identifier too long"; static void restore_rsfp(pTHXo_ void *f); +#define XFAKEBRACK 128 +#define XENUMMASK 127 + #define UTF (PL_hints & HINT_UTF8) /* * Note: we try to be careful never to call the isXXX_utf8() functions @@ -358,7 +361,6 @@ Perl_lex_start(pTHX_ SV *line) SAVEI32(PL_lex_dojoin); SAVEI32(PL_lex_brackets); - SAVEI32(PL_lex_fakebrack); SAVEI32(PL_lex_casemods); SAVEI32(PL_lex_starts); SAVEI32(PL_lex_state); @@ -385,7 +387,6 @@ Perl_lex_start(pTHX_ SV *line) PL_lex_defer = 0; PL_expect = XSTATE; PL_lex_brackets = 0; - PL_lex_fakebrack = 0; New(899, PL_lex_brackstack, 120, char); New(899, PL_lex_casestack, 12, char); SAVEFREEPV(PL_lex_brackstack); @@ -961,7 +962,6 @@ S_sublex_push(pTHX) PL_lex_state = PL_sublex_info.super_state; SAVEI32(PL_lex_dojoin); SAVEI32(PL_lex_brackets); - SAVEI32(PL_lex_fakebrack); SAVEI32(PL_lex_casemods); SAVEI32(PL_lex_starts); SAVEI32(PL_lex_state); @@ -986,7 +986,6 @@ S_sublex_push(pTHX) PL_lex_dojoin = FALSE; PL_lex_brackets = 0; - PL_lex_fakebrack = 0; New(899, PL_lex_brackstack, 120, char); New(899, PL_lex_casestack, 12, char); SAVEFREEPV(PL_lex_brackstack); @@ -1034,7 +1033,6 @@ S_sublex_done(pTHX) SAVEFREESV(PL_linestr); PL_lex_dojoin = FALSE; PL_lex_brackets = 0; - PL_lex_fakebrack = 0; PL_lex_casemods = 0; *PL_lex_casestack = '\0'; PL_lex_starts = 0; @@ -2976,7 +2974,8 @@ Perl_yylex(pTHX) PL_lex_formbrack = 0; if (PL_lex_state == LEX_INTERPNORMAL) { if (PL_lex_brackets == 0) { - if (PL_lex_fakebrack) { + if (PL_expect & XFAKEBRACK) { + PL_expect &= XENUMMASK; PL_lex_state = LEX_INTERPEND; PL_bufptr = s; return yylex(); /* ignore fake brackets */ @@ -2987,9 +2986,9 @@ Perl_yylex(pTHX) PL_lex_state = LEX_INTERPEND; } } - if (PL_lex_brackets < PL_lex_fakebrack) { + if (PL_expect & XFAKEBRACK) { + PL_expect &= XENUMMASK; PL_bufptr = s; - PL_lex_fakebrack = 0; return yylex(); /* ignore fake brackets */ } force_next('}'); @@ -5603,8 +5602,6 @@ S_scan_ident(pTHX_ register char *s, register char *send, char *dest, STRLEN des char *bracket = 0; char funny = *s++; - if (PL_lex_brackets == 0) - PL_lex_fakebrack = 0; if (isSPACE(*s)) s = skipspace(s); d = dest; @@ -5709,9 +5706,8 @@ S_scan_ident(pTHX_ register char *s, register char *send, char *dest, STRLEN des "Ambiguous use of %c{%s%s} resolved to %c%s%s", funny, dest, brack, funny, dest, brack); } - PL_lex_fakebrack = PL_lex_brackets+1; bracket++; - PL_lex_brackstack[PL_lex_brackets++] = XOPERATOR; + PL_lex_brackstack[PL_lex_brackets++] = XOPERATOR | XFAKEBRACK; return s; } }