summary refs log tree commit diff
path: root/ring.c
diff options
context:
space:
mode:
Diffstat (limited to 'ring.c')
-rw-r--r--ring.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/ring.c b/ring.c
index 912d0d3..409fcd4 100644
--- a/ring.c
+++ b/ring.c
@@ -70,17 +70,23 @@ size_t ringDiff(size_t consumer) {
 	return ring.write - read.ptrs[consumer];
 }
 
-const char *ringConsume(time_t *time, size_t consumer) {
+const char *ringPeek(time_t *time, size_t consumer) {
 	assert(consumer < read.len);
 	if (!ringDiff(consumer)) return NULL;
 	if (ringDiff(consumer) > RingLen) {
 		read.ptrs[consumer] = ring.write - RingLen;
 	}
-	size_t i = read.ptrs[consumer]++ % RingLen;
+	size_t i = read.ptrs[consumer] % RingLen;
 	if (time) *time = ring.times[i];
 	return ring.lines[i];
 }
 
+const char *ringConsume(time_t *time, size_t consumer) {
+	const char *line = ringPeek(time, consumer);
+	read.ptrs[consumer]++;
+	return line;
+}
+
 void ringInfo(void) {
 	fprintf(stderr, "producer: %zu\n", ring.write);
 	for (size_t i = 0; i < read.len; ++i) {
tle='2019-07-12 18:41:04 -0400'>2019-07-12Support insert mode in shottyJune McEnroe 2019-07-11Don't do carriage return on line feedJune McEnroe 2019-07-11Interpret 256color-style SGRsJune McEnroe 2019-07-11Use inline style rather than <b>, <i>, <u>June McEnroe 2019-07-11Factor out clearJune McEnroe 2019-07-11Add bright option to shottyJune McEnroe 2019-07-11Output <b>, <i>, <u> in shottyJune McEnroe 2019-07-10Ignore SM and RMJune McEnroe 2019-07-09Add shotty man page and build itJune McEnroe 2019-07-09Add up -cJune McEnroe 2019-07-09Add options for default colors to shottyJune McEnroe 2019-07-08Use char literals consistentlyJune McEnroe