mirror of
https://github.com/tmux/tmux.git
synced 2025-09-02 05:21:10 +00:00
Instead of using a custom parse function to process {}, treat it as a
set of statements and parse with yacc, then convert back to a string as the last step. This means the rules are consistent inside and outside {}, %if and friends work at the right time, and the final result isn't littered with unnecessary newlines.
This commit is contained in:
16
cmd.c
16
cmd.c
@ -357,25 +357,27 @@ cmd_free_argv(int argc, char **argv)
|
||||
char *
|
||||
cmd_stringify_argv(int argc, char **argv)
|
||||
{
|
||||
char *buf;
|
||||
char *buf = NULL, *s;
|
||||
size_t len = 0;
|
||||
int i;
|
||||
size_t len;
|
||||
|
||||
if (argc == 0)
|
||||
return (xstrdup(""));
|
||||
|
||||
len = 0;
|
||||
buf = NULL;
|
||||
|
||||
for (i = 0; i < argc; i++) {
|
||||
len += strlen(argv[i]) + 1;
|
||||
s = args_escape(argv[i]);
|
||||
log_debug("%s: %u %s = %s", __func__, i, argv[i], s);
|
||||
|
||||
len += strlen(s) + 1;
|
||||
buf = xrealloc(buf, len);
|
||||
|
||||
if (i == 0)
|
||||
*buf = '\0';
|
||||
else
|
||||
strlcat(buf, " ", len);
|
||||
strlcat(buf, argv[i], len);
|
||||
strlcat(buf, s, len);
|
||||
|
||||
free(s);
|
||||
}
|
||||
return (buf);
|
||||
}
|
||||
|
Reference in New Issue
Block a user