aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew J. Schorr <aschorr@telemetry-investments.com>2013-07-02 15:59:15 -0400
committerAndrew J. Schorr <aschorr@telemetry-investments.com>2013-07-02 15:59:15 -0400
commit6ace1b5a655517a41be7d1633ec7592ad940c0e6 (patch)
treecd58833a4e7482db3544c4df57c0bfa4a893d17b
parenta0d911d5920362982fb6a5c1fa6047c69dc26668 (diff)
downloadegawk-6ace1b5a655517a41be7d1633ec7592ad940c0e6.tar.gz
egawk-6ace1b5a655517a41be7d1633ec7592ad940c0e6.tar.bz2
egawk-6ace1b5a655517a41be7d1633ec7592ad940c0e6.zip
Patch gawkapi flatten_array to pass index values as strings in all cases!
-rw-r--r--ChangeLog10
-rw-r--r--gawkapi.c11
-rw-r--r--gawkapi.h2
3 files changed, 19 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 9719effc..23afe3b5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2013-07-02 Andrew J. Schorr <aschorr@telemetry-investments.com>
+ * gawkapi.h (awk_element_t): Add comment indicating that the array
+ element index will always be a string!
+ * gawkapi.c (api_flatten_array): When converting the index to an awk
+ value, request a string conversion, since we want the indices to
+ appear as strings to the extensions. This makes the call to
+ force_string redundant, since node_to_awk_value does that internally
+ when we request a string.
+
+2013-07-02 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
* eval.c (update_ERRNO_string): Set PROCINFO["errno"] to 0.
* io.c (inrec): Since get_a_record may now return -2, be sure
to throw an error in that case as well.
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);
}
diff --git a/gawkapi.h b/gawkapi.h
index 7bb93037..81217009 100644
--- a/gawkapi.h
+++ b/gawkapi.h
@@ -343,7 +343,7 @@ typedef struct awk_element {
AWK_ELEMENT_DELETE = 1 /* set by extension if
should be deleted */
} flags;
- awk_value_t index;
+ awk_value_t index; /* guaranteed to be a string! */
awk_value_t value;
} awk_element_t;