diff options
author | 2019-06-05 20:00:53 +0000 | |
---|---|---|
committer | 2019-06-05 20:00:53 +0000 | |
commit | 5304b409a935f4849f86fa569260dd7f5fdcd9d4 (patch) | |
tree | 06329335b1b0bb067a7cfd638511201808b1495d | |
parent | Need to increment the argument to skip the prefix earlier, fixes (diff) | |
download | wireguard-openbsd-5304b409a935f4849f86fa569260dd7f5fdcd9d4.tar.xz wireguard-openbsd-5304b409a935f4849f86fa569260dd7f5fdcd9d4.zip |
Add a -v flag to source-file to show the commands and line numbers.
-rw-r--r-- | usr.bin/tmux/cfg.c | 3 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-parse.y | 19 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-source-file.c | 8 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.1 | 8 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 3 |
5 files changed, 32 insertions, 9 deletions
diff --git a/usr.bin/tmux/cfg.c b/usr.bin/tmux/cfg.c index d58d89bbc7a..852489dd3c8 100644 --- a/usr.bin/tmux/cfg.c +++ b/usr.bin/tmux/cfg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cfg.c,v 1.72 2019/05/23 18:39:00 nicm Exp $ */ +/* $OpenBSD: cfg.c,v 1.73 2019/06/05 20:00:53 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -127,6 +127,7 @@ load_cfg(const char *path, struct client *c, struct cmdq_item *item, int flags, pi.flags = flags; pi.file = path; pi.line = 1; + pi.item = item; pr = cmd_parse_from_file(f, &pi); fclose(f); diff --git a/usr.bin/tmux/cmd-parse.y b/usr.bin/tmux/cmd-parse.y index cfb09d24b1f..ca3592c7ff3 100644 --- a/usr.bin/tmux/cmd-parse.y +++ b/usr.bin/tmux/cmd-parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-parse.y,v 1.13 2019/06/02 07:10:15 nicm Exp $ */ +/* $OpenBSD: cmd-parse.y,v 1.14 2019/06/05 20:00:53 nicm Exp $ */ /* * Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -76,6 +76,8 @@ static char *cmd_parse_get_error(const char *, u_int, const char *); static void cmd_parse_free_command(struct cmd_parse_command *); static struct cmd_parse_commands *cmd_parse_new_commands(void); static void cmd_parse_free_commands(struct cmd_parse_commands *); +static void cmd_parse_print_commands(struct cmd_parse_input *, u_int, + struct cmd_list *); %} @@ -498,6 +500,19 @@ cmd_parse_get_error(const char *file, u_int line, const char *error) } static void +cmd_parse_print_commands(struct cmd_parse_input *pi, u_int line, + struct cmd_list *cmdlist) +{ + char *s; + + if (pi->item != NULL && (pi->flags & CMD_PARSE_VERBOSE)) { + s = cmd_list_print(cmdlist, 0); + cmdq_print(pi->item, "%u: %s", line, s); + free(s); + } +} + +static void cmd_parse_free_command(struct cmd_parse_command *cmd) { free(cmd->name); @@ -653,6 +668,7 @@ cmd_parse_build_commands(struct cmd_parse_commands *cmds, if (cmdlist == NULL || cmd->line != line) { if (cmdlist != NULL) { + cmd_parse_print_commands(pi, line, cmdlist); cmd_list_move(result, cmdlist); cmd_list_free(cmdlist); } @@ -672,6 +688,7 @@ cmd_parse_build_commands(struct cmd_parse_commands *cmds, cmd_list_append(cmdlist, add); } if (cmdlist != NULL) { + cmd_parse_print_commands(pi, line, cmdlist); cmd_list_move(result, cmdlist); cmd_list_free(cmdlist); } diff --git a/usr.bin/tmux/cmd-source-file.c b/usr.bin/tmux/cmd-source-file.c index a9ebd0c2261..ffe031ec03a 100644 --- a/usr.bin/tmux/cmd-source-file.c +++ b/usr.bin/tmux/cmd-source-file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-source-file.c,v 1.40 2019/05/28 12:20:28 nicm Exp $ */ +/* $OpenBSD: cmd-source-file.c,v 1.41 2019/06/05 20:00:53 nicm Exp $ */ /* * Copyright (c) 2008 Tiago Cunha <me@tiagocunha.org> @@ -38,8 +38,8 @@ const struct cmd_entry cmd_source_file_entry = { .name = "source-file", .alias = "source", - .args = { "nq", 1, -1 }, - .usage = "[-nq] path ...", + .args = { "nqv", 1, -1 }, + .usage = "[-nqv] path ...", .flags = 0, .exec = cmd_source_file_exec @@ -63,6 +63,8 @@ cmd_source_file_exec(struct cmd *self, struct cmdq_item *item) flags |= CMD_PARSE_QUIET; if (args_has(args, 'n')) flags |= CMD_PARSE_PARSEONLY; + if (args_has(args, 'v')) + flags |= CMD_PARSE_VERBOSE; utf8_stravis(&cwd, server_client_get_cwd(c, NULL), VIS_GLOB); retval = CMD_RETURN_NORMAL; diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index c1bf8e6b886..1d37be69cc4 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.662 2019/06/03 18:28:37 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.663 2019/06/05 20:00:53 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> .\" @@ -14,7 +14,7 @@ .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: June 3 2019 $ +.Dd $Mdocdate: June 5 2019 $ .Dt TMUX 1 .Os .Sh NAME @@ -1251,7 +1251,7 @@ and .Fl T show debugging information about jobs and terminals. .It Xo Ic source-file -.Op Fl nq +.Op Fl nqv .Ar path .Ar ... .Xc @@ -1269,6 +1269,8 @@ does not exist. With .Fl n , the file is parsed but no commands are executed. +.Fl v +shows the parsed commands and line numbers if possible. .It Ic start-server .D1 (alias: Ic start ) Start the diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 7fbd288869c..d830168ffa8 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.908 2019/06/03 18:28:37 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.909 2019/06/05 20:00:53 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -1324,6 +1324,7 @@ struct cmd_parse_input { #define CMD_PARSE_QUIET 0x1 #define CMD_PARSE_PARSEONLY 0x2 #define CMD_PARSE_NOALIAS 0x4 +#define CMD_PARSE_VERBOSE 0x8 const char *file; u_int line; |