summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2009-07-15 17:39:00 +0000
committerNicholas Marriott <nicm@openbsd.org>2009-07-15 17:39:00 +0000
commit92da443a9e02a2238d4415e0dcf3796d3929b290 (patch)
treedba39ebf34f33d4d399e9dc73591e2a6668c8f07
parent780fd8f7a6fde6f14016f3c4f94f04d8118859c1 (diff)
Make status_message_set a variadic printf-like function. No functional change -
helpful for a couple of things coming soon.
-rw-r--r--cmd-command-prompt.c2
-rw-r--r--cmd-confirm-before.c2
-rw-r--r--cmd-select-prompt.c4
-rw-r--r--key-bindings.c4
-rw-r--r--status.c9
-rw-r--r--tmux.h2
6 files changed, 13 insertions, 10 deletions
diff --git a/cmd-command-prompt.c b/cmd-command-prompt.c
index 841dfd78..e4660e99 100644
--- a/cmd-command-prompt.c
+++ b/cmd-command-prompt.c
@@ -150,7 +150,7 @@ cmd_command_prompt_callback(void *data, const char *s)
if (cause == NULL)
return (0);
*cause = toupper((u_char) *cause);
- status_message_set(c, cause);
+ status_message_set(c, "%s", cause);
xfree(cause);
cmdlist = NULL;
}
diff --git a/cmd-confirm-before.c b/cmd-confirm-before.c
index 0819e3e9..2dbd72ce 100644
--- a/cmd-confirm-before.c
+++ b/cmd-confirm-before.c
@@ -113,7 +113,7 @@ cmd_confirm_before_callback(void *data, const char *s)
if (cmd_string_parse(cdata->cmd, &cmdlist, &cause) != 0) {
if (cause != NULL) {
*cause = toupper((u_char) *cause);
- status_message_set(c, cause);
+ status_message_set(c, "%s", cause);
xfree(cause);
}
goto out;
diff --git a/cmd-select-prompt.c b/cmd-select-prompt.c
index 5221fa1e..8b707342 100644
--- a/cmd-select-prompt.c
+++ b/cmd-select-prompt.c
@@ -74,14 +74,14 @@ cmd_select_prompt_callback(void *data, const char *s)
idx = strtonum(s, 0, UINT_MAX, &errstr);
if (errstr != NULL) {
xsnprintf(msg, sizeof msg, "Index %s: %s", errstr, s);
- status_message_set(c, msg);
+ status_message_set(c, "%s", msg);
return (0);
}
if (winlink_find_by_index(&c->session->windows, idx) == NULL) {
xsnprintf(msg, sizeof msg,
"Window not found: %s:%d", c->session->name, idx);
- status_message_set(c, msg);
+ status_message_set(c, "%s", msg);
return (0);
}
diff --git a/key-bindings.c b/key-bindings.c
index 438836f3..6fb3b89d 100644
--- a/key-bindings.c
+++ b/key-bindings.c
@@ -194,7 +194,7 @@ key_bindings_error(struct cmd_ctx *ctx, const char *fmt, ...)
va_end(ap);
*msg = toupper((u_char) *msg);
- status_message_set(ctx->curclient, msg);
+ status_message_set(ctx->curclient, "%s", msg);
xfree(msg);
}
@@ -227,7 +227,7 @@ key_bindings_info(struct cmd_ctx *ctx, const char *fmt, ...)
va_end(ap);
*msg = toupper((u_char) *msg);
- status_message_set(ctx->curclient, msg);
+ status_message_set(ctx->curclient, "%s", msg);
xfree(msg);
}
diff --git a/status.c b/status.c
index 89a83cba..67d0274d 100644
--- a/status.c
+++ b/status.c
@@ -465,17 +465,20 @@ status_print(struct session *s, struct winlink *wl, struct grid_cell *gc)
return (text);
}
-void
-status_message_set(struct client *c, const char *msg)
+void printflike2
+status_message_set(struct client *c, const char *fmt, ...)
{
struct timeval tv;
+ va_list ap;
int delay;
delay = options_get_number(&c->session->options, "display-time");
tv.tv_sec = delay / 1000;
tv.tv_usec = (delay % 1000) * 1000L;
- c->message_string = xstrdup(msg);
+ va_start(ap, fmt);
+ xvasprintf(&c->message_string, fmt, ap);
+ va_end(ap);
if (gettimeofday(&c->message_timer, NULL) != 0)
fatal("gettimeofday");
timeradd(&c->message_timer, &tv, &c->message_timer);
diff --git a/tmux.h b/tmux.h
index 533a8797..53688eed 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1275,7 +1275,7 @@ int server_unlock(const char *);
/* status.c */
int status_redraw(struct client *);
-void status_message_set(struct client *, const char *);
+void printflike2 status_message_set(struct client *, const char *, ...);
void status_message_clear(struct client *);
int status_message_redraw(struct client *);
void status_prompt_set(struct client *,