summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/cmd-save-buffer.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2014-05-13 07:34:35 +0000
committernicm <nicm@openbsd.org>2014-05-13 07:34:35 +0000
commita41fa27a7a7d81a2718aed810231593ca5d4d42a (patch)
tree6f9e54947c41df6d05b7c7b9a6ec979545ee9031 /usr.bin/tmux/cmd-save-buffer.c
parentSince this is limited to ffs, use ufsinfo_t instead of ino_t. (diff)
downloadwireguard-openbsd-a41fa27a7a7d81a2718aed810231593ca5d4d42a.tar.xz
wireguard-openbsd-a41fa27a7a7d81a2718aed810231593ca5d4d42a.zip
Add support for named buffers. If you don't name a buffer, things work
much as before - buffers are automatically named "buffer0000", "buffer0001" and so on and ordered as a stack. Buffers can be named explicitly when creating ("loadb -b foo" etc) or renamed ("setb -b buffer0000 -n foo"). If buffers are named explicitly, they are not deleted when buffer-limit is reached. Diff from J Raynor.
Diffstat (limited to 'usr.bin/tmux/cmd-save-buffer.c')
-rw-r--r--usr.bin/tmux/cmd-save-buffer.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/usr.bin/tmux/cmd-save-buffer.c b/usr.bin/tmux/cmd-save-buffer.c
index d5bd640530c..8803aa90c11 100644
--- a/usr.bin/tmux/cmd-save-buffer.c
+++ b/usr.bin/tmux/cmd-save-buffer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-save-buffer.c,v 1.24 2014/04/24 09:14:43 nicm Exp $ */
+/* $OpenBSD: cmd-save-buffer.c,v 1.25 2014/05/13 07:34:35 nicm Exp $ */
/*
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
@@ -59,10 +59,10 @@ cmd_save_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
struct client *c = cmdq->client;
struct session *s;
struct paste_buffer *pb;
- const char *path;
- char *cause, *start, *end, *msg;
+ const char *path, *bufname;
+ char *start, *end, *msg;
size_t size, used, msglen;
- int cwd, fd, buffer;
+ int cwd, fd;
FILE *f;
if (!args_has(args, 'b')) {
@@ -71,16 +71,10 @@ cmd_save_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
return (CMD_RETURN_ERROR);
}
} else {
- buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
- if (cause != NULL) {
- cmdq_error(cmdq, "buffer %s", cause);
- free(cause);
- return (CMD_RETURN_ERROR);
- }
-
- pb = paste_get_index(buffer);
+ bufname = args_get(args, 'b');
+ pb = paste_get_name(bufname);
if (pb == NULL) {
- cmdq_error(cmdq, "no buffer %d", buffer);
+ cmdq_error(cmdq, "no buffer %s", bufname);
return (CMD_RETURN_ERROR);
}
}