diff options
author | Maria Matejka <mq@ucw.cz> | 2023-06-13 11:09:41 +0200 |
---|---|---|
committer | Ondrej Zajicek <santiago@crfreenet.org> | 2023-09-12 15:36:53 +0200 |
commit | 6b95353ebdaa724252492f941ebe75f80e9e545a (patch) | |
tree | 75d59bd4237b9b9ced3ffb26c43c5e8c0203dcfc /conf | |
parent | 51f2e7afaf069508685281e8c1b8bb1ceda79d8f (diff) |
Conf: Allowing conf scope to be explicitly read only
Diffstat (limited to 'conf')
-rw-r--r-- | conf/cf-lex.l | 5 | ||||
-rw-r--r-- | conf/conf.h | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/conf/cf-lex.l b/conf/cf-lex.l index 95237215..8dc0ac89 100644 --- a/conf/cf-lex.l +++ b/conf/cf-lex.l @@ -559,6 +559,9 @@ static inline void cf_swap_soft_scope(struct config *conf); static struct symbol * cf_new_symbol(struct sym_scope *scope, pool *p, struct linpool *lp, const byte *c) { + if (scope->readonly) + cf_error("Unknown symbol %s", c); + struct symbol *s; uint l = strlen(c); @@ -712,6 +715,8 @@ cf_lex_init(int is_cli, struct config *c) sym->class = SYM_KEYWORD; sym->keyword = k; } + + global_root_scope->readonly = 1; } ifs_head = ifs = push_ifs(NULL); diff --git a/conf/conf.h b/conf/conf.h index ec8c97e8..8558fcba 100644 --- a/conf/conf.h +++ b/conf/conf.h @@ -137,9 +137,10 @@ struct sym_scope { HASH(struct symbol) hash; /* Local symbol hash */ uint slots; /* Variable slots */ - byte active; /* Currently entered */ - byte block; /* No independent stack frame */ byte soft_scopes; /* Number of soft scopes above */ + byte active:1; /* Currently entered */ + byte block:1; /* No independent stack frame */ + byte readonly:1; /* Do not add new symbols */ }; extern struct sym_scope *global_root_scope; |