summaryrefslogtreecommitdiffstats
path: root/paste.c
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2022-06-04 10:01:09 +0100
committerThomas Adam <thomas@xteddy.org>2022-06-04 10:01:09 +0100
commitafb3a5fe7180f73457346cf12d096497d93aa642 (patch)
tree115ee9190ae9ff5af5358fdc0ee1662380145aed /paste.c
parente77e11ec6bad1207ab15ee0f148b6a084d9f091c (diff)
parent020c403dff56269d93625970ed41761520afc853 (diff)
Merge branch 'obsd-master'
Diffstat (limited to 'paste.c')
-rw-r--r--paste.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/paste.c b/paste.c
index 51ae2b1d..ad9d71e5 100644
--- a/paste.c
+++ b/paste.c
@@ -111,6 +111,12 @@ paste_walk(struct paste_buffer *pb)
return (RB_NEXT(paste_time_tree, &paste_by_time, pb));
}
+int
+paste_is_empty(void)
+{
+ return RB_ROOT(&paste_by_time) == NULL;
+}
+
/* Get the most recent automatic buffer. */
struct paste_buffer *
paste_get_top(const char **name)
@@ -118,6 +124,8 @@ paste_get_top(const char **name)
struct paste_buffer *pb;
pb = RB_MIN(paste_time_tree, &paste_by_time);
+ while (pb != NULL && !pb->automatic)
+ pb = RB_NEXT(paste_time_tree, &paste_by_time, pb);
if (pb == NULL)
return (NULL);
if (name != NULL)