diff options
author | nicm <nicm> | 2020-06-04 07:12:05 +0000 |
---|---|---|
committer | nicm <nicm> | 2020-06-04 07:12:05 +0000 |
commit | b3782d2dc8f872c43fcf53b9436c4e881d3f1e2d (patch) | |
tree | f7c75fcbdc0ce56e6f55cce00480a49a3dd02f84 /cmd.c | |
parent | 3f6af4156f451cfbee867babe74cc6675eb3f947 (diff) | |
download | rtmux-b3782d2dc8f872c43fcf53b9436c4e881d3f1e2d.tar.gz rtmux-b3782d2dc8f872c43fcf53b9436c4e881d3f1e2d.tar.bz2 rtmux-b3782d2dc8f872c43fcf53b9436c4e881d3f1e2d.zip |
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.
Diffstat (limited to 'cmd.c')
-rw-r--r-- | cmd.c | 16 |
1 files changed, 9 insertions, 7 deletions
@@ -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); } |