From 6ace1b5a655517a41be7d1633ec7592ad940c0e6 Mon Sep 17 00:00:00 2001 From: "Andrew J. Schorr" Date: Tue, 2 Jul 2013 15:59:15 -0400 Subject: Patch gawkapi flatten_array to pass index values as strings in all cases! --- gawkapi.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'gawkapi.c') diff --git a/gawkapi.c b/gawkapi.c index 78d6dbe4..3fc23388 100644 --- a/gawkapi.c +++ b/gawkapi.c @@ -936,12 +936,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); } -- cgit v1.2.3