From 77638505b32fc938c30b24e87f9dde2d8dc39924 Mon Sep 17 00:00:00 2001 From: Holden Rohrer Date: Mon, 18 May 2020 21:28:17 -0400 Subject: moved folding logic away from lineset, starting to generalize --- badroff.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/badroff.c b/badroff.c index 3d96fc7..e73dd99 100644 --- a/badroff.c +++ b/badroff.c @@ -148,9 +148,7 @@ llnode* accumlines(size_t* ct){ // returns tail of linked list endgroup = false; // prevents false positive on next run return tail; } -char* lineset(char* txt){ - size_t ct; - llnode* tail = accumlines(&ct); +char* foldlines(llnode* tail, size_t ct){ sb* buf = newsb(100); size_t oldbrk = 0, brk = 0; @@ -178,8 +176,12 @@ char* lineset(char* txt){ } } - char* lines = decompose(buf); - return lines; + return decompose(buf); +} +char* lineset(char* txt){ + size_t ct; + llnode* tail = accumlines(&ct); + return foldlines(tail, ct); } char* emptalloc(void){ // need a null string so it can be freed later char* str = malloc(sizeof(char)); str[0] = 0; -- cgit