diff options
author | Holden Rohrer <hr@hrhr.dev> | 2020-05-29 01:04:23 -0400 |
---|---|---|
committer | Holden Rohrer <hr@hrhr.dev> | 2020-05-29 01:04:23 -0400 |
commit | 0caf0888e98bb504f7421cfa085f4821eecf7966 (patch) | |
tree | ba8f97b25bfd82f23d50b7236e7f68c808f9e675 | |
parent | 6d961236c9a1802de28ed300f7c345cc69a1550f (diff) |
foldlines handles unfoldable lines, merge improved greatly
-rw-r--r-- | badroff.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -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); |