diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2016-10-12 23:24:59 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2016-10-12 23:24:59 +0300 |
commit | 24a88d5c8b1f5f5e18149651b033b5a155ac8ee3 (patch) | |
tree | b1a531ad1dc462c324de68fe6764bc93f204516b /awkgram.c | |
parent | 65f44324e8ba1dc7b0495693e0830329a1ae4684 (diff) | |
parent | 43a8120a00068448c4ffa60db37bdb8e782df321 (diff) | |
download | egawk-24a88d5c8b1f5f5e18149651b033b5a155ac8ee3.tar.gz egawk-24a88d5c8b1f5f5e18149651b033b5a155ac8ee3.tar.bz2 egawk-24a88d5c8b1f5f5e18149651b033b5a155ac8ee3.zip |
Merge branch 'master' into feature/cmake
Diffstat (limited to 'awkgram.c')
-rw-r--r-- | awkgram.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -4533,11 +4533,9 @@ negate_num(NODE *n) if ((n->flags & NUMCONSTSTR) != 0) { char *s; - emalloc(s, char *, n->stlen + 1 + 1, "negate_num"); + s = n->stptr; + memmove(& s[1], & s[0], n->stlen + 1); s[0] = '-'; - strcpy(& s[1], n->stptr); - free(n->stptr); - n->stptr = s; n->stlen++; } @@ -8598,7 +8596,9 @@ make_profile_number(double d, const char *str, size_t len) { NODE *n = make_number(d); if (do_pretty_print) { - n->stptr = estrdup(str, len); + // extra byte in case need to add minus sign in negate_num + n->stptr = estrdup(str, len + 1); + n->stptr[len] = '\0'; n->stlen = len; n->flags |= NUMCONSTSTR; } |