diff options
author | Andrew J. Schorr <aschorr@telemetry-investments.com> | 2016-12-04 16:38:16 -0500 |
---|---|---|
committer | Andrew J. Schorr <aschorr@telemetry-investments.com> | 2016-12-04 16:38:16 -0500 |
commit | 4a20341b487c17b49fc455ba37df84946eda38a7 (patch) | |
tree | 5c56acdfdf7ef40e9b07865dcf685029731a863c | |
parent | 2b9a30b2ab91ea465a649be0fd0927c2aebc67ff (diff) | |
download | egawk-4a20341b487c17b49fc455ba37df84946eda38a7.tar.gz egawk-4a20341b487c17b49fc455ba37df84946eda38a7.tar.bz2 egawk-4a20341b487c17b49fc455ba37df84946eda38a7.zip |
Minor fixes to fixtype and do_typeof.
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | awk.h | 10 | ||||
-rw-r--r-- | builtin.c | 9 |
3 files changed, 21 insertions, 7 deletions
@@ -1,5 +1,14 @@ 2016-12-04 Andrew J. Schorr <aschorr@telemetry-investments.com> + * awk.h (fixtype): Remove conditional checking if the node type + is Node_val. This is already covered by the assert, and if it's not + true, we have serious bugs. + * builtin.c (do_typeof): Do not treat Node_var the same way as + Node_val, since they are different beasts. In reality, the argument + to this function will never have type Node_var. + +2016-12-04 Andrew J. Schorr <aschorr@telemetry-investments.com> + * gawkapi.h (awk_element_t): Remove obsolete comment claiming that the index will always be a string. (gawk_api_t): Add new api_flatten_array_typed function and indicate @@ -1882,12 +1882,10 @@ static inline NODE * fixtype(NODE *n) { assert(n->type == Node_val); - if (n->type == Node_val) { - if ((n->flags & (NUMCUR|USER_INPUT)) == USER_INPUT) - return force_number(n); - if ((n->flags & INTIND) != 0) - return force_string(n); - } + if ((n->flags & (NUMCUR|USER_INPUT)) == USER_INPUT) + return force_number(n); + if ((n->flags & INTIND) != 0) + return force_string(n); return n; } @@ -3988,7 +3988,6 @@ do_typeof(int nargs) deref = false; break; case Node_val: - case Node_var: switch (fixtype(arg)->flags & (STRING|NUMBER|USER_INPUT|REGEX)) { case STRING: res = "string"; @@ -4017,6 +4016,14 @@ do_typeof(int nargs) res = "untyped"; deref = false; break; + case Node_var: + /* + * Note: this doesn't happen because the function calling code + * in interpret.h pushes Node_var->var_value. + */ + fatal(_("typeof: invalid argument type `%s'"), + nodetype2str(arg->type)); + break; default: fatal(_("typeof: unknown argument type `%s'"), nodetype2str(arg->type)); |