aboutsummaryrefslogtreecommitdiffstats
path: root/src/bc_lex.c
diff options
context:
space:
mode:
authorGavin Howard <gavin@yzena.com>2021-07-22 13:58:12 -0600
committerGavin Howard <gavin@yzena.com>2021-07-22 13:58:12 -0600
commita554a391b10473a1fcc9feec8b210c05b02d9b94 (patch)
tree9e5ecc55c38e9b1d0a2d22f1a51f517782aeffaf /src/bc_lex.c
parent6e46f47b0a0838afd8615296f73517cc1c7b7f53 (diff)
downloadplatform_external_bc-a554a391b10473a1fcc9feec8b210c05b02d9b94.tar.gz
platform_external_bc-a554a391b10473a1fcc9feec8b210c05b02d9b94.tar.bz2
platform_external_bc-a554a391b10473a1fcc9feec8b210c05b02d9b94.zip
Fix the problem where keywords can be redefined for builtin libs
Signed-off-by: Gavin Howard <gavin@yzena.com>
Diffstat (limited to 'src/bc_lex.c')
-rw-r--r--src/bc_lex.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/bc_lex.c b/src/bc_lex.c
index c33052de..cdbdf24b 100644
--- a/src/bc_lex.c
+++ b/src/bc_lex.c
@@ -61,10 +61,11 @@ static void bc_lex_identifier(BcLex *l) {
if (!strncmp(buf, kw->name, n) && !isalnum(buf[n]) && buf[n] != '_') {
- // If the keyword has been redefined, break out of the loop and use
- // it as a name. This depends on the parser ensuring that only
- // non-POSIX keywords get redefined.
- if (vm.redefined_kws[i]) break;
+ // If the keyword has been redefined, and redefinition is allowed
+ // (it is not allowed for builtin libraries), break out of the loop
+ // and use it as a name. This depends on the argument parser to
+ // ensure that only non-POSIX keywords get redefined.
+ if (!vm.no_redefine && vm.redefined_kws[i]) break;
l->t = BC_LEX_KW_AUTO + (BcLexType) i;