From bfca1619d658bc30835f4fb29c53ddfe206f4b17 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Sun, 28 Feb 2016 05:40:41 +0200 Subject: Fix copy-paste error in profiler's else handling. --- profile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'profile.c') diff --git a/profile.c b/profile.c index 3d0b1cbc..d002e237 100644 --- a/profile.c +++ b/profile.c @@ -885,7 +885,7 @@ cleanup: && pc->branch_end == pc->nexti->nexti->branch_else->lasti) { pprint(pc->nexti, pc->branch_end, IN_ELSE_IF); } else { - fprintf(prof_fp, "{\n", op2str(pc->opcode)); + fprintf(prof_fp, "{\n"); indent_in(); pprint(pc->nexti, pc->branch_end, NO_PPRINT_FLAGS); indent_out(); -- cgit v1.2.3 From 21b584ce481970c9022c08148a6adbc0e489c432 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Mon, 29 Feb 2016 21:34:57 +0200 Subject: Fix profiling bug - printf with no arguments. --- profile.c | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) (limited to 'profile.c') diff --git a/profile.c b/profile.c index d002e237..178deb7e 100644 --- a/profile.c +++ b/profile.c @@ -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]; -- cgit v1.2.3