aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--badroff.c11
1 files 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);