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


From: Andrew J. Schorr
Subject: [gawk-diffs] [SCM] gawk branch, feature/fixtype, updated. gawk-4.1.0-1889-gcedd082
Date: Mon, 4 Jul 2016 15:20:57 +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  cedd0829b0075533986fce1e699bc6ae511a891e (commit)
      from  b3fa425feb23dd36e82d4dd71f0bc1e03495a46b (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=cedd0829b0075533986fce1e699bc6ae511a891e

commit cedd0829b0075533986fce1e699bc6ae511a891e
Author: Andrew J. Schorr <address@hidden>
Date:   Mon Jul 4 11:20:07 2016 -0400

    Unify force_string handling of CONVFMT and OFMT.

diff --git a/ChangeLog b/ChangeLog
index feb84d1..2fb4d45 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2016-07-04         Andrew J. Schorr     <address@hidden>
 
+       * awk.h (force_string_fmt): New inline function to get the string
+       representation in a requested format.
+       (force_string): Reimplement as a macro using force_string_fmt function.
+       (force_string_ofmt): New macro to get a value's OFMT representation.
+       * builtin.c (do_print): Use new force_string_ofmt macro instead of
+       duplicating the logic inline.
+
+2016-07-04         Andrew J. Schorr     <address@hidden>
+
        * str_array.c (str_lookup): There is no need to worry about the
        MAYBE_NUM flag, since the code has been patched to make sure to
        preserve the string value of strnum values, and the integer array
diff --git a/awk.h b/awk.h
index 3475558..b99dec7 100644
--- a/awk.h
+++ b/awk.h
@@ -1799,21 +1799,33 @@ dupnode(NODE *n)
 }
 #endif
 
-/* force_string --- force a node to have a string value */
+/*
+ * force_string_fmt --- force a node to have a string value in a given format.
+ * The string representation of a number may change due to whether it was most
+ * recently rendered with CONVFMT or OFMT, or due to changes in the CONVFMT
+ * and OFMT values. But if the value entered gawk as a string or strnum, then
+ * stfmt should be set to STFMT_UNUSED, and the string representation should
+ * not change.
+ */
 
 static inline NODE *
-force_string(NODE *s)
+force_string_fmt(NODE *s, const char *fmtstr, int fmtidx)
 {
        if (s->type == Node_typedregex)
                return dupnode(s->re_exp);
 
        if ((s->flags & STRCUR) != 0
-                   && (s->stfmt == STFMT_UNUSED || s->stfmt == CONVFMTidx)
+                   && (s->stfmt == STFMT_UNUSED || s->stfmt == fmtidx)
        )
                return s;
-       return format_val(CONVFMT, CONVFMTidx, s);
+       return format_val(fmtstr, fmtidx, s);
 }
 
+/* conceptually should be force_string_convfmt, but this is the typical case */
+#define force_string(s)                force_string_fmt((s), CONVFMT, 
CONVFMTidx)
+
+#define force_string_ofmt(s)   force_string_fmt((s), OFMT, OFMTidx)
+
 #ifdef GAWKDEBUG
 #define unref  r_unref
 #define        force_number    str2number
diff --git a/builtin.c b/builtin.c
index 92ac9e4..a01018e 100644
--- a/builtin.c
+++ b/builtin.c
@@ -2200,12 +2200,7 @@ do_print(int nargs, int redirtype)
                                DEREF(args_array[i]);
                        fatal(_("attempt to use array `%s' in a scalar 
context"), array_vname(tmp));
                }
-
-               if (tmp->type == Node_typedregex)
-                       args_array[i] = force_string(tmp);
-               else if (!((tmp->flags & STRCUR) != 0
-                               && (tmp->stfmt == STFMT_UNUSED || tmp->stfmt == 
OFMTidx)))
-                       args_array[i] = format_val(OFMT, OFMTidx, tmp);
+               args_array[i] = force_string_ofmt(tmp);
        }
 
        if (redir_exp != NULL) {

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

Summary of changes:
 ChangeLog |    9 +++++++++
 awk.h     |   20 ++++++++++++++++----
 builtin.c |    7 +------
 3 files changed, 26 insertions(+), 10 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

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