gawk-diffs
[Top][All Lists]
Advanced

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

[gawk-diffs] [SCM] gawk branch, wasted-byte, updated. gawk-4.1.0-1012-gc


From: Arnold Robbins
Subject: [gawk-diffs] [SCM] gawk branch, wasted-byte, updated. gawk-4.1.0-1012-gc55956b
Date: Sun, 14 Dec 2014 18:38:31 +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, wasted-byte has been updated
       via  c55956b6a10d0a4d0b151c1be976dc9c344c1103 (commit)
      from  b6ac928a53d146233741fc5f7fe1cac66de27303 (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=c55956b6a10d0a4d0b151c1be976dc9c344c1103

commit c55956b6a10d0a4d0b151c1be976dc9c344c1103
Author: Arnold D. Robbins <address@hidden>
Date:   Sun Dec 14 20:38:14 2014 +0200

    More fixes to stop allocating an extra byte.

diff --git a/ChangeLog b/ChangeLog
index c54a177..f890a70 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2014-12-14         Arnold D. Robbins     <address@hidden>
+
+       * awkgram.y (yyerror): Do not waste a byte at the end of a string.
+       * builtin.c (do_match): Ditto.
+       * command.y (append_statement): Ditto.
+       * debug.c (gprintf, serialize): Ditto.
+       * field.c (set_FIELDWIDTHS): Ditto.
+       * io.c.c (init_awkpath, grow_iop_buffer): Ditto.
+       * profile.c (pp_string, pp_concat, pp_group3): Ditto.
+
 2014-12-14         Andrew J. Schorr     <address@hidden>
 
        * array.c (concat_exp): Do not waste a byte at the end of a string.
diff --git a/awkgram.c b/awkgram.c
index 4715290..827c09b 100644
--- a/awkgram.c
+++ b/awkgram.c
@@ -4548,7 +4548,7 @@ yyerror(const char *m, ...)
        if (mesg == NULL)
                mesg = m;
 
-       count = (bp - thisline) + strlen(mesg) + 2 + 1;
+       count = (bp - thisline) + strlen(mesg) + 1 + 1;
        emalloc(buf, char *, count, "yyerror");
 
        bp = buf;
diff --git a/awkgram.y b/awkgram.y
index f6a396a..b476ef5 100644
--- a/awkgram.y
+++ b/awkgram.y
@@ -2210,7 +2210,7 @@ yyerror(const char *m, ...)
        if (mesg == NULL)
                mesg = m;
 
-       count = (bp - thisline) + strlen(mesg) + 2 + 1;
+       count = (bp - thisline) + strlen(mesg) + 1 + 1;
        emalloc(buf, char *, count, "yyerror");
 
        bp = buf;
diff --git a/builtin.c b/builtin.c
index 838ab89..067b410 100644
--- a/builtin.c
+++ b/builtin.c
@@ -2554,7 +2554,7 @@ do_match(int nargs)
 
                                        sprintf(buff, "%d", ii);
                                        ilen = strlen(buff);
-                                       amt = ilen + subseplen + 
strlen("length") + 2;
+                                       amt = ilen + subseplen + 
strlen("length") + 1;
        
                                        if (oldamt == 0) {
                                                emalloc(buf, char *, amt, 
"do_match");
@@ -2876,9 +2876,8 @@ set_how_many:
 
        /* guesstimate how much room to allocate; +2 forces > 0 */
        buflen = textlen + (ampersands + 1) * repllen + 2;
-       emalloc(buf, char *, buflen + 2, "do_sub");
+       emalloc(buf, char *, buflen + 1, "do_sub");
        buf[buflen] = '\0';
-       buf[buflen + 1] = '\0';
 
        bp = buf;
        for (current = 1;; current++) {
@@ -3006,7 +3005,7 @@ set_how_many:
        }
        sofar = bp - buf;
        if (buflen - sofar - textlen - 1) {
-               buflen = sofar + textlen + 2;
+               buflen = sofar + textlen + 1;
                erealloc(buf, char *, buflen, "do_sub");
                bp = buf + sofar;
        }
diff --git a/command.c b/command.c
index 2d4bc81..5304cd6 100644
--- a/command.c
+++ b/command.c
@@ -2515,7 +2515,7 @@ append_statement(CMDARG *stmt_list, char *stmt)
                        len += strlen(a->a_string) + 1; /* 1 for ',' */
                len += EVALSIZE;
 
-               emalloc(s, char *, (len + 2) * sizeof(char), 
"append_statement");
+               emalloc(s, char *, (len + 1) * sizeof(char), 
"append_statement");
                arg = mk_cmdarg(D_string);
                arg->a_string = s;
                arg->a_count = len;     /* kludge */
@@ -2542,7 +2542,7 @@ append_statement(CMDARG *stmt_list, char *stmt)
        ssize = stmt_list->a_count;
        if (len > ssize - slen) {
                ssize = slen + len + EVALSIZE;
-               erealloc(s, char *, (ssize + 2) * sizeof(char), 
"append_statement");
+               erealloc(s, char *, (ssize + 1) * sizeof(char), 
"append_statement");
                stmt_list->a_string = s;
                stmt_list->a_count = ssize;
        }
@@ -2554,7 +2554,7 @@ append_statement(CMDARG *stmt_list, char *stmt)
        }
 
        if (stmt == end_EVAL)
-               erealloc(stmt_list->a_string, char *, slen + 2, 
"append_statement");
+               erealloc(stmt_list->a_string, char *, slen + 1, 
"append_statement");
        return stmt_list;
 
 #undef EVALSIZE
@@ -2921,7 +2921,7 @@ again:
                bool esc_seen = false;
 
                toklen = lexend - lexptr;
-               emalloc(str, char *, toklen + 2, "yylex");
+               emalloc(str, char *, toklen + 1, "yylex");
                p = str;
 
                while ((c = *++lexptr) != '"') {
@@ -3100,7 +3100,7 @@ concat_args(CMDARG *arg, int count)
                arg = arg->next;
        }
 
-       emalloc(str, char *, len + 2, "concat_args");
+       emalloc(str, char *, len + 1, "concat_args");
        n = tmp[0];
        memcpy(str, n->stptr, n->stlen);
        p = str + n->stlen;
diff --git a/command.y b/command.y
index 0889374..bd5b487 100644
--- a/command.y
+++ b/command.y
@@ -764,7 +764,7 @@ append_statement(CMDARG *stmt_list, char *stmt)
                        len += strlen(a->a_string) + 1; /* 1 for ',' */
                len += EVALSIZE;
 
-               emalloc(s, char *, (len + 2) * sizeof(char), 
"append_statement");
+               emalloc(s, char *, (len + 1) * sizeof(char), 
"append_statement");
                arg = mk_cmdarg(D_string);
                arg->a_string = s;
                arg->a_count = len;     /* kludge */
@@ -791,7 +791,7 @@ append_statement(CMDARG *stmt_list, char *stmt)
        ssize = stmt_list->a_count;
        if (len > ssize - slen) {
                ssize = slen + len + EVALSIZE;
-               erealloc(s, char *, (ssize + 2) * sizeof(char), 
"append_statement");
+               erealloc(s, char *, (ssize + 1) * sizeof(char), 
"append_statement");
                stmt_list->a_string = s;
                stmt_list->a_count = ssize;
        }
@@ -803,7 +803,7 @@ append_statement(CMDARG *stmt_list, char *stmt)
        }
 
        if (stmt == end_EVAL)
-               erealloc(stmt_list->a_string, char *, slen + 2, 
"append_statement");
+               erealloc(stmt_list->a_string, char *, slen + 1, 
"append_statement");
        return stmt_list;
 
 #undef EVALSIZE
@@ -1170,7 +1170,7 @@ again:
                bool esc_seen = false;
 
                toklen = lexend - lexptr;
-               emalloc(str, char *, toklen + 2, "yylex");
+               emalloc(str, char *, toklen + 1, "yylex");
                p = str;
 
                while ((c = *++lexptr) != '"') {
@@ -1349,7 +1349,7 @@ concat_args(CMDARG *arg, int count)
                arg = arg->next;
        }
 
-       emalloc(str, char *, len + 2, "concat_args");
+       emalloc(str, char *, len + 1, "concat_args");
        n = tmp[0];
        memcpy(str, n->stptr, n->stlen);
        p = str + n->stlen;
diff --git a/debug.c b/debug.c
index 58012b7..c2f1135 100644
--- a/debug.c
+++ b/debug.c
@@ -4205,10 +4205,10 @@ gprintf(FILE *fp, const char *format, ...)
 #define GPRINTF_BUFSIZ 512
        if (buf == NULL) {
                buflen = GPRINTF_BUFSIZ;
-               emalloc(buf, char *, (buflen + 2) * sizeof(char), "gprintf");
+               emalloc(buf, char *, (buflen + 1) * sizeof(char), "gprintf");
        } else if (buflen - bl < GPRINTF_BUFSIZ/2) {
                buflen += GPRINTF_BUFSIZ;
-               erealloc(buf, char *, (buflen + 2) * sizeof(char), "gprintf");
+               erealloc(buf, char *, (buflen + 1) * sizeof(char), "gprintf");
        }        
 #undef GPRINTF_BUFSIZ
        
@@ -4227,7 +4227,7 @@ gprintf(FILE *fp, const char *format, ...)
 
                /* enlarge buffer, and try again */ 
                buflen *= 2;
-               erealloc(buf, char *, (buflen + 2) * sizeof(char), "gprintf");
+               erealloc(buf, char *, (buflen + 1) * sizeof(char), "gprintf");
        }
 
        bl = 0;
@@ -4356,7 +4356,7 @@ serialize(int type)
 
        if (buf == NULL) {      /* first time */
                buflen = SERIALIZE_BUFSIZ;
-               emalloc(buf, char *, buflen + 2, "serialize");
+               emalloc(buf, char *, buflen + 1, "serialize");
        }
        bl = 0;
 
@@ -4365,7 +4365,7 @@ serialize(int type)
                if (buflen - bl < SERIALIZE_BUFSIZ/2) {
 enlarge_buffer:
                        buflen *= 2;
-                       erealloc(buf, char *, buflen + 2, "serialize");
+                       erealloc(buf, char *, buflen + 1, "serialize");
                }
 
 #undef SERIALIZE_BUFSIZ
@@ -4466,7 +4466,7 @@ enlarge_buffer:
                        }
 
                        if (nchar > 0) {        /* non-empty commands list */
-                               nchar += (strlen("commands ") + 20 + 
strlen("end") + 2); /* 20 for cnum (an int) */
+                               nchar += (strlen("commands ") + 20 + 
strlen("end") + 1); /* 20 for cnum (an int) */
                                if (nchar > buflen - bl) {
                                        buflen = bl + nchar;
                                        erealloc(buf, char *, buflen + 3, 
"serialize");
diff --git a/field.c b/field.c
index c23f0b1..13a5db6 100644
--- a/field.c
+++ b/field.c
@@ -1138,7 +1138,7 @@ set_FIELDWIDTHS()
        FIELDWIDTHS[0] = 0;
        for (i = 1; ; i++) {
                unsigned long int tmp;
-               if (i + 2 >= fw_alloc) {
+               if (i + 1 >= fw_alloc) {
                        fw_alloc *= 2;
                        erealloc(FIELDWIDTHS, int *, fw_alloc * sizeof(int), 
"set_FIELDWIDTHS");
                }
diff --git a/io.c b/io.c
index 1d15d88..86dfc13 100644
--- a/io.c
+++ b/io.c
@@ -2554,7 +2554,7 @@ init_awkpath(path_info *pi)
                        end++;
                len = end - start;
                if (len > 0) {
-                       emalloc(p, char *, len + 2, "init_awkpath");
+                       emalloc(p, char *, len + 1, "init_awkpath");
                        memcpy(p, start, len);
 
                        /* add directory punctuation if necessary */
@@ -3040,10 +3040,10 @@ grow_iop_buffer(IOBUF *iop)
        size_t newsize;
 
        /*
-        * Lop off original extra two bytes, double the size,
-        * add them back.
+        * Lop off original extra byte, double the size,
+        * add it back.
         */
-       newsize = ((iop->size - 2) * 2) + 2;
+       newsize = ((iop->size - 1) * 2) + 1;
 
        /* Check for overflow */
        if (newsize <= iop->size)
@@ -3051,7 +3051,7 @@ grow_iop_buffer(IOBUF *iop)
 
        /* Make sure there's room for a disk block */
        if (newsize - valid < iop->readsize)
-               newsize += iop->readsize + 2;
+               newsize += iop->readsize + 1;
 
        /* Check for overflow, again */
        if (newsize <= iop->size)
diff --git a/profile.c b/profile.c
index ad879a3..45eb562 100644
--- a/profile.c
+++ b/profile.c
@@ -1337,7 +1337,7 @@ pp_string(const char *in_str, size_t len, int delim)
                osiz *= 2; \
        } ofre -= (l)
 
-       osiz = len + 3 + 2;     /* initial size; 3 for delim + terminating null 
*/
+       osiz = len + 3 + 1;     /* initial size; 3 for delim + terminating null 
*/
        emalloc(obuf, char *, osiz, "pp_string");
        obufout = obuf;
        ofre = osiz - 1;
@@ -1505,7 +1505,7 @@ pp_concat(int nargs)
        len = -delimlen;
        for (i = nargs; i >= 1; i--) {
                r = pp_args[i] = pp_pop();
-               len += r->pp_len + delimlen + 2;
+               len += r->pp_len + delimlen + 1;
        }
 
        emalloc(str, char *, len + 1, "pp_concat");
@@ -1571,7 +1571,7 @@ pp_group3(const char *s1, const char *s2, const char *s3)
        len1 = strlen(s1);
        len2 = strlen(s2);
        len3 = strlen(s3);
-       l = len1 + len2 + len3 + 2;
+       l = len1 + len2 + len3 + 1;
        emalloc(str, char *, l, "pp_group3");
        s = str;
        if (len1 > 0) {

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

Summary of changes:
 ChangeLog |   10 ++++++++++
 awkgram.c |    2 +-
 awkgram.y |    2 +-
 builtin.c |    7 +++----
 command.c |   10 +++++-----
 command.y |   10 +++++-----
 debug.c   |   12 ++++++------
 field.c   |    2 +-
 io.c      |   10 +++++-----
 profile.c |    6 +++---
 10 files changed, 40 insertions(+), 31 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

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