From 0caf0888e98bb504f7421cfa085f4821eecf7966 Mon Sep 17 00:00:00 2001 From: Holden Rohrer Date: Fri, 29 May 2020 01:04:23 -0400 Subject: foldlines handles unfoldable lines, merge improved greatly --- badroff.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/badroff.c b/badroff.c index 7814d62..80d347c 100644 --- a/badroff.c +++ b/badroff.c @@ -161,7 +161,7 @@ static void multbreak(sb* buffer, size_t start, static char* foldlines(llnode* tail, size_t ct){ sb* buf = newsb(100); - size_t oldbrk = 0, brk = 0; + int oldbrk = 0, brk = -1; for (size_t i = 0; tail; i++){ // check every column until all rows // are removed. bool valid = true; // if stays true, this is a space @@ -245,10 +245,13 @@ static char* nbrkspc(char* txt){ } static char* join = NULL; static char* merge(char* txt){ // merges until an endgroup + join = txt; for (char* pos = txt; *pos != '\0'; pos++) { + *txt = *pos; if (*pos != '\\') txt++; - *pos = *txt; } + *(txt-1) = 0; + join = strdup(join); return NULL; } static char* nomrg(char* txt){ @@ -335,8 +338,8 @@ char* wordset(char* txt){ static char* norm(void){ - int len = chrfill('\n'); - char* out = popstrbuf(inbuf,len); + int len = chrfill('\n'); // len = strlen(out) = sizeof(out)-1 + char* out = popstrbuf(inbuf,len); // out[len-1] = '\n' if (join) { out = realloc(out, len+strlen(join)-1); strcpy(out+len-1, /* \n loc */ join); -- cgit