diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2013-07-04 11:58:14 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2013-07-04 11:58:14 +0300 |
commit | 133125e373eebdd96cfe5ed54951d2770c01ef7d (patch) | |
tree | 9dcfe918b9c32eba2108777309a2729c0cf19540 /gawkapi.c | |
parent | 71cc2e70847d5a3b99c249fa609ea6ba8b1a00d6 (diff) | |
download | egawk-133125e373eebdd96cfe5ed54951d2770c01ef7d.tar.gz egawk-133125e373eebdd96cfe5ed54951d2770c01ef7d.tar.bz2 egawk-133125e373eebdd96cfe5ed54951d2770c01ef7d.zip |
Force array indices to be strings in flatten_array API.
Diffstat (limited to 'gawkapi.c')
-rw-r--r-- | gawkapi.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -934,12 +934,17 @@ api_flatten_array(awk_ext_id_t id, for (i = j = 0; i < 2 * array->table_size; i += 2, j++) { NODE *index, *value; - index = force_string(list[i]); + index = list[i]; value = list[i + 1]; /* number or string or subarray */ - /* convert index and value to ext types */ + /* + * Convert index and value to ext types. Force the + * index to be a string, since indices are always + * conceptually strings, regardless of internal optimizations + * to treat them as integers in some cases. + */ if (! node_to_awk_value(index, - & (*data)->elements[j].index, AWK_UNDEFINED)) { + & (*data)->elements[j].index, AWK_STRING)) { fatal(_("api_flatten_array: could not convert index %d\n"), (int) i); } |