diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2016-10-12 23:25:32 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2016-10-12 23:25:32 +0300 |
commit | 47873e9e88e573737c96d9a0c649a05ce7d61f0d (patch) | |
tree | 442ee36df53fee4a0123671bdae4f3fd045aa506 /awkgram.c | |
parent | 1edb964dbdb07174e5822727df8ae45b32eb965f (diff) | |
parent | 43a8120a00068448c4ffa60db37bdb8e782df321 (diff) | |
download | egawk-47873e9e88e573737c96d9a0c649a05ce7d61f0d.tar.gz egawk-47873e9e88e573737c96d9a0c649a05ce7d61f0d.tar.bz2 egawk-47873e9e88e573737c96d9a0c649a05ce7d61f0d.zip |
Merge branch 'master' into feature/typed-regex
Diffstat (limited to 'awkgram.c')
-rw-r--r-- | awkgram.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -4622,11 +4622,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++; } @@ -8701,7 +8699,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; } |