From f995a0a66e665592b18cb053ee727093f0f5617b Mon Sep 17 00:00:00 2001
From: Holden Rohrer
Date: Mon, 30 Mar 2020 23:53:26 -0400
Subject: added peekchrbuf to buf
---
buf.c | 7 +++++++
buf.h | 1 +
2 files changed, 8 insertions(+)
diff --git a/buf.c b/buf.c
index a219773..7e270c3 100644
--- a/buf.c
+++ b/buf.c
@@ -110,3 +110,10 @@ char* peekstrbuf(buf* buffer, size_t loc, size_t len){
}
return str;
}
+char peekchrbuf(buf* buffer, size_t loc){
+ buf_node* start;
+ loc += buffer->pop;
+ for (start = buffer->tail; loc>buffer->cap; loc -= buffer->cap)
+ start = start->next;
+ return start->text[loc];
+}
diff --git a/buf.h b/buf.h
index d142148..9b2a996 100644
--- a/buf.h
+++ b/buf.h
@@ -16,5 +16,6 @@ void inschrbuf(buf* buffer, char chr);
void insstrbuf(buf* buffer, char* str);
char* peekstrbuf(buf* buffer, size_t loc, size_t len);
+char peekchrbuf(buf* buffer, size_t loc);
#endif
--
cgit