diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2012-11-10 21:42:18 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2012-11-10 21:42:18 +0200 |
commit | 2fe4775356a1042a90f0236d69df1d0379b1a9bc (patch) | |
tree | 0987884859894fe9aeba7d6139ee7960987d5a9b /interpret.h | |
parent | a92d9e310f119d61752b38bcb232e0cbe867c34f (diff) | |
download | egawk-2fe4775356a1042a90f0236d69df1d0379b1a9bc.tar.gz egawk-2fe4775356a1042a90f0236d69df1d0379b1a9bc.tar.bz2 egawk-2fe4775356a1042a90f0236d69df1d0379b1a9bc.zip |
Bug fixes for SYMTAB.
Diffstat (limited to 'interpret.h')
-rw-r--r-- | interpret.h | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/interpret.h b/interpret.h index 0a306848..26725a21 100644 --- a/interpret.h +++ b/interpret.h @@ -557,10 +557,26 @@ mod: } DEREF(t2); + /* + * Changing something in FUNCTAB is not allowed. + * + * SYMTAB is a little more messy. Three kinds of values may + * be stored in SYMTAB: + * 1. Variables that don"t yet have a value (Node_var_new) + * 2. Variables that have a value (Node_var) + * 3. Values that awk code stuck into SYMTAB not related to variables (Node_value) + * For 1, since we are giving it a value, we have to change the type to Node_var. + * For 1 and 2, we have to step through the Node_var to get to the value. + * For 3, we just us the value we got from assoc_lookup(), above. + */ if (t1 == func_table) fatal(_("cannot assign to elements of FUNCTAB")); - else if (t1 == symbol_table && (*lhs)->type == Node_var) - lhs = & ((*lhs)->var_value); + else if ( t1 == symbol_table + && ( (*lhs)->type == Node_var + || (*lhs)->type == Node_var_new)) { + (*lhs)->type = Node_var; /* in case was Node_var_new */ + lhs = & ((*lhs)->var_value); /* extra level of indirection */ + } unref(*lhs); *lhs = POP_SCALAR(); |