diff options
author | Holden Rohrer <hr@hrhr.dev> | 2020-03-30 23:53:26 -0400 |
---|---|---|
committer | Holden Rohrer <hr@hrhr.dev> | 2020-03-30 23:53:26 -0400 |
commit | f995a0a66e665592b18cb053ee727093f0f5617b (patch) | |
tree | 5249c3ad81682721f493d3006d0f94093896b175 | |
parent | d87022dad4efdf4395c15b4de63a894b358bcf7c (diff) |
added peekchrbuf to buf
-rw-r--r-- | buf.c | 7 | ||||
-rw-r--r-- | buf.h | 1 |
2 files changed, 8 insertions, 0 deletions
@@ -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]; +} @@ -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 |