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-185


From: Andrew J. Schorr
Subject: [gawk-diffs] [SCM] gawk branch, feature/fixtype, updated. gawk-4.1.0-1854-g2d2744e
Date: Mon, 20 Jun 2016 14:10:56 +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  2d2744ec74076d29e94a2a004e308f73a86b9fa5 (commit)
      from  239d7cc07ec54ec7a69805f9a674bfbbbd72f9b1 (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=2d2744ec74076d29e94a2a004e308f73a86b9fa5

commit 2d2744ec74076d29e94a2a004e308f73a86b9fa5
Author: Andrew J. Schorr <address@hidden>
Date:   Mon Jun 20 10:10:30 2016 -0400

    Call fixtype in a few more places to make sure we check types properly.

diff --git a/ChangeLog b/ChangeLog
index 796dc9c..2d0ca88 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2016-06-20         Andrew J. Schorr     <address@hidden>
+
+       * builtin.c (do_strftime): Call fixtype before checking flags for
+       STRING type.
+       (do_print): Call fixtype before checking whether argument is a NUMBER.
+       * eval.c (set_BINMODE): Call fixtype before checking value type.
+       No need to call force_number if the flags say it's a number.
+       (r_get_field): Fix lint check for non-numeric argument.
+       * io.c (redirect): Call fixtype before checking whether it's a string.
+
 2016-06-18         Andrew J. Schorr     <address@hidden>
 
        * node.c (r_force_number): Fix typo in comment.
diff --git a/builtin.c b/builtin.c
index 7ef5d3a..67b963e 100644
--- a/builtin.c
+++ b/builtin.c
@@ -1915,7 +1915,7 @@ do_strftime(int nargs)
                unref(sub);
 
                if (val != NULL) {
-                       if (do_lint && (val->flags & STRING) == 0)
+                       if (do_lint && (fixtype(val)->flags & STRING) == 0)
                                lintwarn(_("strftime: format value in 
PROCINFO[\"strftime\"] has numeric type"));
                        val = force_string(val);
                        format = val->stptr;
@@ -2197,7 +2197,7 @@ do_print(int nargs, int redirtype)
 
                if (tmp->type == Node_typedregex)
                                args_array[i] = force_string(tmp);
-               else if ((tmp->flags & (NUMBER|STRING)) == NUMBER) {
+               else if ((fixtype(tmp)->flags & (NUMBER|STRING)) == NUMBER) {
                        if (OFMTidx == CONVFMTidx)
                                args_array[i] = force_string(tmp);
                        else
diff --git a/eval.c b/eval.c
index ee67491..d773520 100644
--- a/eval.c
+++ b/eval.c
@@ -712,7 +712,7 @@ set_BINMODE()
 {
        static bool warned = false;
        char *p;
-       NODE *v = BINMODE_node->var_value;
+       NODE *v = fixtype(BINMODE_node->var_value);
 
        if ((do_lint || do_traditional) && ! warned) {
                warned = true;
@@ -721,7 +721,6 @@ set_BINMODE()
        if (do_traditional)
                BINMODE = TEXT_TRANSLATE;
        else if ((v->flags & NUMBER) != 0) {
-               (void) force_number(v);
                BINMODE = get_number_si(v);
                /* Make sure the value is rational. */
                if (BINMODE < TEXT_TRANSLATE)
@@ -1157,7 +1156,7 @@ r_get_field(NODE *n, Func_ptr *assign, bool reference)
        if (assign)
                *assign = NULL;
        if (do_lint) {
-               if ((n->flags & NUMBER) == 0) {
+               if ((fixtype(n)->flags & NUMBER) == 0) {
                        lintwarn(_("attempt to field reference from non-numeric 
value"));
                        if (n->stlen == 0)
                                lintwarn(_("attempt to field reference from 
null string"));
diff --git a/io.c b/io.c
index 94a5dfc..b9bce69 100644
--- a/io.c
+++ b/io.c
@@ -1083,7 +1083,7 @@ redirect_string(const char *str, size_t explen, bool 
not_string,
 struct redirect *
 redirect(NODE *redir_exp, int redirtype, int *errflg, bool failure_fatal)
 {
-       bool not_string = ((redir_exp->flags & STRING) == 0);
+       bool not_string = ((fixtype(redir_exp)->flags & STRING) == 0);
 
        redir_exp = force_string(redir_exp);
        return redirect_string(redir_exp->stptr, redir_exp->stlen, not_string,
diff --git a/test/ChangeLog b/test/ChangeLog
index e667de5..5a57584 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,8 @@
+2016-06-20         Andrew J. Schorr     <address@hidden>
+
+       * Makefile.am (strnum2): New test.
+       * strnum2.awk, strnum2.ok: New files.
+
 2016-06-14         Arnold D. Robbins     <address@hidden>
 
        * Makefile.am (subback): New test.
diff --git a/test/Makefile.am b/test/Makefile.am
index 6c893cc..499107c 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -999,6 +999,8 @@ EXTRA_DIST = \
        strftlng.ok \
        strnum1.awk \
        strnum1.ok \
+       strnum2.awk \
+       strnum2.ok \
        strtod.awk \
        strtod.in \
        strtod.ok \
@@ -1165,7 +1167,7 @@ BASIC_TESTS = \
        reparse resplit rri1 rs rscompat rsnul1nl rsnulbig rsnulbig2 rstest1 
rstest2 \
        rstest3 rstest4 rstest5 rswhite \
        scalar sclforin sclifin sigpipe1 sortempty sortglos splitargv splitarr 
splitdef \
-       splitvar splitwht strcat1 strnum1 strtod subamp subback subi18n \
+       splitvar splitwht strcat1 strnum1 strnum2 strtod subamp subback subi18n 
\
        subsepnm subslash substr swaplns synerr1 synerr2 tradanch tweakfld \
        uninit2 uninit3 uninit4 uninit5 uninitialized unterm uparrfs \
        wideidx wideidx2 widesub widesub2 widesub3 widesub4 wjposer1 \
diff --git a/test/strnum2.awk b/test/strnum2.awk
new file mode 100644
index 0000000..16e6f5d
--- /dev/null
+++ b/test/strnum2.awk
@@ -0,0 +1,10 @@
+BEGIN {
+       split("1.234", f)
+       OFMT = "%.1f"
+       # check whether strnum is displayed the same way before and
+       # after force_number is called. Also, should numeric strings
+       # be formatted with OFMT or show the original string value?
+       print f[1]
+       x = f[1]+0      # trigger conversion to NUMBER
+       print f[1]
+}
diff --git a/test/strnum2.ok b/test/strnum2.ok
new file mode 100644
index 0000000..f5103ca
--- /dev/null
+++ b/test/strnum2.ok
@@ -0,0 +1,2 @@
+1.2
+1.2

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

Summary of changes:
 ChangeLog        |   10 ++++++++++
 builtin.c        |    4 ++--
 eval.c           |    5 ++---
 io.c             |    2 +-
 test/ChangeLog   |    5 +++++
 test/Makefile.am |    4 +++-
 test/strnum2.awk |   10 ++++++++++
 test/strnum2.ok  |    2 ++
 8 files changed, 35 insertions(+), 7 deletions(-)
 create mode 100644 test/strnum2.awk
 create mode 100644 test/strnum2.ok


hooks/post-receive
-- 
gawk



reply via email to

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