aboutsummaryrefslogtreecommitdiffstats
path: root/symbol.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2013-01-22 20:36:43 +0200
committerArnold D. Robbins <arnold@skeeve.com>2013-01-22 20:36:43 +0200
commit76d9cad48102984af70a1b6a202abb966b75aa22 (patch)
tree5d021f683e520f0d64abbe82a2f9ce8684cb4502 /symbol.c
parent28d9143e9b98728450f5db7b2244f99768de399f (diff)
downloadegawk-76d9cad48102984af70a1b6a202abb966b75aa22.tar.gz
egawk-76d9cad48102984af70a1b6a202abb966b75aa22.tar.bz2
egawk-76d9cad48102984af70a1b6a202abb966b75aa22.zip
Bug fix for -d with -i.
Diffstat (limited to 'symbol.c')
-rw-r--r--symbol.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/symbol.c b/symbol.c
index 4ff9c78a..c775c931 100644
--- a/symbol.c
+++ b/symbol.c
@@ -376,13 +376,20 @@ get_symbols(SYMBOL_TYPE what, int sort)
long max;
NODE *the_table;
+ /*
+ * assoc_list() returns an array with two elements per awk array
+ * element. Elements i and i+1 in the C array represent the key
+ * and value of element j in the awk array. Thus the loops use += 2
+ * to go through the awk array.
+ */
+
if (what == FUNCTION) {
count = func_count;
the_table = func_table;
max = the_table->table_size * 2;
list = assoc_list(the_table, "@unsorted", ASORTI);
- emalloc(table, NODE **, (count + 1) * sizeof(NODE *), "symbol_list");
+ emalloc(table, NODE **, (count + 1) * sizeof(NODE *), "get_symbols");
for (i = j = 0; i < max; i += 2) {
r = list[i+1];
@@ -391,6 +398,7 @@ get_symbols(SYMBOL_TYPE what, int sort)
assert(r->type == Node_func);
table[j++] = r;
}
+ count = j;
} else { /* what == VARIABLE */
the_table = symbol_table;
count = var_count;
@@ -399,7 +407,7 @@ get_symbols(SYMBOL_TYPE what, int sort)
max = the_table->table_size * 2;
list = assoc_list(the_table, "@unsorted", ASORTI);
- emalloc(table, NODE **, (count + 1) * sizeof(NODE *), "symbol_list");
+ emalloc(table, NODE **, (count + 1) * sizeof(NODE *), "get_symbols");
for (i = j = 0; i < max; i += 2) {
r = list[i+1];
@@ -407,6 +415,7 @@ get_symbols(SYMBOL_TYPE what, int sort)
continue;
table[j++] = r;
}
+ count = j;
}
efree(list);