summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cmd-attach-session.c8
-rw-r--r--cmd-bind-key.c4
-rw-r--r--cmd-break-pane.c6
-rw-r--r--cmd-choose-client.c4
-rw-r--r--cmd-choose-session.c4
-rw-r--r--cmd-choose-window.c4
-rw-r--r--cmd-clear-history.c4
-rw-r--r--cmd-clock-mode.c4
-rw-r--r--cmd-command-prompt.c4
-rw-r--r--cmd-confirm-before.c4
-rw-r--r--cmd-copy-buffer.c4
-rw-r--r--cmd-copy-mode.c8
-rw-r--r--cmd-delete-buffer.c4
-rw-r--r--cmd-detach-client.c4
-rw-r--r--cmd-display-message.c4
-rw-r--r--cmd-display-panes.c4
-rw-r--r--cmd-down-pane.c4
-rw-r--r--cmd-find-window.c4
-rw-r--r--cmd-generic.c90
-rw-r--r--cmd-has-session.c4
-rw-r--r--cmd-if-shell.c4
-rw-r--r--cmd-kill-pane.c6
-rw-r--r--cmd-kill-server.c4
-rw-r--r--cmd-kill-session.c4
-rw-r--r--cmd-kill-window.c4
-rw-r--r--cmd-last-window.c4
-rw-r--r--cmd-link-window.c8
-rw-r--r--cmd-list-buffers.c4
-rw-r--r--cmd-list-clients.c4
-rw-r--r--cmd-list-commands.c4
-rw-r--r--cmd-list-keys.c4
-rw-r--r--cmd-list-panes.c4
-rw-r--r--cmd-list-sessions.c4
-rw-r--r--cmd-list-windows.c4
-rw-r--r--cmd-load-buffer.c4
-rw-r--r--cmd-lock-client.c4
-rw-r--r--cmd-lock-server.c4
-rw-r--r--cmd-lock-session.c4
-rw-r--r--cmd-move-window.c8
-rw-r--r--cmd-new-session.c4
-rw-r--r--cmd-new-window.c4
-rw-r--r--cmd-next-layout.c4
-rw-r--r--cmd-next-window.c8
-rw-r--r--cmd-paste-buffer.c8
-rw-r--r--cmd-pipe-pane.c6
-rw-r--r--cmd-previous-layout.c4
-rw-r--r--cmd-previous-window.c8
-rw-r--r--cmd-refresh-client.c4
-rw-r--r--cmd-rename-session.c4
-rw-r--r--cmd-rename-window.c4
-rw-r--r--cmd-resize-pane.c36
-rw-r--r--cmd-respawn-window.c6
-rw-r--r--cmd-rotate-window.c8
-rw-r--r--cmd-run-shell.c4
-rw-r--r--cmd-save-buffer.c6
-rw-r--r--cmd-select-layout.c4
-rw-r--r--cmd-select-pane.c4
-rw-r--r--cmd-select-prompt.c4
-rw-r--r--cmd-select-window.c4
-rw-r--r--cmd-send-keys.c4
-rw-r--r--cmd-send-prefix.c4
-rw-r--r--cmd-server-info.c4
-rw-r--r--cmd-set-buffer.c4
-rw-r--r--cmd-set-environment.c10
-rw-r--r--cmd-set-option.c12
-rw-r--r--cmd-set-window-option.c12
-rw-r--r--cmd-show-buffer.c4
-rw-r--r--cmd-show-environment.c6
-rw-r--r--cmd-show-options.c6
-rw-r--r--cmd-show-window-options.c6
-rw-r--r--cmd-source-file.c4
-rw-r--r--cmd-split-window.c4
-rw-r--r--cmd-start-server.c4
-rw-r--r--cmd-suspend-client.c4
-rw-r--r--cmd-swap-pane.c15
-rw-r--r--cmd-swap-window.c6
-rw-r--r--cmd-switch-client.c4
-rw-r--r--cmd-unbind-key.c4
-rw-r--r--cmd-unlink-window.c6
-rw-r--r--cmd-up-pane.c4
-rw-r--r--tmux.h9
81 files changed, 266 insertions, 266 deletions
diff --git a/cmd-attach-session.c b/cmd-attach-session.c
index dc5f6abf..13d0ff54 100644
--- a/cmd-attach-session.c
+++ b/cmd-attach-session.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-attach-session.c,v 1.33 2009-11-13 16:51:49 tcunha Exp $ */
+/* $Id: cmd-attach-session.c,v 1.34 2009-11-14 17:56:39 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -29,7 +29,7 @@ int cmd_attach_session_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_attach_session_entry = {
"attach-session", "attach",
"[-d] " CMD_TARGET_SESSION_USAGE,
- CMD_CANTNEST|CMD_STARTSERVER|CMD_SENDENVIRON, CMD_CHFLAG('d'),
+ CMD_CANTNEST|CMD_STARTSERVER|CMD_SENDENVIRON, "d",
cmd_target_init,
cmd_target_parse,
cmd_attach_session_exec,
@@ -58,7 +58,7 @@ cmd_attach_session_exec(struct cmd *self, struct cmd_ctx *ctx)
return (0);
if (ctx->cmdclient == NULL) {
- if (data->chflags & CMD_CHFLAG('d')) {
+ if (cmd_check_flag(data->chflags, 'd')) {
/*
* Can't use server_write_session in case attaching to
* the same session as currently attached to.
@@ -89,7 +89,7 @@ cmd_attach_session_exec(struct cmd *self, struct cmd_ctx *ctx)
return (-1);
}
- if (data->chflags & CMD_CHFLAG('d'))
+ if (cmd_check_flag(data->chflags, 'd'))
server_write_session(s, MSG_DETACH, NULL, 0);
ctx->cmdclient->session = s;
diff --git a/cmd-bind-key.c b/cmd-bind-key.c
index 2ae81782..e20a75b1 100644
--- a/cmd-bind-key.c
+++ b/cmd-bind-key.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-bind-key.c,v 1.25 2009-07-28 23:19:06 tcunha Exp $ */
+/* $Id: cmd-bind-key.c,v 1.26 2009-11-14 17:56:39 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -46,7 +46,7 @@ struct cmd_bind_key_data {
const struct cmd_entry cmd_bind_key_entry = {
"bind-key", "bind",
"[-cnr] [-t key-table] key command [arguments]",
- 0, 0,
+ 0, "",
NULL,
cmd_bind_key_parse,
cmd_bind_key_exec,
diff --git a/cmd-break-pane.c b/cmd-break-pane.c
index e2e8768f..6c01ca4b 100644
--- a/cmd-break-pane.c
+++ b/cmd-break-pane.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-break-pane.c,v 1.9 2009-10-11 23:38:16 tcunha Exp $ */
+/* $Id: cmd-break-pane.c,v 1.10 2009-11-14 17:56:39 tcunha Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -31,7 +31,7 @@ int cmd_break_pane_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_break_pane_entry = {
"break-pane", "breakp",
CMD_TARGET_PANE_USAGE " [-d]",
- 0, CMD_CHFLAG('d'),
+ 0, "d",
cmd_target_init,
cmd_target_parse,
cmd_break_pane_exec,
@@ -74,7 +74,7 @@ cmd_break_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
base_idx = options_get_number(&s->options, "base-index");
wl = session_attach(s, w, -1 - base_idx, &cause); /* can't fail */
- if (!(data->chflags & CMD_CHFLAG('d')))
+ if (!cmd_check_flag(data->chflags, 'd'))
session_select(s, wl->idx);
server_redraw_session(s);
diff --git a/cmd-choose-client.c b/cmd-choose-client.c
index ce8334fc..d3210fe1 100644
--- a/cmd-choose-client.c
+++ b/cmd-choose-client.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-choose-client.c,v 1.3 2009-09-07 23:59:19 tcunha Exp $ */
+/* $Id: cmd-choose-client.c,v 1.4 2009-11-14 17:56:39 tcunha Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -34,7 +34,7 @@ void cmd_choose_client_free(void *);
const struct cmd_entry cmd_choose_client_entry = {
"choose-client", NULL,
CMD_TARGET_WINDOW_USAGE " [template]",
- CMD_ARG01, 0,
+ CMD_ARG01, "",
cmd_target_init,
cmd_target_parse,
cmd_choose_client_exec,
diff --git a/cmd-choose-session.c b/cmd-choose-session.c
index 27e03d19..33b84080 100644
--- a/cmd-choose-session.c
+++ b/cmd-choose-session.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-choose-session.c,v 1.14 2009-10-11 23:38:16 tcunha Exp $ */
+/* $Id: cmd-choose-session.c,v 1.15 2009-11-14 17:56:39 tcunha Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -34,7 +34,7 @@ void cmd_choose_session_free(void *);
const struct cmd_entry cmd_choose_session_entry = {
"choose-session", NULL,
CMD_TARGET_WINDOW_USAGE " [template]",
- CMD_ARG01, 0,
+ CMD_ARG01, "",
cmd_target_init,
cmd_target_parse,
cmd_choose_session_exec,
diff --git a/cmd-choose-window.c b/cmd-choose-window.c
index 8137c6eb..6cff98c4 100644
--- a/cmd-choose-window.c
+++ b/cmd-choose-window.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-choose-window.c,v 1.18 2009-10-11 23:38:16 tcunha Exp $ */
+/* $Id: cmd-choose-window.c,v 1.19 2009-11-14 17:56:39 tcunha Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -34,7 +34,7 @@ void cmd_choose_window_free(void *);
const struct cmd_entry cmd_choose_window_entry = {
"choose-window", NULL,
CMD_TARGET_WINDOW_USAGE " [template]",
- CMD_ARG01, 0,
+ CMD_ARG01, "",
cmd_target_init,
cmd_target_parse,
cmd_choose_window_exec,
diff --git a/cmd-clear-history.c b/cmd-clear-history.c
index f91d3b43..6771443b 100644
--- a/cmd-clear-history.c
+++ b/cmd-clear-history.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-clear-history.c,v 1.7 2009-07-30 21:04:40 tcunha Exp $ */
+/* $Id: cmd-clear-history.c,v 1.8 2009-11-14 17:56:39 tcunha Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -29,7 +29,7 @@ int cmd_clear_history_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_clear_history_entry = {
"clear-history", "clearhist",
CMD_TARGET_PANE_USAGE,
- 0, 0,
+ 0, "",
cmd_target_init,
cmd_target_parse,
cmd_clear_history_exec,
diff --git a/cmd-clock-mode.c b/cmd-clock-mode.c
index 037cee3a..aaff6d06 100644
--- a/cmd-clock-mode.c
+++ b/cmd-clock-mode.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-clock-mode.c,v 1.6 2009-08-20 11:37:46 tcunha Exp $ */
+/* $Id: cmd-clock-mode.c,v 1.7 2009-11-14 17:56:39 tcunha Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -29,7 +29,7 @@ int cmd_clock_mode_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_clock_mode_entry = {
"clock-mode", NULL,
CMD_TARGET_PANE_USAGE,
- 0, 0,
+ 0, "",
cmd_target_init,
cmd_target_parse,
cmd_clock_mode_exec,
diff --git a/cmd-command-prompt.c b/cmd-command-prompt.c
index 0ef56df5..37814cb9 100644
--- a/cmd-command-prompt.c
+++ b/cmd-command-prompt.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-command-prompt.c,v 1.26 2009-09-22 14:06:40 tcunha Exp $ */
+/* $Id: cmd-command-prompt.c,v 1.27 2009-11-14 17:56:39 tcunha Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -39,7 +39,7 @@ void cmd_command_prompt_cfree(void *);
const struct cmd_entry cmd_command_prompt_entry = {
"command-prompt", NULL,
CMD_TARGET_CLIENT_USAGE " [-p prompts] [template]",
- 0, 0,
+ 0, "",
cmd_command_prompt_init,
cmd_command_prompt_parse,
cmd_command_prompt_exec,
diff --git a/cmd-confirm-before.c b/cmd-confirm-before.c
index 5c2dd109..8824e911 100644
--- a/cmd-confirm-before.c
+++ b/cmd-confirm-before.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-confirm-before.c,v 1.11 2009-08-24 16:24:18 tcunha Exp $ */
+/* $Id: cmd-confirm-before.c,v 1.12 2009-11-14 17:56:39 tcunha Exp $ */
/*
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
@@ -34,7 +34,7 @@ void cmd_confirm_before_free(void *);
const struct cmd_entry cmd_confirm_before_entry = {
"confirm-before", "confirm",
CMD_TARGET_CLIENT_USAGE " command",
- CMD_ARG1, 0,
+ CMD_ARG1, "",
cmd_confirm_before_init,
cmd_target_parse,
cmd_confirm_before_exec,
diff --git a/cmd-copy-buffer.c b/cmd-copy-buffer.c
index b74f7789..99c58a22 100644
--- a/cmd-copy-buffer.c
+++ b/cmd-copy-buffer.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-copy-buffer.c,v 1.5 2009-09-22 14:06:40 tcunha Exp $ */
+/* $Id: cmd-copy-buffer.c,v 1.6 2009-11-14 17:56:39 tcunha Exp $ */
/*
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
@@ -43,7 +43,7 @@ struct cmd_copy_buffer_data {
const struct cmd_entry cmd_copy_buffer_entry = {
"copy-buffer", "copyb",
"[-a src-index] [-b dst-index] [-s src-session] [-t dst-session]",
- 0, 0,
+ 0, "",
cmd_copy_buffer_init,
cmd_copy_buffer_parse,
cmd_copy_buffer_exec,
diff --git a/cmd-copy-mode.c b/cmd-copy-mode.c
index 92aafbd9..5930fc26 100644
--- a/cmd-copy-mode.c
+++ b/cmd-copy-mode.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-copy-mode.c,v 1.24 2009-10-06 14:14:06 tcunha Exp $ */
+/* $Id: cmd-copy-mode.c,v 1.25 2009-11-14 17:56:39 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -30,7 +30,7 @@ int cmd_copy_mode_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_copy_mode_entry = {
"copy-mode", NULL,
"[-u] " CMD_TARGET_PANE_USAGE,
- 0, CMD_CHFLAG('u'),
+ 0, "u",
cmd_copy_mode_init,
cmd_target_parse,
cmd_copy_mode_exec,
@@ -48,7 +48,7 @@ cmd_copy_mode_init(struct cmd *self, int key)
switch (key) {
case KEYC_PPAGE:
- data->chflags |= CMD_CHFLAG('u');
+ cmd_set_flag(&data->chflags, 'u');
break;
}
}
@@ -63,7 +63,7 @@ cmd_copy_mode_exec(struct cmd *self, struct cmd_ctx *ctx)
return (-1);
window_pane_set_mode(wp, &window_copy_mode);
- if (wp->mode == &window_copy_mode && data->chflags & CMD_CHFLAG('u'))
+ if (wp->mode == &window_copy_mode && cmd_check_flag(data->chflags, 'u'))
window_copy_pageup(wp);
return (0);
diff --git a/cmd-delete-buffer.c b/cmd-delete-buffer.c
index e9746eeb..1ca3d8d6 100644
--- a/cmd-delete-buffer.c
+++ b/cmd-delete-buffer.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-delete-buffer.c,v 1.7 2009-07-28 22:12:16 tcunha Exp $ */
+/* $Id: cmd-delete-buffer.c,v 1.8 2009-11-14 17:56:39 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -31,7 +31,7 @@ int cmd_delete_buffer_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_delete_buffer_entry = {
"delete-buffer", "deleteb",
CMD_BUFFER_SESSION_USAGE,
- 0, 0,
+ 0, "",
cmd_buffer_init,
cmd_buffer_parse,
cmd_delete_buffer_exec,
diff --git a/cmd-detach-client.c b/cmd-detach-client.c
index d973fa2f..13f00d67 100644
--- a/cmd-detach-client.c
+++ b/cmd-detach-client.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-detach-client.c,v 1.9 2009-07-28 22:12:16 tcunha Exp $ */
+/* $Id: cmd-detach-client.c,v 1.10 2009-11-14 17:56:39 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -29,7 +29,7 @@ int cmd_detach_client_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_detach_client_entry = {
"detach-client", "detach",
CMD_TARGET_CLIENT_USAGE,
- 0, 0,
+ 0, "",
cmd_target_init,
cmd_target_parse,
cmd_detach_client_exec,
diff --git a/cmd-display-message.c b/cmd-display-message.c
index a7a50868..9876fb19 100644
--- a/cmd-display-message.c
+++ b/cmd-display-message.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-display-message.c,v 1.3 2009-10-11 23:55:26 tcunha Exp $ */
+/* $Id: cmd-display-message.c,v 1.4 2009-11-14 17:56:39 tcunha Exp $ */
/*
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
@@ -31,7 +31,7 @@ int cmd_display_message_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_display_message_entry = {
"display-message", "display",
CMD_TARGET_CLIENT_USAGE " [message]",
- CMD_ARG01, 0,
+ CMD_ARG01, "",
cmd_target_init,
cmd_target_parse,
cmd_display_message_exec,
diff --git a/cmd-display-panes.c b/cmd-display-panes.c
index f1bf5819..b58622b5 100644
--- a/cmd-display-panes.c
+++ b/cmd-display-panes.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-display-panes.c,v 1.1 2009-08-31 22:30:15 tcunha Exp $ */
+/* $Id: cmd-display-panes.c,v 1.2 2009-11-14 17:56:39 tcunha Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -29,7 +29,7 @@ int cmd_display_panes_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_display_panes_entry = {
"display-panes", "displayp",
CMD_TARGET_CLIENT_USAGE,
- 0, 0,
+ 0, "",
cmd_target_init,
cmd_target_parse,
cmd_display_panes_exec,
diff --git a/cmd-down-pane.c b/cmd-down-pane.c
index 9c21cbc2..4d57b096 100644
--- a/cmd-down-pane.c
+++ b/cmd-down-pane.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-down-pane.c,v 1.12 2009-07-28 22:12:16 tcunha Exp $ */
+/* $Id: cmd-down-pane.c,v 1.13 2009-11-14 17:56:39 tcunha Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -29,7 +29,7 @@ int cmd_down_pane_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_down_pane_entry = {
"down-pane", "downp",
CMD_TARGET_WINDOW_USAGE,
- 0, 0,
+ 0, "",
cmd_target_init,
cmd_target_parse,
cmd_down_pane_exec,
diff --git a/cmd-find-window.c b/cmd-find-window.c
index 247cb207..82277161 100644
--- a/cmd-find-window.c
+++ b/cmd-find-window.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-find-window.c,v 1.13 2009-07-28 22:12:16 tcunha Exp $ */
+/* $Id: cmd-find-window.c,v 1.14 2009-11-14 17:56:39 tcunha Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -34,7 +34,7 @@ void cmd_find_window_callback(void *, int);
const struct cmd_entry cmd_find_window_entry = {
"find-window", "findw",
CMD_TARGET_WINDOW_USAGE " match-string",
- CMD_ARG1, 0,
+ CMD_ARG1, "",
cmd_target_init,
cmd_target_parse,
cmd_find_window_exec,
diff --git a/cmd-generic.c b/cmd-generic.c
index df9aeb16..f384dc81 100644
--- a/cmd-generic.c
+++ b/cmd-generic.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-generic.c,v 1.34 2009-08-26 22:13:52 tcunha Exp $ */
+/* $Id: cmd-generic.c,v 1.35 2009-11-14 17:56:39 tcunha Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -23,8 +23,8 @@
#include "tmux.h"
-int cmd_getopt(int, char **, const char *, uint64_t);
-int cmd_flags(int, uint64_t, uint64_t *);
+int cmd_getopt(int, char **, const char *, const char *);
+int cmd_parse_flags(int, const char *, uint64_t *);
size_t cmd_print_flags(char *, size_t, size_t, uint64_t);
int cmd_fill_argument(int, char **, char **, int, char **);
@@ -36,51 +36,53 @@ cmd_prarg(char *buf, size_t len, const char *prefix, char *arg)
return (xsnprintf(buf, len, "%s%s", prefix, arg));
}
-/* Prepend flags from chflags onto flagstr and call getopt. */
+/* Append two flag strings together and call getopt. */
int
-cmd_getopt(int argc, char **argv, const char *flagstr, uint64_t chflags)
+cmd_getopt(int argc, char **argv, const char *flagstr, const char *chflagstr)
{
- u_char ch;
- char buf[128];
- size_t len, off;
-
- *buf = '\0';
+ char tmp[BUFSIZ];
- len = sizeof buf;
- off = 0;
+ if (strlcpy(tmp, flagstr, sizeof tmp) >= sizeof tmp)
+ fatalx("strlcpy overflow");
+ if (strlcat(tmp, chflagstr, sizeof tmp) >= sizeof tmp)
+ fatalx("strlcat overflow");
+ return (getopt(argc, argv, tmp));
+}
- for (ch = 0; ch < 26; ch++) {
- if (chflags & CMD_CHFLAG('a' + ch))
- off += xsnprintf(buf + off, len - off, "%c", 'a' + ch);
- if (chflags & CMD_CHFLAG('A' + ch))
- off += xsnprintf(buf + off, len - off, "%c", 'A' + ch);
- }
-
- strlcat(buf, flagstr, sizeof buf);
+/* Return if flag character is set. */
+int
+cmd_check_flag(uint64_t chflags, int flag)
+{
+ if (flag >= 'A' && flag <= 'Z')
+ flag = 26 + flag - 'A';
+ else if (flag >= 'a' && flag <= 'z')
+ flag = flag - 'a';
+ else
+ return (0);
+ return ((chflags & (1ULL << flag)) != 0);
+}
- return (getopt(argc, argv, buf));
+/* Set flag character. */
+void
+cmd_set_flag(uint64_t *chflags, int flag)
+{
+ if (flag >= 'A' && flag <= 'Z')
+ flag = 26 + flag - 'A';
+ else if (flag >= 'a' && flag <= 'z')
+ flag = flag - 'a';
+ else
+ return;
+ (*chflags) |= (1ULL << flag);