inpcom.c, cleanup `inp_quote_params()', don't poke string

This commit is contained in:
rlar
2014-12-20 18:49:34 +01:00
parent 6a6c9a9409
commit 1b49bb6ea4
+6 -4
View File
@@ -6119,7 +6119,9 @@ inp_quote_params(struct line *s_c, struct line *e_c, struct dependency *deps, in
beg = str_ptr; beg = str_ptr;
end = str_ptr + strlen(deps[i].param_name); end = str_ptr + strlen(deps[i].param_name);
if ((isspace(beg[-1]) || beg[-1] == '=') && if ((isspace(beg[-1]) || beg[-1] == '=') &&
(isspace(*end) || *end == '\0' || *end == ')')) { (isspace(*end) || *end == '\0' || *end == ')'))
{
int prefix_len;
if (isspace(beg[-1])) { if (isspace(beg[-1])) {
beg = skip_back_ws(beg); beg = skip_back_ws(beg);
if (beg[-1] == '{') if (beg[-1] == '{')
@@ -6134,9 +6136,9 @@ inp_quote_params(struct line *s_c, struct line *e_c, struct dependency *deps, in
else else
end--; end--;
} }
*str_ptr = '\0'; prefix_len = (int)(str_ptr - curr_line);
new_str = tprintf("%s{%s}%s", curr_line, deps[i].param_name, end); new_str = tprintf("%.*s{%s}%s", prefix_len, curr_line, deps[i].param_name, end);
str_ptr = new_str + strlen(curr_line) + strlen(deps[i].param_name) + 2; str_ptr = new_str + prefix_len + strlen(deps[i].param_name) + 2;
tfree(c->li_line); tfree(c->li_line);
curr_line = c->li_line = new_str; curr_line = c->li_line = new_str;