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. --- ChangeLog | 5 +++++ profile.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 8ac6f192..0b8c5e0f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2016-02-28 Arnold D. Robbins + + * profile.c (pprint): Fix copy-paste error in else handling. + Thanks to Michal Jaegermann for the report. + 2016-02-23 Arnold D. Robbins * config.guess, config.rpath, config.sub: Update to latest 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. --- ChangeLog | 5 +++++ profile.c | 44 +++++++++++++++++++++++++------------------- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0b8c5e0f..67d81cf4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2016-02-29 Arnold D. Robbins + + * profile.c (pp_list): Handle the case of nargs equal to zero. + Thanks to Hermann Peifer for the report. + 2016-02-28 Arnold D. Robbins * profile.c (pprint): Fix copy-paste error in else handling. 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