From 45f23f3a59c91ddaf0b358b98c9dbe2bc1e83257 Mon Sep 17 00:00:00 2001 From: nicm Date: Sun, 4 Jan 2026 08:38:26 +0000 Subject: [PATCH] Minor tidying of cmd_list_print from Pavel Roskin. --- cmd.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/cmd.c b/cmd.c index f02aa625..119b685a 100644 --- a/cmd.c +++ b/cmd.c @@ -682,6 +682,9 @@ cmd_list_print(const struct cmd_list *cmdlist, int escaped) struct cmd *cmd, *next; char *buf, *this; size_t len; + const char *separator; + const char *single_separator = escaped ? " \\; " : " ; "; + const char *double_separator = escaped ? " \\;\\; " : " ;; "; len = 1; buf = xcalloc(1, len); @@ -696,17 +699,11 @@ cmd_list_print(const struct cmd_list *cmdlist, int escaped) next = TAILQ_NEXT(cmd, qentry); if (next != NULL) { - if (cmd->group != next->group) { - if (escaped) - strlcat(buf, " \\;\\; ", len); - else - strlcat(buf, " ;; ", len); - } else { - if (escaped) - strlcat(buf, " \\; ", len); - else - strlcat(buf, " ; ", len); - } + if (cmd->group != next->group) + separator = double_separator; + else + separator = single_separator; + strlcat(buf, separator, len); } free(this);