aboutsummaryrefslogtreecommitdiffstats
path: root/awkgram.y
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2012-12-23 15:58:52 +0200
committerArnold D. Robbins <arnold@skeeve.com>2012-12-23 15:58:52 +0200
commitcec0cbdbda6a8b27d3f69eb5e2984d87b55f78fb (patch)
tree61c7c85228cdd11a1df3294b381bebc24341689a /awkgram.y
parented17f7f9d71310c6418ba10a81bb35792f46cb08 (diff)
parentb0648b574c42f1d56253938a46f5299c95eef702 (diff)
downloadegawk-cec0cbdbda6a8b27d3f69eb5e2984d87b55f78fb.tar.gz
egawk-cec0cbdbda6a8b27d3f69eb5e2984d87b55f78fb.tar.bz2
egawk-cec0cbdbda6a8b27d3f69eb5e2984d87b55f78fb.zip
Merge branch 'gawk-4.0-stable'
Diffstat (limited to 'awkgram.y')
-rw-r--r--awkgram.y18
1 files changed, 16 insertions, 2 deletions
diff --git a/awkgram.y b/awkgram.y
index b1574c88..6a707cbc 100644
--- a/awkgram.y
+++ b/awkgram.y
@@ -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 *