diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2016-02-29 21:34:57 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2016-02-29 21:34:57 +0200 |
commit | 21b584ce481970c9022c08148a6adbc0e489c432 (patch) | |
tree | 1b67978ae32a437958c1d69b4dc856d58172aca0 /profile.c | |
parent | bfca1619d658bc30835f4fb29c53ddfe206f4b17 (diff) | |
download | egawk-21b584ce481970c9022c08148a6adbc0e489c432.tar.gz egawk-21b584ce481970c9022c08148a6adbc0e489c432.tar.bz2 egawk-21b584ce481970c9022c08148a6adbc0e489c432.zip |
Fix profiling bug - printf with no arguments.
Diffstat (limited to 'profile.c')
-rw-r--r-- | profile.c | 44 |
1 files changed, 25 insertions, 19 deletions
@@ -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]; |