diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2020-06-04 07:12:06 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2020-06-04 07:12:06 +0000 |
commit | 10646ca6ccc4c522cb1694d2ad975be2cac96f4f (patch) | |
tree | f2dde6277a6f5f4dcab38b7af7219a9202d94a00 /usr.bin/tmux/cmd.c | |
parent | b212416942e2f3a1215ec9f47edab7ca780b9e01 (diff) |
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 'usr.bin/tmux/cmd.c')
-rw-r--r-- | usr.bin/tmux/cmd.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/usr.bin/tmux/cmd.c b/usr.bin/tmux/cmd.c index 7e6f7fc1f86..5e116fc36bc 100644 --- a/usr.bin/tmux/cmd.c +++ b/usr.bin/tmux/cmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd.c,v 1.161 2020/05/16 16:02:24 nicm Exp $ */ +/* $OpenBSD: cmd.c,v 1.162 2020/06/04 07:12:05 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -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); } |