summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTiago Cunha <tcunha@gmx.com>2009-09-22 13:59:46 +0000
committerTiago Cunha <tcunha@gmx.com>2009-09-22 13:59:46 +0000
commit59e65cbda27e49b90aab48d13aa8036303cd6679 (patch)
treea1c2ee3a3eaac1ced524089e32f1dbfb0fd5c421
parent649b7c132d3a83cc7e67742d38d9e74c5cfae9ac (diff)
Sync OpenBSD patchset 340:
Use option print function for info messages as well.
-rw-r--r--options-cmd.c69
-rw-r--r--options.c9
-rw-r--r--tmux.h7
3 files changed, 49 insertions, 36 deletions
diff --git a/options-cmd.c b/options-cmd.c
index aba4b3c5..bc978611 100644
--- a/options-cmd.c
+++ b/options-cmd.c
@@ -1,4 +1,4 @@
-/* $Id: options-cmd.c,v 1.6 2009-09-22 13:56:02 tcunha Exp $ */
+/* $Id: options-cmd.c,v 1.7 2009-09-22 13:59:46 tcunha Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -67,7 +67,8 @@ void
set_option_string(struct cmd_ctx *ctx, struct options *oo,
const struct set_option_entry *entry, char *value, int append)
{
- char *oldvalue, *newvalue;
+ struct options_entry *o;
+ char *oldvalue, *newvalue;
if (value == NULL) {
ctx->error(ctx, "empty value");
@@ -80,8 +81,9 @@ set_option_string(struct cmd_ctx *ctx, struct options *oo,
} else
newvalue = value;
- options_set_string(oo, entry->name, "%s", newvalue);
- ctx->info(ctx, "set option: %s -> %s", entry->name, newvalue);
+ o = options_set_string(oo, entry->name, "%s", newvalue);
+ ctx->info(
+ ctx, "set option: %s -> %s", o->name, set_option_print(entry, o));
if (newvalue != value)
xfree(newvalue);
@@ -91,8 +93,9 @@ void
set_option_number(struct cmd_ctx *ctx, struct options *oo,
const struct set_option_entry *entry, char *value)
{
- long long number;
- const char *errstr;
+ struct options_entry *o;
+ long long number;
+ const char *errstr;
if (value == NULL) {
ctx->error(ctx, "empty value");
@@ -104,15 +107,18 @@ set_option_number(struct cmd_ctx *ctx, struct options *oo,
ctx->error(ctx, "value is %s: %s", errstr, value);
return;
}
- options_set_number(oo, entry->name, number);
- ctx->info(ctx, "set option: %s -> %lld", entry->name, number);
+
+ o = options_set_number(oo, entry->name, number);
+ ctx->info(
+ ctx, "set option: %s -> %s", o->name, set_option_print(entry, o));
}
void
set_option_key(struct cmd_ctx *ctx, struct options *oo,
const struct set_option_entry *entry, char *value)
{
- int key;
+ struct options_entry *o;
+ int key;
if (value == NULL) {
ctx->error(ctx, "empty value");
@@ -123,16 +129,18 @@ set_option_key(struct cmd_ctx *ctx, struct options *oo,
ctx->error(ctx, "unknown key: %s", value);
return;
}
- options_set_number(oo, entry->name, key);
- ctx->info(ctx,
- "set option: %s -> %s", entry->name, key_string_lookup_key(key));
+
+ o = options_set_number(oo, entry->name, key);
+ ctx->info(
+ ctx, "set option: %s -> %s", o->name, set_option_print(entry, o));
}
void
set_option_colour(struct cmd_ctx *ctx, struct options *oo,
const struct set_option_entry *entry, char *value)
{
- int colour;
+ struct options_entry *o;
+ int colour;
if (value == NULL) {
ctx->error(ctx, "empty value");
@@ -144,16 +152,17 @@ set_option_colour(struct cmd_ctx *ctx, struct options *oo,
return;
}
- options_set_number(oo, entry->name, colour);
- ctx->info(ctx,
- "set option: %s -> %s", entry->name, colour_tostring(colour));
+ o = options_set_number(oo, entry->name, colour);
+ ctx->info(
+ ctx, "set option: %s -> %s", o->name, set_option_print(entry, o));
}
void
set_option_attributes(struct cmd_ctx *ctx, struct options *oo,
const struct set_option_entry *entry, char *value)
{
- int attr;
+ struct options_entry *o;
+ int attr;
if (value == NULL) {
ctx->error(ctx, "empty value");
@@ -165,16 +174,17 @@ set_option_attributes(struct cmd_ctx *ctx, struct options *oo,
return;
}
- options_set_number(oo, entry->name, attr);
- ctx->info(ctx,
- "set option: %s -> %s", entry->name, attributes_tostring(attr));
+ o = options_set_number(oo, entry->name, attr);
+ ctx->info(
+ ctx, "set option: %s -> %s", o->name, set_option_print(entry, o));
}
void
set_option_flag(struct cmd_ctx *ctx, struct options *oo,
const struct set_option_entry *entry, char *value)
{
- int flag;
+ struct options_entry *o;
+ int flag;
if (value == NULL || *value == '\0')
flag = !options_get_number(oo, entry->name);
@@ -193,17 +203,18 @@ set_option_flag(struct cmd_ctx *ctx, struct options *oo,
}
}
- options_set_number(oo, entry->name, flag);
- ctx->info(ctx,
- "set option: %s -> %s", entry->name, flag ? "on" : "off");
+ o = options_set_number(oo, entry->name, flag);
+ ctx->info(
+ ctx, "set option: %s -> %s", o->name, set_option_print(entry, o));
}
void
set_option_choice(struct cmd_ctx *ctx, struct options *oo,
const struct set_option_entry *entry, char *value)
{
- const char **choicep;
- int n, choice = -1;
+ struct options_entry *o;
+ const char **choicep;
+ int n, choice = -1;
if (value == NULL) {
ctx->error(ctx, "empty value");
@@ -227,7 +238,7 @@ set_option_choice(struct cmd_ctx *ctx, struct options *oo,
return;
}
- options_set_number(oo, entry->name, choice);
- ctx->info(ctx,
- "set option: %s -> %s", entry->name, entry->choices[choice]);
+ o = options_set_number(oo, entry->name, choice);
+ ctx->info(
+ ctx, "set option: %s -> %s", o->name, set_option_print(entry, o));
}
diff --git a/options.c b/options.c
index ff29c2ec..78a11ae8 100644
--- a/options.c
+++ b/options.c
@@ -1,4 +1,4 @@
-/* $Id: options.c,v 1.7 2009-09-22 13:49:13 tcunha Exp $ */
+/* $Id: options.c,v 1.8 2009-09-22 13:59:46 tcunha Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -98,7 +98,7 @@ options_remove(struct options *oo, const char *name)
xfree(o);
}
-void printflike3
+struct options_entry *printflike3
options_set_string(struct options *oo, const char *name, const char *fmt, ...)
{
struct options_entry *o;
@@ -115,6 +115,7 @@ options_set_string(struct options *oo, const char *name, const char *fmt, ...)
o->type = OPTIONS_STRING;
xvasprintf(&o->str, fmt, ap);
va_end(ap);
+ return (o);
}
char *
@@ -129,7 +130,7 @@ options_get_string(struct options *oo, const char *name)
return (o->str);
}
-void
+struct options_entry *
options_set_number(struct options *oo, const char *name, long long value)
{
struct options_entry *o;
@@ -143,7 +144,7 @@ options_set_number(struct options *oo, const char *name, long long value)
o->type = OPTIONS_NUMBER;
o->num = value;
-
+ return (o);
}
long long
diff --git a/tmux.h b/tmux.h
index 74cc2797..9dc346c8 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1,4 +1,4 @@
-/* $Id: tmux.h,v 1.448 2009-09-22 13:56:02 tcunha Exp $ */
+/* $Id: tmux.h,v 1.449 2009-09-22 13:59:46 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -1157,10 +1157,11 @@ void options_free(struct options *);
struct options_entry *options_find1(struct options *, const char *);
struct options_entry *options_find(struct options *, const char *);
void options_remove(struct options *, const char *);
-void printflike3 options_set_string(
+struct options_entry *printflike3 options_set_string(
struct options *, const char *, const char *, ...);
char *options_get_string(struct options *, const char *);
-void options_set_number(struct options *, const char *, long long);
+struct options_entry *options_set_number(
+ struct options *, const char *, long long);
long long options_get_number(struct options *, const char *);
/* environ.c */