diff options
Diffstat (limited to 'usr.bin/tmux/paste.c')
-rw-r--r-- | usr.bin/tmux/paste.c | 11 |
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); } |