gawk-diffs
[Top][All Lists]
Advanced

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

[gawk-diffs] [SCM] gawk branch, master, updated. gawk-4.1.0-2429-g21cc2d


From: Andrew J. Schorr
Subject: [gawk-diffs] [SCM] gawk branch, master, updated. gawk-4.1.0-2429-g21cc2dc
Date: Fri, 3 Feb 2017 14:03:49 +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, master has been updated
       via  21cc2dc13d48aaa70b88d7a190ea8b4b830986f4 (commit)
      from  f0b9ec9b838045318bcc8512c48dd93c66d4eef5 (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=21cc2dc13d48aaa70b88d7a190ea8b4b830986f4

commit 21cc2dc13d48aaa70b88d7a190ea8b4b830986f4
Author: Andrew J. Schorr <address@hidden>
Date:   Fri Feb 3 09:03:27 2017 -0500

    In set_profile_text, use emalloc instead of estrdup to improve clarity.

diff --git a/ChangeLog b/ChangeLog
index 6fe653f..cb9a011 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2017-02-03         Andrew J. Schorr     <address@hidden>
+
+       * awkgram.y (set_profile_text): Improve code clarity by using emalloc
+       to allocate the string instead of abusing estrdup.
+
 2017-02-02         Arnold D. Robbins     <address@hidden>
 
        * awkgram.y (set_profile_next): Allocate an extra byte at the
diff --git a/awkgram.c b/awkgram.c
index a39fff2..3c26d34 100644
--- a/awkgram.c
+++ b/awkgram.c
@@ -8712,9 +8712,10 @@ static NODE *
 set_profile_text(NODE *n, const char *str, size_t len)
 {
        if (do_pretty_print) {
-               // extra byte in case we need to add minus sign in negate_num
-               // note that estrdup adds another byte for the \0 at the end
-               n->stptr = estrdup(str, len + 1);
+               // two extra bytes: one for NUL termination, and another in
+               // case we need to add a leading minus sign in add_sign_to_num
+               emalloc(n->stptr, char *, len + 2, "set_profile_text");
+               memcpy(n->stptr, str, len);
                n->stptr[len] = '\0';
                n->stlen = len;
                // Set STRCUR and n->stfmt for use when profiling
diff --git a/awkgram.y b/awkgram.y
index f506be8..ea365a7 100644
--- a/awkgram.y
+++ b/awkgram.y
@@ -6292,9 +6292,10 @@ static NODE *
 set_profile_text(NODE *n, const char *str, size_t len)
 {
        if (do_pretty_print) {
-               // extra byte in case we need to add minus sign in negate_num
-               // note that estrdup adds another byte for the \0 at the end
-               n->stptr = estrdup(str, len + 1);
+               // two extra bytes: one for NUL termination, and another in
+               // case we need to add a leading minus sign in add_sign_to_num
+               emalloc(n->stptr, char *, len + 2, "set_profile_text");
+               memcpy(n->stptr, str, len);
                n->stptr[len] = '\0';
                n->stlen = len;
                // Set STRCUR and n->stfmt for use when profiling

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

Summary of changes:
 ChangeLog |    5 +++++
 awkgram.c |    7 ++++---
 awkgram.y |    7 ++++---
 3 files changed, 13 insertions(+), 6 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

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