aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHolden Rohrer <hr@hrhr.dev>2020-05-18 21:28:17 -0400
committerHolden Rohrer <hr@hrhr.dev>2020-05-18 21:28:17 -0400
commit77638505b32fc938c30b24e87f9dde2d8dc39924 (patch)
tree210c7b72b6cfaec77e4875cc5d10a32f0fd2cf59
parent38c700a0915aa6cf6b2111f6ae72c584f16d4826 (diff)
moved folding logic away from lineset, starting to generalize
-rw-r--r--badroff.c12
1 files 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;