diff options
Diffstat (limited to 'awkgram.y')
-rw-r--r-- | awkgram.y | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -57,6 +57,7 @@ static int include_source(INSTRUCTION *file); static int load_library(INSTRUCTION *file); static void next_sourcefile(void); static char *tokexpand(void); +static bool is_deferred_variable(const char *name); #define instruction(t) bcalloc(t, 1, 0) @@ -1873,7 +1874,7 @@ static const struct token tokentab[] = { {"gsub", Op_sub_builtin, LEX_BUILTIN, NOT_OLD|A(2)|A(3), 0, 0}, {"if", Op_K_if, LEX_IF, 0, 0, 0}, {"in", Op_symbol, LEX_IN, 0, 0, 0}, -{"include", Op_symbol, LEX_INCLUDE, GAWKX, 0, 0}, +{"include", Op_symbol, LEX_INCLUDE, GAWKX, 0, 0}, {"index", Op_builtin, LEX_BUILTIN, A(2), do_index, 0}, {"int", Op_builtin, LEX_BUILTIN, A(1), do_int, MPF(int)}, {"isarray", Op_builtin, LEX_BUILTIN, GAWKX|A(1), do_isarray, 0}, @@ -4192,7 +4193,7 @@ install_function(char *fname, INSTRUCTION *fi, INSTRUCTION *plist) int pcount = 0; r = lookup(fname); - if (r != NULL) { + if (r != NULL || is_deferred_variable(fname)) { error_ln(fi->source_line, _("function name `%s' previously defined"), fname); return -1; } @@ -4422,6 +4423,19 @@ register_deferred_variable(const char *name, NODE *(*load_func)(void)) deferred_variables = dv; } +/* is_deferred_variable --- check if NAME is a deferred variable */ + +static bool +is_deferred_variable(const char *name) +{ + struct deferred_variable *dv; + for (dv = deferred_variables; dv != NULL; dv = dv->next) + if (strcmp(name, dv->name) == 0) + return true; + return false; +} + + /* variable --- make sure NAME is in the symbol table */ NODE * |