diff --git a/embed.fnc b/embed.fnc index 60edc5d79f..ac75fd06b0 100644 --- a/embed.fnc +++ b/embed.fnc @@ -6179,9 +6179,8 @@ So |SV * |new_constant |NULLOK const char *s \ S |void |parse_ident |NN char **s \ |SPTR char **d \ |EPTR char * const e \ - |int allow_package \ |bool is_utf8 \ - |bool check_dollar + |U32 flags S |int |pending_ident RS |char * |scan_const |NN char *start RS |char * |scan_formline |NN char *s diff --git a/embed.h b/embed.h index 7771d44b3b..2690fa3b31 100644 --- a/embed.h +++ b/embed.h @@ -1688,7 +1688,7 @@ # define is_existing_identifier(a,b,c,d) S_is_existing_identifier(aTHX_ a,b,c,d) # define lop(a,b,c,d) S_lop(aTHX_ a,b,c,d) # define missingterm(a,b) S_missingterm(aTHX_ a,b) -# define parse_ident(a,b,c,d,e,f) S_parse_ident(aTHX_ a,b,c,d,e,f) +# define parse_ident(a,b,c,d,e) S_parse_ident(aTHX_ a,b,c,d,e) # define pending_ident() S_pending_ident(aTHX) # define scan_const(a) S_scan_const(aTHX_ a) # define scan_formline(a) S_scan_formline(aTHX_ a) diff --git a/proto.h b/proto.h index 30fab02161..40bc1b0013 100644 --- a/proto.h +++ b/proto.h @@ -9467,7 +9467,7 @@ S_new_constant(pTHX_ const char *s, STRLEN len, const char *key, STRLEN keylen, assert(key); assert(sv) STATIC void -S_parse_ident(pTHX_ char **s, char **d, char * const e, int allow_package, bool is_utf8, bool check_dollar); +S_parse_ident(pTHX_ char **s, char **d, char * const e, bool is_utf8, U32 flags); # define PERL_ARGS_ASSERT_PARSE_IDENT \ assert(s); assert(d); assert(*d); assert(e); assert(*d < e) diff --git a/toke.c b/toke.c index f8e8f294e3..dad79280ac 100644 --- a/toke.c +++ b/toke.c @@ -176,6 +176,7 @@ static const char ident_var_zero_multi_digit[] = "Numeric variables with more th /* Bits in the flags parameter of various functions */ #define CHECK_KEYWORD (1 << 0) #define ALLOW_PACKAGE (1 << 1) +#define CHECK_DOLLAR (1 << 2) #ifdef DEBUGGING static const char* const lex_state_names[] = { @@ -5503,8 +5504,7 @@ yyl_sigvar(pTHX_ char *s) char *dest = PL_tokenbuf + 1; /* read var name, including sigil, into PL_tokenbuf */ PL_tokenbuf[0] = sigil; - parse_ident(&s, &dest, C_ARRAY_END(PL_tokenbuf), - 0, cBOOL(UTF), FALSE); + parse_ident(&s, &dest, C_ARRAY_END(PL_tokenbuf), cBOOL(UTF), 0); *dest = '\0'; assert(PL_tokenbuf[1]); /* we have a variable name */ } @@ -10538,8 +10538,8 @@ S_new_constant(pTHX_ const char *s, STRLEN len, const char *key, STRLEN keylen, } STATIC void -S_parse_ident(pTHX_ char **s, char **d, char * const e, int allow_package, - bool is_utf8, bool check_dollar) +S_parse_ident(pTHX_ char **s, char **d, char * const e, bool is_utf8, + U32 flags) { PERL_ARGS_ASSERT_PARSE_IDENT; assert(*s <= PL_bufend); @@ -10565,10 +10565,12 @@ S_parse_ident(pTHX_ char **s, char **d, char * const e, int allow_package, * variable path. Each iteration of the loop below picks up one segment * of the path. If the apostrophe is allowed as a package separator, it * is converted to "::", so later code doesn't have to concern itself with - * this possibility. - * - * 'check_dollar' is used to look for and stop parsing before the dollar + * this possibility. */ + const bool allow_package = flags & ALLOW_PACKAGE; + + /* 'check_dollar' is used to look for and stop parsing before the dollar * in things like Foo::$bar */ + const bool check_dollar = flags & CHECK_DOLLAR; while (*s < PL_bufend) { if (*d >= e) @@ -10642,7 +10644,8 @@ Perl_scan_word(pTHX_ char *s, char *dest, STRLEN destlen, int allow_package, STR char * const e = d + destlen - 3; /* two-character token, ending NUL */ bool is_utf8 = cBOOL(UTF); - parse_ident(&s, &d, e, allow_package, is_utf8, TRUE); + parse_ident(&s, &d, e, is_utf8, + (CHECK_DOLLAR | ((allow_package) ? ALLOW_PACKAGE : 0))); *d = '\0'; *slp = d - dest; return s; @@ -10683,7 +10686,7 @@ S_scan_ident(pTHX_ char *s, char *dest, char *dest_end, bool chk_unary) croak(ident_var_zero_multi_digit); } else { /* See if it is a "normal" identifier */ - parse_ident(&s, &d, e, 1, is_utf8, FALSE); + parse_ident(&s, &d, e, is_utf8, ALLOW_PACKAGE); } *d = '\0'; d = dest; @@ -10804,7 +10807,8 @@ S_scan_ident(pTHX_ char *s, char *dest, char *dest_end, bool chk_unary) (the later check for } being at the expected point will trap cases where this doesn't pan out.) */ d += advance; - parse_ident(&s, &d, e, 1, is_utf8, TRUE); + parse_ident(&s, &d, e, is_utf8, ( ALLOW_PACKAGE + |CHECK_DOLLAR)); *d = '\0'; } else { /* caret word: ${^Foo} ${^CAPTURE[0]} */