diff --git a/profile.c b/profile.c index 910a821..f57023d 100644 --- a/profile.c +++ b/profile.c @@ -1863,7 +1863,7 @@ pp_concat(int nargs) r = pp_args[i]; if (r->pp_str[0] != '(') { - pl_l = prec_level(pp_args[i]->type); + pl_l = prec_level(r->type); pl_r = prec_level(pp_args[i+1]->type); if (i >= 2 && is_unary_minus(r->pp_str)) { @@ -1871,7 +1871,7 @@ pp_concat(int nargs) memcpy(s, r->pp_str, r->pp_len); s += r->pp_len; *s++ = ')'; - } else if (is_scalar(pp_args[i]->type) && is_scalar(pp_args[i+1]->type)) { + } else if (is_scalar(r->type) && is_scalar(pp_args[i+1]->type)) { memcpy(s, r->pp_str, r->pp_len); s += r->pp_len; } else if (pl_l <= pl_r || is_scalar(pp_args[i+1]->type)) { @@ -1887,14 +1887,13 @@ pp_concat(int nargs) memcpy(s, r->pp_str, r->pp_len); s += r->pp_len; } + if (i == nargs-1) + pl_l = prec_level(r->type); pp_free(r); - if (i < nargs) { - *s++ = ' '; - } + *s++ = ' '; } - pl_l = prec_level(pp_args[nargs-1]->type); pl_r = prec_level(pp_args[nargs]->type); r = pp_args[nargs]; if (r->pp_str[0] == '(') {