summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/paste.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2019-04-02 09:03:40 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2019-04-02 09:03:40 +0000
commitdb0fa372a961f9ae95e69ed401ec6c93c4a3eee4 (patch)
tree7df2c146efe72df316fbc0fdac351b40300740ac /usr.bin/tmux/paste.c
parent5342d0744c57f49bf0cf8917f6a0674f81dd48cb (diff)
Add an argument to copy commands to set the prefix for the buffer name,
allows buffers for different sessions to be named separately.
Diffstat (limited to 'usr.bin/tmux/paste.c')
-rw-r--r--usr.bin/tmux/paste.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/usr.bin/tmux/paste.c b/usr.bin/tmux/paste.c
index 9c77846010e..a6b925b05f0 100644
--- a/usr.bin/tmux/paste.c
+++ b/usr.bin/tmux/paste.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: paste.c,v 1.39 2017/01/24 13:28:33 nicm Exp $ */
+/* $OpenBSD: paste.c,v 1.40 2019/04/02 09:03:39 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -158,11 +158,14 @@ paste_free(struct paste_buffer *pb)
* that the caller is responsible for allocating data.
*/
void
-paste_add(char *data, size_t size)
+paste_add(const char *prefix, char *data, size_t size)
{
struct paste_buffer *pb, *pb1;
u_int limit;
+ if (prefix == NULL)
+ prefix = "buffer";
+
if (size == 0) {
free(data);
return;
@@ -181,7 +184,7 @@ paste_add(char *data, size_t size)
pb->name = NULL;
do {
free(pb->name);
- xasprintf(&pb->name, "buffer%04u", paste_next_index);
+ xasprintf(&pb->name, "%s%u", prefix, paste_next_index);
paste_next_index++;
} while (paste_get_name(pb->name) != NULL);
@@ -263,7 +266,7 @@ paste_set(char *data, size_t size, const char *name, char **cause)
return (0);
}
if (name == NULL) {
- paste_add(data, size);
+ paste_add(NULL, data, size);
return (0);
}