gawk-diffs
[Top][All Lists]
Advanced

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

[gawk-diffs] [SCM] gawk branch, feature/fixtype, updated. gawk-4.1.0-181


From: Andrew J. Schorr
Subject: [gawk-diffs] [SCM] gawk branch, feature/fixtype, updated. gawk-4.1.0-1818-g5826bee
Date: Tue, 14 Jun 2016 20:36:09 +0000 (UTC)

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, feature/fixtype has been updated
       via  5826beec258141776469c5fd9b703d52c81a35fb (commit)
      from  56b1798777fe5464014fca3f9744ebdb950b8348 (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=5826beec258141776469c5fd9b703d52c81a35fb

commit 5826beec258141776469c5fd9b703d52c81a35fb
Author: Andrew J. Schorr <address@hidden>
Date:   Tue Jun 14 16:35:48 2016 -0400

    Add a new boolval function to awk.h to make sure we handle this 
consistently.

diff --git a/ChangeLog b/ChangeLog
index 87ea189..2f4631f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2016-06-14         Andrew J. Schorr     <address@hidden>
 
+       * awk.h (boolval): New inline function to standardize testing whether
+       a node's value is true.
+       * builtin.c (do_strftime): Use boolval to handle 3rd argument.
+       * eval.c (set_IGNORECASE, eval_condition): Use new boolval function.
+       * io.c (pty_vs_pipe): Use new boolval function.
+
+2016-06-14         Andrew J. Schorr     <address@hidden>
+
        * builtin.c (do_strftime): Fix handling of 3rd argument to work
        as a standard boolean: non-null or non-zero.
 
diff --git a/awk.h b/awk.h
index 0cbcf04..0a7059b 100644
--- a/awk.h
+++ b/awk.h
@@ -1843,6 +1843,19 @@ fixtype(NODE *n)
        return n;
 }
 
+/*
+ * In `awk', a value is considered to be true if it is nonzero _or_
+ * non-null. Otherwise, the value is false.
+ */
+static inline int
+boolval(NODE *t)
+{
+       (void) fixtype(t);
+       if ((t->flags & NUMBER) != 0)
+               return ! iszero(t);
+       return (t->stlen > 0);
+}
+
 static inline void *
 emalloc_real(size_t count, const char *where, const char *var, const char 
*file, int line)
 {
diff --git a/builtin.c b/builtin.c
index ede0247..4d9e145 100644
--- a/builtin.c
+++ b/builtin.c
@@ -1928,11 +1928,8 @@ do_strftime(int nargs)
                NODE *tmp;
 
                if (nargs == 3) {
-                       t3 = fixtype(POP_SCALAR());
-                       if ((t3->flags & NUMBER) != 0)
-                               do_gmt = ! iszero(t3);
-                       else
-                               do_gmt = (t3->stlen > 0);
+                       t3 = POP_SCALAR();
+                       do_gmt = boolval(t3);
                        DEREF(t3);
                }
 
diff --git a/eval.c b/eval.c
index 90947dc..ee67491 100644
--- a/eval.c
+++ b/eval.c
@@ -692,7 +692,6 @@ void
 set_IGNORECASE()
 {
        static bool warned = false;
-       NODE *n;
 
        if ((do_lint || do_traditional) && ! warned) {
                warned = true;
@@ -701,13 +700,8 @@ set_IGNORECASE()
        load_casetable();
        if (do_traditional)
                IGNORECASE = false;
-       else {
-               n = fixtype(IGNORECASE_node->var_value);
-               if ((n->flags & NUMBER) != 0)
-                       IGNORECASE = ! iszero(n);
-               else
-                       IGNORECASE = (n->stlen > 0);
-       }
+       else
+               IGNORECASE = boolval(IGNORECASE_node->var_value);
        set_RS();       /* set_RS() calls set_FS() if need be, for us */
 }
 
@@ -1517,12 +1511,7 @@ eval_condition(NODE *t)
        if (t == node_Boolean[true])
                return true;
 
-       (void) fixtype(t);
-
-       if ((t->flags & NUMBER) != 0)
-               return ! iszero(t);
-
-       return (t->stlen != 0);
+       return boolval(t);
 }
 
 /* cmp_scalars -- compare two nodes on the stack */
diff --git a/io.c b/io.c
index 9d827d7..94a5dfc 100644
--- a/io.c
+++ b/io.c
@@ -3895,13 +3895,8 @@ pty_vs_pipe(const char *command)
         * in_PROCINFO function now checks that for us.
         */
        val = in_PROCINFO(command, "pty", NULL);
-       if (val) {
-               val = fixtype(val);
-               if ((val->flags & NUMBER) != 0)
-                       return ! iszero(val);
-               else
-                       return (val->stlen != 0);
-       }
+       if (val)
+               return boolval(val);
 #endif /* HAVE_TERMIOS_H */
        return false;
 }

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

Summary of changes:
 ChangeLog |    8 ++++++++
 awk.h     |   13 +++++++++++++
 builtin.c |    7 ++-----
 eval.c    |   17 +++--------------
 io.c      |    9 ++-------
 5 files changed, 28 insertions(+), 26 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

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