diff options
author | Tiago Cunha <tcunha@gmx.com> | 2009-08-09 16:48:34 +0000 |
---|---|---|
committer | Tiago Cunha <tcunha@gmx.com> | 2009-08-09 16:48:34 +0000 |
commit | 65a28912ebf180f736f29fcecc3c87223e5ee533 (patch) | |
tree | 4dd079332c2227ebaf2353a816019fbe89f00e48 /options-cmd.c | |
parent | d8a2ceea438df9fcf235ce7e1b2700d734fd5d77 (diff) | |
download | rtmux-65a28912ebf180f736f29fcecc3c87223e5ee533.tar.gz rtmux-65a28912ebf180f736f29fcecc3c87223e5ee533.tar.bz2 rtmux-65a28912ebf180f736f29fcecc3c87223e5ee533.zip |
Sync OpenBSD patchset 219:
Add a -a flag to set-option and set-window-option to append to an existing
string value, useful for terminal-overrides.
Diffstat (limited to 'options-cmd.c')
-rw-r--r-- | options-cmd.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/options-cmd.c b/options-cmd.c index 2c1ab636..e328fea2 100644 --- a/options-cmd.c +++ b/options-cmd.c @@ -1,4 +1,4 @@ -/* $Id: options-cmd.c,v 1.4 2009-01-27 20:22:33 nicm Exp $ */ +/* $Id: options-cmd.c,v 1.5 2009-08-09 16:48:34 tcunha Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -25,15 +25,26 @@ void set_option_string(struct cmd_ctx *ctx, struct options *oo, - const struct set_option_entry *entry, char *value) + const struct set_option_entry *entry, char *value, int append) { + char *oldvalue, *newvalue; + if (value == NULL) { ctx->error(ctx, "empty value"); return; } - options_set_string(oo, entry->name, "%s", value); - ctx->info(ctx, "set option: %s -> %s", entry->name, value); + if (append) { + oldvalue = options_get_string(oo, entry->name); + xasprintf(&newvalue, "%s%s", oldvalue, value); + } else + newvalue = value; + + options_set_string(oo, entry->name, "%s", newvalue); + ctx->info(ctx, "set option: %s -> %s", entry->name, newvalue); + + if (newvalue != value) + xfree(newvalue); } void |