diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2016-10-12 23:25:26 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2016-10-12 23:25:26 +0300 |
commit | 90478dd4c89715ad3e5dd599c1a615df8433db72 (patch) | |
tree | 741f83f72cc64ddf176bc6c4e15d0485a27c9bf5 /awkgram.c | |
parent | 21da4e0801ad2e54503f0790b328ac81fee5d290 (diff) | |
parent | 43a8120a00068448c4ffa60db37bdb8e782df321 (diff) | |
download | egawk-90478dd4c89715ad3e5dd599c1a615df8433db72.tar.gz egawk-90478dd4c89715ad3e5dd599c1a615df8433db72.tar.bz2 egawk-90478dd4c89715ad3e5dd599c1a615df8433db72.zip |
Merge branch 'master' into feature/nocopy
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; } |