gawk-diffs
[Top][All Lists]
Advanced

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

[gawk-diffs] [SCM] gawk branch, feature/wasted-byte, updated. gawk-4.1.0


From: Arnold Robbins
Subject: [gawk-diffs] [SCM] gawk branch, feature/wasted-byte, updated. gawk-4.1.0-1315-g613c6dd
Date: Tue, 14 Apr 2015 11:17:01 +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, feature/wasted-byte has been updated
       via  613c6ddd082a0b241a59260927929cc65ae61f9b (commit)
       via  d3d01be8a74e50ec3cb58ba9acd99f08ade5a606 (commit)
       via  1806544b56f2f5e1c76addc85f18aaa75066f497 (commit)
       via  3de71423b3a39be0b9536413321c953cbf99b119 (commit)
      from  8dd09969090bf05155153f5aedfd2302aba15b56 (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=613c6ddd082a0b241a59260927929cc65ae61f9b

commit 613c6ddd082a0b241a59260927929cc65ae61f9b
Merge: 1806544 d3d01be
Author: Arnold D. Robbins <address@hidden>
Date:   Tue Apr 14 14:16:53 2015 +0300

    Merge branch 'master' into feature/wasted-byte

diff --cc ChangeLog
index 31f572a,8cf0c53..2f38085
--- a/ChangeLog
+++ b/ChangeLog
@@@ -1,15 -1,10 +1,22 @@@
  2015-04-14         Arnold D. Robbins     <address@hidden>
  
+       * builtin.c (do_strftime): Restore checking for negative result and
+       add check that time_t is > 0 --- means we're assigning a negative value
+       to an unsigned time_t. Thanks again to Glaudiston Gomes da Silva
+       <address@hidden>.
+ 
++      Unrelated:
++
 +      * builtin.c (do_sub): Improve some variable names for readability
 +      and add / expand some comments.
 +
 +2015-04-14         Andrew J. Schorr      <address@hidden>
 +                 Arnold D. Robbins     <address@hidden>
 +
 +      * builtin.c (do_sub): Make computations smarter; initial len
 +      to malloc, test for final amount after all matches done and
 +      need to copy in the final part of the original string.
 +
  2015-04-13         Arnold D. Robbins     <address@hidden>
  
        * regcomp.c (analyze): Prevent malloc(0).

http://git.sv.gnu.org/cgit/gawk.git/commit/?id=1806544b56f2f5e1c76addc85f18aaa75066f497

commit 1806544b56f2f5e1c76addc85f18aaa75066f497
Author: Arnold D. Robbins <address@hidden>
Date:   Tue Apr 14 14:14:38 2015 +0300

    Improve readability in builtin.c.

diff --git a/ChangeLog b/ChangeLog
index cff7389..31f572a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-04-14         Arnold D. Robbins     <address@hidden>
+
+       * builtin.c (do_sub): Improve some variable names for readability
+       and add / expand some comments.
+
 2015-04-14         Andrew J. Schorr      <address@hidden>
                   Arnold D. Robbins     <address@hidden>
 
diff --git a/builtin.c b/builtin.c
index 3d3c1c4..7320871 100644
--- a/builtin.c
+++ b/builtin.c
@@ -2759,42 +2759,42 @@ do_sub(int nargs, unsigned int flags)
        int ampersands;
        int matches = 0;
        Regexp *rp;
-       NODE *s;                /* subst. pattern */
-       NODE *t;                /* string to make sub. in; $0 if none given */
+       NODE *rep_node;         /* replacement text */
+       NODE *target;           /* string to make sub. in; $0 if none given */
        NODE *tmp;
        NODE **lhs = NULL;
        long how_many = 1;      /* one substitution for sub, also gensub 
default */
-       int global;
+       bool global;
        long current;
        bool lastmatchnonzero;
        char *mb_indices = NULL;
        
        if ((flags & GENSUB) != 0) {
                double d;
-               NODE *t1;
+               NODE *glob_flag;
 
                tmp = PEEK(3);
                rp = re_update(tmp);
 
-               t = POP_STRING();       /* original string */
+               target = POP_STRING();  /* original string */
 
-               t1 = POP_SCALAR();      /* value of global flag */
-               if ((t1->flags & (STRCUR|STRING)) != 0) {
-                       if (t1->stlen > 0 && (t1->stptr[0] == 'g' || 
t1->stptr[0] == 'G'))
+               glob_flag = POP_SCALAR();       /* value of global flag */
+               if ((glob_flag->flags & (STRCUR|STRING)) != 0) {
+                       if (glob_flag->stlen > 0 && (glob_flag->stptr[0] == 'g' 
|| glob_flag->stptr[0] == 'G'))
                                how_many = -1;
                        else {
-                               (void) force_number(t1);
-                               d = get_number_d(t1);
-                               if ((t1->flags & NUMCUR) != 0)
+                               (void) force_number(glob_flag);
+                               d = get_number_d(glob_flag);
+                               if ((glob_flag->flags & NUMCUR) != 0)
                                        goto set_how_many;
 
                                warning(_("gensub: third argument `%.*s' 
treated as 1"),
-                                               (int) t1->stlen, t1->stptr);
+                                               (int) glob_flag->stlen, 
glob_flag->stptr);
                                how_many = 1;
                        }
                } else {
-                       (void) force_number(t1);
-                       d = get_number_d(t1);
+                       (void) force_number(glob_flag);
+                       d = get_number_d(glob_flag);
 set_how_many:
                        if (d < 1)
                                how_many = 1;
@@ -2805,10 +2805,8 @@ set_how_many:
                        if (d <= 0)
                                warning(_("gensub: third argument %g treated as 
1"), d);
                }
-               DEREF(t1);
-
+               DEREF(glob_flag);
        } else {
-
                /* take care of regexp early, in case re_update is fatal */
 
                tmp = PEEK(2);
@@ -2820,30 +2818,30 @@ set_how_many:
                /* original string */
 
                if ((flags & LITERAL) != 0)
-                       t = POP_STRING();
+                       target = POP_STRING();
                else {
                        lhs = POP_ADDRESS();
-                       t = force_string(*lhs);
+                       target = force_string(*lhs);
                }
        }
 
        global = (how_many == -1);
 
-       s = POP_STRING();       /* replacement text */
+       rep_node = POP_STRING();        /* replacement text */
        decr_sp();              /* regexp, already updated above */
 
        /* do the search early to avoid work on non-match */
-       if (research(rp, t->stptr, 0, t->stlen, RE_NEED_START) == -1 ||
-                       RESTART(rp, t->stptr) > t->stlen)
+       if (research(rp, target->stptr, 0, target->stlen, RE_NEED_START) == -1 
||
+                       RESTART(rp, target->stptr) > target->stlen)
                goto done;
 
-       t->flags |= STRING;
+       target->flags |= STRING;
 
-       text = t->stptr;
-       textlen = t->stlen;
+       text = target->stptr;
+       textlen = target->stlen;
 
-       repl = s->stptr;
-       replend = repl + s->stlen;
+       repl = rep_node->stptr;
+       replend = repl + rep_node->stlen;
        repllen = replend - repl;
 
        ampersands = 0;
@@ -2861,6 +2859,7 @@ set_how_many:
                index_multibyte_buffer(repl, mb_indices, repllen);
        }
 
+       /* compute length of replacement string, number of ampersands */
        for (scan = repl; scan < replend; scan++) {
                if ((gawk_mb_cur_max == 1 || (repllen > 0 && mb_indices[scan - 
repl] == 1))
                    && (*scan == '&')) {
@@ -2913,12 +2912,13 @@ set_how_many:
        bp = buf;
        for (current = 1;; current++) {
                matches++;
-               matchstart = t->stptr + RESTART(rp, t->stptr);
-               matchend = t->stptr + REEND(rp, t->stptr);
+               matchstart = target->stptr + RESTART(rp, target->stptr);
+               matchend = target->stptr + REEND(rp, target->stptr);
 
                /*
                 * create the result, copying in parts of the original
-                * string 
+                * string. note that length of replacement string can
+                * vary since ampersand is actual text of regexp match.
                 */
 
                /*
@@ -2976,13 +2976,13 @@ set_how_many:
                                        if (flags & GENSUB) {   /* gensub, 
behave sanely */
                                                if (isdigit((unsigned char) 
scan[1])) {
                                                        int dig = scan[1] - '0';
-                                                       if (dig < 
NUMSUBPATS(rp, t->stptr) && SUBPATSTART(rp, tp->stptr, dig) != -1) {
+                                                       if (dig < 
NUMSUBPATS(rp, target->stptr) && SUBPATSTART(rp, tp->stptr, dig) != -1) {
                                                                char *start, 
*end;
                
-                                                               start = t->stptr
-                                                                     + 
SUBPATSTART(rp, t->stptr, dig);
-                                                               end = t->stptr
-                                                                     + 
SUBPATEND(rp, t->stptr, dig);
+                                                               start = 
target->stptr
+                                                                     + 
SUBPATSTART(rp, target->stptr, dig);
+                                                               end = 
target->stptr
+                                                                     + 
SUBPATEND(rp, target->stptr, dig);
 
                                                                for (cp = 
start; cp < end; cp++)
                                                                        *bp++ = 
*cp;
@@ -3043,7 +3043,7 @@ set_how_many:
 
                if ((current >= how_many && ! global)
                    || ((long) textlen <= 0 && matchstart == matchend)
-                   || research(rp, t->stptr, text - t->stptr, textlen, 
RE_NEED_START) == -1)
+                   || research(rp, target->stptr, text - target->stptr, 
textlen, RE_NEED_START) == -1)
                        break;
 
        }
@@ -3067,7 +3067,7 @@ set_how_many:
                efree(mb_indices);
 
 done:
-       DEREF(s);
+       DEREF(rep_node);
 
        if ((matches == 0 || (flags & LITERAL) != 0) && buf != NULL) {
                efree(buf); 
@@ -3077,18 +3077,18 @@ done:
        if (flags & GENSUB) {
                if (matches > 0) {
                        /* return the result string */
-                       DEREF(t);
+                       DEREF(target);
                        assert(buf != NULL);
                        return make_str_node(buf, textlen, ALREADY_MALLOCED);   
                }
 
                /* return the original string */
-               return t;
+               return target;
        }
 
        /* For a string literal, must not change the original string. */
        if ((flags & LITERAL) != 0)
-               DEREF(t);
+               DEREF(target);
        else if (matches > 0) {
                unref(*lhs);
                *lhs = make_str_node(buf, textlen, ALREADY_MALLOCED);   

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

Summary of changes:
 ChangeLog |   12 ++++++++
 builtin.c |   94 +++++++++++++++++++++++++++++-------------------------------
 2 files changed, 57 insertions(+), 49 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

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