diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2016-05-26 16:28:08 -0400 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2016-05-26 16:28:08 -0400 |
commit | 33ffd32ea8ea143a210fef2181a804ee0c70cdfb (patch) | |
tree | 00047e89140f0075084957e297baabad107f1a6d /str_array.c | |
parent | 01e482c9f36b34fe03bff724bb3079d86f1c4625 (diff) | |
parent | 4d634960a411622cfb2e757d8e98c84f7601e09e (diff) | |
download | egawk-33ffd32ea8ea143a210fef2181a804ee0c70cdfb.tar.gz egawk-33ffd32ea8ea143a210fef2181a804ee0c70cdfb.tar.bz2 egawk-33ffd32ea8ea143a210fef2181a804ee0c70cdfb.zip |
Merge branch 'master' into feature/cmake
Diffstat (limited to 'str_array.c')
-rw-r--r-- | str_array.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/str_array.c b/str_array.c index c122ab94..7a6b50fe 100644 --- a/str_array.c +++ b/str_array.c @@ -156,7 +156,18 @@ str_lookup(NODE *symbol, NODE *subs) hash1 = code1 % (unsigned long) symbol->array_size; } - if (subs->stfmt != -1) { + + /* + * Repeat after me: "Array indices are always strings." + * "Array indices are always strings." + * "Array indices are always strings." + * "Array indices are always strings." + * .... + * If subs is a STRNUM, copy it; don't clear the MAYBE_NUM + * flag on it since other variables could be using the same + * reference-counted value. + */ + if (subs->stfmt != -1 || (subs->flags & MAYBE_NUM) != 0) { NODE *tmp; /* @@ -187,14 +198,7 @@ str_lookup(NODE *symbol, NODE *subs) subs = dupnode(subs); } - /* - * Repeat after me: "Array indices are always strings." - * "Array indices are always strings." - * "Array indices are always strings." - * "Array indices are always strings." - * .... - */ - subs->flags &= ~MAYBE_NUM; + assert((subs->flags & MAYBE_NUM) == 0); getbucket(b); b->ahnext = symbol->buckets[hash1]; |