gawk-diffs
[Top][All Lists]
Advanced

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

[gawk-diffs] [SCM] gawk branch, gawk-4.1-stable, updated. gawk-4.1.0-828


From: Arnold Robbins
Subject: [gawk-diffs] [SCM] gawk branch, gawk-4.1-stable, updated. gawk-4.1.0-828-g21b584c
Date: Mon, 29 Feb 2016 19:35:22 +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, gawk-4.1-stable has been updated
       via  21b584ce481970c9022c08148a6adbc0e489c432 (commit)
      from  bfca1619d658bc30835f4fb29c53ddfe206f4b17 (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=21b584ce481970c9022c08148a6adbc0e489c432

commit 21b584ce481970c9022c08148a6adbc0e489c432
Author: Arnold D. Robbins <address@hidden>
Date:   Mon Feb 29 21:34:57 2016 +0200

    Fix profiling bug - printf with no arguments.

diff --git a/ChangeLog b/ChangeLog
index 0b8c5e0..67d81cf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2016-02-29         Arnold D. Robbins     <address@hidden>
+
+       * profile.c (pp_list): Handle the case of nargs equal to zero.
+       Thanks to Hermann Peifer for the report.
+
 2016-02-28         Arnold D. Robbins     <address@hidden>
 
        * profile.c (pprint): Fix copy-paste error in else handling.
diff --git a/profile.c b/profile.c
index d002e23..178deb7 100644
--- a/profile.c
+++ b/profile.c
@@ -1423,34 +1423,40 @@ pp_list(int nargs, const char *paren, const char *delim)
                erealloc(pp_args, NODE **, (nargs + 2) * sizeof(NODE *), 
"pp_list");
        }
 
-       delimlen = strlen(delim);
-       len = -delimlen;
-       for (i = 1; i <= nargs; i++) {
-               r = pp_args[i] = pp_pop();
-               len += r->pp_len + delimlen;
-       }
-       if (paren != NULL) {
-               assert(strlen(paren) == 2);
-               len += 2;
+       if (nargs == 0)
+               len = 2;
+       else {
+               delimlen = strlen(delim);
+               len = -delimlen;
+               for (i = 1; i <= nargs; i++) {
+                       r = pp_args[i] = pp_pop();
+                       len += r->pp_len + delimlen;
+               }
+               if (paren != NULL) {
+                       assert(strlen(paren) == 2);
+                       len += 2;
+               }
        }
 
        emalloc(str, char *, len + 1, "pp_list");
        s = str;
        if (paren != NULL)
                *s++ = paren[0];  
-       r = pp_args[nargs];
-       memcpy(s, r->pp_str, r->pp_len);
-       s += r->pp_len;
-       pp_free(r);
-       for (i = nargs - 1; i > 0; i--) {
-               if (delimlen > 0) {
-                       memcpy(s, delim, delimlen);
-                       s += delimlen;
-               }
-               r = pp_args[i];
+       if (nargs > 0) {
+               r = pp_args[nargs];
                memcpy(s, r->pp_str, r->pp_len);
                s += r->pp_len;
                pp_free(r);
+               for (i = nargs - 1; i > 0; i--) {
+                       if (delimlen > 0) {
+                               memcpy(s, delim, delimlen);
+                               s += delimlen;
+                       }
+                       r = pp_args[i];
+                       memcpy(s, r->pp_str, r->pp_len);
+                       s += r->pp_len;
+                       pp_free(r);
+               }
        }
        if (paren != NULL)
                *s++ = paren[1];

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

Summary of changes:
 ChangeLog |    5 +++++
 profile.c |   44 +++++++++++++++++++++++++-------------------
 2 files changed, 30 insertions(+), 19 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

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