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


From: Andrew J. Schorr
Subject: [gawk-diffs] [SCM] gawk branch, feature/fixtype, updated. gawk-4.1.0-1870-ge81d4c0
Date: Thu, 30 Jun 2016 14:02:10 +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  e81d4c05425ee21c44ecef554c216a6760c34c88 (commit)
       via  92b5353bf364897f02003c4116cabe6d48ea17eb (commit)
      from  63df63c24298c4427afcecc34facae7244a80cad (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=e81d4c05425ee21c44ecef554c216a6760c34c88

commit e81d4c05425ee21c44ecef554c216a6760c34c88
Merge: 92b5353 63df63c
Author: Andrew J. Schorr <address@hidden>
Date:   Thu Jun 30 10:00:45 2016 -0400

    Merge branch 'feature/fixtype' of ssh://git.sv.gnu.org/srv/git/gawk into 
feature/fixtype


http://git.sv.gnu.org/cgit/gawk.git/commit/?id=92b5353bf364897f02003c4116cabe6d48ea17eb

commit 92b5353bf364897f02003c4116cabe6d48ea17eb
Author: Andrew J. Schorr <address@hidden>
Date:   Thu Jun 30 09:59:47 2016 -0400

    Use new STFMT_UNUSED define to improve code clarity, and fix some minor 
stfmt issues.

diff --git a/ChangeLog b/ChangeLog
index d78e0b2..a1e2202 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2016-06-30         Andrew J. Schorr     <address@hidden>
+
+       * awk.h (STFMT_UNUSED): New define indicating that the string
+       representation does not depend on CONVFMT or OFMT.
+       (force_string): Use STFMT_UNUSED to improve code clarity.
+       * array.c (value_info): Fix stfmt logic.
+       * builtin.c (do_print): Use STFMT_UNUSED to improve code clarity.
+       * field.c (set_record): Ditto.
+       * gawkapi.c (api_sym_update_scalar): Ditto.
+       * int_array.c (is_integer): Check stfmt equals STFMT_UNUSED before
+       bothering to inspect the string.
+       * mpfr.c (mpg_format_val): Use STFMT_UNUSED to improve code clarity.
+       Remove buggy cast to char in stfmt assignment.
+       * node.c (r_format_val): Ditto.
+       * str_array.c (str_lookup): Use STFMT_UNUSED to improve code clarity.
+       * symbol.c (check_param_names): Ditto.
+
 2016-06-29         Andrew J. Schorr     <address@hidden>
 
        * node.c (r_force_number): Optimize by trimming leading and trailing
diff --git a/array.c b/array.c
index afa3795..ddd3c08 100644
--- a/array.c
+++ b/array.c
@@ -704,7 +704,14 @@ value_info(NODE *n)
        if ((n->flags & (STRING|STRCUR)) == STRCUR) {
                fprintf(output_fp, "][");
                fprintf(output_fp, "stfmt=%d, ", n->stfmt);     
-               fprintf(output_fp, "CONVFMT=\"%s\"", n->stfmt <= -1 ? "%ld"
+               /*
+                * If not STFMT_UNUSED, could be CONVFMT or OFMT if last
+                * used in a print statement. If immutable, could be that it
+                * was originally set as a string, or it's a number that has
+                * an integer value.
+                */
+               fprintf(output_fp, "FMT=\"%s\"",
+                                       n->stfmt == STFMT_UNUSED ? "%s"
                                        : fmt_list[n->stfmt]->stptr);
        }
 
diff --git a/awk.h b/awk.h
index c737c16..3475558 100644
--- a/awk.h
+++ b/awk.h
@@ -497,6 +497,16 @@ typedef struct exp_node {
 #define numbr          sub.val.fltnum
 #endif
 
+/*
+ * If stfmt is set to STFMT_UNUSED, it means that the string representation
+ * stored in stptr is not a function of the value of CONVFMT or OFMT. That
+ * indicates that either the string value was explicitly assigned, or it
+ * was converted from a NUMBER that has an integer value. When stfmt is not
+ * set to STFMT_UNUSED, it is an offset into the fmt_list array of distinct
+ * CONVFMT and OFMT node pointers.
+ */
+#define STFMT_UNUSED   -1
+
 /* Node_arrayfor */
 #define for_list       sub.nodep.r.av
 #define for_list_size  sub.nodep.reflags
@@ -1798,7 +1808,7 @@ force_string(NODE *s)
                return dupnode(s->re_exp);
 
        if ((s->flags & STRCUR) != 0
-                   && (s->stfmt == -1 || s->stfmt == CONVFMTidx)
+                   && (s->stfmt == STFMT_UNUSED || s->stfmt == CONVFMTidx)
        )
                return s;
        return format_val(CONVFMT, CONVFMTidx, s);
diff --git a/builtin.c b/builtin.c
index 24f585e..92ac9e4 100644
--- a/builtin.c
+++ b/builtin.c
@@ -2204,7 +2204,7 @@ do_print(int nargs, int redirtype)
                if (tmp->type == Node_typedregex)
                        args_array[i] = force_string(tmp);
                else if (!((tmp->flags & STRCUR) != 0
-                               && (tmp->stfmt == -1 || tmp->stfmt == OFMTidx)))
+                               && (tmp->stfmt == STFMT_UNUSED || tmp->stfmt == 
OFMTidx)))
                        args_array[i] = format_val(OFMT, OFMTidx, tmp);
        }
 
diff --git a/field.c b/field.c
index 6a9516d..931bafc 100644
--- a/field.c
+++ b/field.c
@@ -288,7 +288,7 @@ set_record(const char *buf, int cnt)
        n->stlen = cnt;
        n->valref = 1;
        n->type = Node_val;
-       n->stfmt = -1;
+       n->stfmt = STFMT_UNUSED;
        n->flags = (STRING|STRCUR|MAYBE_NUM|FIELD);
        fields_arr[0] = n;
 
diff --git a/gawkapi.c b/gawkapi.c
index 3d9f61a..fa960de 100644
--- a/gawkapi.c
+++ b/gawkapi.c
@@ -686,7 +686,7 @@ api_sym_update_scalar(awk_ext_id_t id,
                        /* make_str_node(s, l, ALREADY_MALLOCED): */
                        r->numbr = 0;
                        r->flags = (MALLOC|STRING|STRCUR);
-                       r->stfmt = -1;
+                       r->stfmt = STFMT_UNUSED;
                        r->stptr = value->str_value.str;
                        r->stlen = value->str_value.len;
                        return awk_true;
diff --git a/int_array.c b/int_array.c
index f17bdde..e7913de 100644
--- a/int_array.c
+++ b/int_array.c
@@ -92,8 +92,10 @@ is_integer(NODE *symbol, NODE *subs)
        /*
         * Protect against MAYBE_NUM values where the string may not regenerate
         * correctly. There could be white space and/or a non-decimal value.
+        * If stfmt is not STFMT_UNUSED, it means that the string value was
+        * generated using CONVFMT or OFMT, so there is no info there.
         */
-       if ((subs->flags & STRCUR) != 0) {
+       if ((subs->flags & STRCUR) != 0 && subs->stfmt == STFMT_UNUSED) {
                char *cp = subs->stptr;
 
                if (       subs->stlen == 0
diff --git a/mpfr.c b/mpfr.c
index f2c5811..0bb5b43 100644
--- a/mpfr.c
+++ b/mpfr.c
@@ -370,11 +370,11 @@ mpg_format_val(const char *format, int index, NODE *s)
        if (is_mpg_integer(s) || mpfr_integer_p(s->mpg_numbr)) {
                /* integral value, use %d */
                r = format_tree("%d", 2, dummy, 2);
-               s->stfmt = -1;
+               s->stfmt = STFMT_UNUSED;
        } else {
                r = format_tree(format, fmt_list[index]->stlen, dummy, 2);
                assert(r != NULL);
-               s->stfmt = (char) index;
+               s->stfmt = index;
        }
        s->flags = oflags;
        s->stlen = r->stlen;
diff --git a/node.c b/node.c
index 41dcb2f..8c5d0c0 100644
--- a/node.c
+++ b/node.c
@@ -226,7 +226,7 @@ r_format_val(const char *format, int index, NODE *s)
                 * Once upon a time, we just blindly did this:
                 *      sprintf(sp, format, s->numbr);
                 *      s->stlen = strlen(sp);
-                *      s->stfmt = (char) index;
+                *      s->stfmt = index;
                 * but that's no good if, e.g., OFMT is %s. So we punt,
                 * and just always format the value ourselves.
                 */
@@ -241,11 +241,11 @@ r_format_val(const char *format, int index, NODE *s)
                if (val == s->numbr) {
                        /* integral value, but outside range of %ld, use %.0f */
                        r = format_tree("%.0f", 4, dummy, 2);
-                       s->stfmt = -1;
+                       s->stfmt = STFMT_UNUSED;
                } else {
                        r = format_tree(format, fmt_list[index]->stlen, dummy, 
2);
                        assert(r != NULL);
-                       s->stfmt = (char) index;
+                       s->stfmt = index;
                }
                s->flags = oflags;
                s->stlen = r->stlen;
@@ -268,7 +268,7 @@ r_format_val(const char *format, int index, NODE *s)
                        (void) sprintf(sp, "%ld", num);
                        s->stlen = strlen(sp);
                }
-               s->stfmt = -1;
+               s->stfmt = STFMT_UNUSED;
                if ((s->flags & INTIND) != 0) {
                        s->flags &= ~(INTIND|NUMBER);
                        s->flags |= STRING;
@@ -385,7 +385,7 @@ make_str_node(const char *s, size_t len, int flags)
        r->numbr = 0;
        r->flags = (MALLOC|STRING|STRCUR);
        r->valref = 1;
-       r->stfmt = -1;
+       r->stfmt = STFMT_UNUSED;
        r->wstptr = NULL;
        r->wstlen = 0;
 
diff --git a/str_array.c b/str_array.c
index d9b5d2a..f66b22c 100644
--- a/str_array.c
+++ b/str_array.c
@@ -168,7 +168,7 @@ str_lookup(NODE *symbol, NODE *subs)
         * flag on it since other variables could be using the same
         * reference-counted value.
         */
-       if (subs->stfmt != -1 || (subs->flags & MAYBE_NUM) != 0) {
+       if (subs->stfmt != STFMT_UNUSED || (subs->flags & MAYBE_NUM) != 0) {
                NODE *tmp;
 
                /*
diff --git a/symbol.c b/symbol.c
index 8533fad..ab23103 100644
--- a/symbol.c
+++ b/symbol.c
@@ -648,7 +648,7 @@ check_param_names(void)
        memset(& n, 0, sizeof n);
        n.type = Node_val;
        n.flags = STRING|STRCUR;
-       n.stfmt = -1;
+       n.stfmt = STFMT_UNUSED;
 
        /*
         * assoc_list() returns an array with two elements per awk array

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

Summary of changes:
 ChangeLog   |   17 +++++++++++++++++
 array.c     |    9 ++++++++-
 awk.h       |   12 +++++++++++-
 builtin.c   |    2 +-
 field.c     |    2 +-
 gawkapi.c   |    2 +-
 int_array.c |    4 +++-
 mpfr.c      |    4 ++--
 node.c      |   10 +++++-----
 str_array.c |    2 +-
 symbol.c    |    2 +-
 11 files changed, 51 insertions(+), 15 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

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