gawk-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gawk-diffs] [SCM] gawk branch, select, updated. gawk-4.1.0-62-gf0391b8


From: Andrew J. Schorr
Subject: [gawk-diffs] [SCM] gawk branch, select, updated. gawk-4.1.0-62-gf0391b8
Date: Tue, 02 Jul 2013 20:14:03 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".

The branch, select has been updated
       via  f0391b8a4db649853ecc47a10b09d7c4b04330cf (commit)
       via  6ace1b5a655517a41be7d1633ec7592ad940c0e6 (commit)
      from  a0d911d5920362982fb6a5c1fa6047c69dc26668 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=f0391b8a4db649853ecc47a10b09d7c4b04330cf

commit f0391b8a4db649853ecc47a10b09d7c4b04330cf
Author: Andrew J. Schorr <address@hidden>
Date:   Tue Jul 2 16:13:43 2013 -0400

    Patch select to remove support for buggy case where the index had a numeric 
value.

diff --git a/extension/ChangeLog b/extension/ChangeLog
index 6778e2e..efb3824 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -1,5 +1,11 @@
 2013-07-02         Andrew J. Schorr     <address@hidden>
 
+       * select.c (do_select): Now that the API flatten_array call has been
+       patched to ensure that the index values are strings, we can remove
+       the code to check for the AWK_NUMBER case.
+
+2013-07-02         Andrew J. Schorr     <address@hidden>
+
        * select.c (do_select): Do not treat a numeric command value as a
        file descriptor unless the command type is empty.
 
diff --git a/extension/select.c b/extension/select.c
index be17dcf..89dbf6c 100644
--- a/extension/select.c
+++ b/extension/select.c
@@ -238,41 +238,21 @@ do_select(int nargs, awk_value_t *result)
                if (flatten_array(fds[i].array.array_cookie, &fds[i].flat)) {
                        emalloc(fds[i].array2fd, int *, 
fds[i].flat->count*sizeof(int), "select");
                        for (j = 0; j < fds[i].flat->count; j++) {
+                               long x;
                                fds[i].array2fd[j] = -1;
-                               switch (EL.index.val_type) {
-                               case AWK_NUMBER:
-                                       if ((EL.value.val_type == 
AWK_UNDEFINED) || ((EL.value.val_type == AWK_STRING) && ! 
EL.value.str_value.len)) {
-                                               if (EL.index.num_value >= 0)
-                                                       fds[i].array2fd[j] = 
EL.index.num_value;
-                                               if (fds[i].array2fd[j] != 
EL.index.num_value) {
-                                                       fds[i].array2fd[j] = -1;
-                                                       warning(ext_id, 
_("select: invalid numeric index `%g' in `%s' array (should be a non-negative 
integer)"), EL.index.num_value, argname[i]);
-                                               }
-                                       }
+                               /* note: the index is always delivered as a 
string */
+
+                               if (((EL.value.val_type == AWK_UNDEFINED) || 
((EL.value.val_type == AWK_STRING) && ! EL.value.str_value.len)) && 
(integer_string(EL.index.str_value.str, &x) == 0) && (x >= 0))
+                                       fds[i].array2fd[j] = x;
+                               else if (EL.value.val_type == AWK_STRING) {
+                                       const awk_input_buf_t *buf;
+                                       if ((buf = 
get_file(EL.index.str_value.str, EL.index.str_value.len, 
EL.value.str_value.str, EL.value.str_value.len)) != NULL)
+                                               fds[i].array2fd[j] = buf->fd;
                                        else
-                                               warning(ext_id, _("select: 
numeric index `%g' in `%s' array should have an empty command type to be 
treated as a file descriptor"), EL.index.num_value, argname[i]);
-                                       break;
-                               case AWK_STRING:
-                                       {
-                                               long x;
-
-                                               if 
((integer_string(EL.index.str_value.str, &x) == 0) && (x >= 0) && 
((EL.value.val_type == AWK_UNDEFINED) || ((EL.value.val_type == AWK_STRING) && 
! EL.value.str_value.len)))
-                                                       fds[i].array2fd[j] = x;
-                                               else if (EL.value.val_type == 
AWK_STRING) {
-                                                       const awk_input_buf_t 
*buf;
-                                                       if ((buf = 
get_file(EL.index.str_value.str, EL.index.str_value.len, 
EL.value.str_value.str, EL.value.str_value.len)) != NULL)
-                                                               
fds[i].array2fd[j] = buf->fd;
-                                                       else
-                                                               warning(ext_id, 
_("select: get_file(`%s', `%s') failed in `%s' array"), EL.index.str_value.str, 
EL.value.str_value.str, argname[i]);
-                                               }
-                                               else
-                                                       warning(ext_id, 
_("select: command type should be a string for `%s' in `%s' array"), 
EL.index.str_value.str, argname[i]);
-                                       }
-                                       break;
-                               default:
-                                       warning(ext_id, _("select: invalid 
index type in `%s' array (must be a string or a non-negative integer"), 
argname[i]);
-                                       break;
+                                               warning(ext_id, _("select: 
get_file(`%s', `%s') failed in `%s' array"), EL.index.str_value.str, 
EL.value.str_value.str, argname[i]);
                                }
+                               else
+                                       warning(ext_id, _("select: command type 
should be a string for `%s' in `%s' array"), EL.index.str_value.str, 
argname[i]);
                                if (fds[i].array2fd[j] < 0) {
                                        update_ERRNO_string(_("select: get_file 
failed"));
                                        if (! 
release_flattened_array(fds[i].array.array_cookie, fds[i].flat))

http://git.sv.gnu.org/cgit/gawk.git/commit/?id=6ace1b5a655517a41be7d1633ec7592ad940c0e6

commit 6ace1b5a655517a41be7d1633ec7592ad940c0e6
Author: Andrew J. Schorr <address@hidden>
Date:   Tue Jul 2 15:59:15 2013 -0400

    Patch gawkapi flatten_array to pass index values as strings in all cases!

diff --git a/ChangeLog b/ChangeLog
index 9719eff..23afe3b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2013-07-02         Andrew J. Schorr     <address@hidden>
 
+       * 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     <address@hidden>
+
        * 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 78d6dbe..3fc2338 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 7bb9303..8121700 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;
 

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog           |   10 ++++++++++
 extension/ChangeLog |    6 ++++++
 extension/select.c  |   44 ++++++++++++--------------------------------
 gawkapi.c           |   11 ++++++++---
 gawkapi.h           |    2 +-
 5 files changed, 37 insertions(+), 36 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

[Prev in Thread] Current Thread [Next in Thread]