From 2e2f16f714e9724d188cd5d27d4de155d0887f36 Mon Sep 17 00:00:00 2001
From: Holden Rohrer
Date: Tue, 31 Mar 2020 16:47:09 -0400
Subject: added new .FIL cmd and fixed lots of typeset bugs
---
badroff.c | 33 ++++++++++++++++++++++-----------
1 file changed, 22 insertions(+), 11 deletions(-)
diff --git a/badroff.c b/badroff.c
index 3e2bd12..7dff4f1 100644
--- a/badroff.c
+++ b/badroff.c
@@ -64,7 +64,6 @@ size_t chrnfill(char chr, size_t sz){//fills to first of chr or sz
// typesetting config and commands to change.
int width = 80;
-bool brk = false; // not implemented
char* center(char* txt){
size_t len = strlen(txt);
@@ -81,9 +80,15 @@ char* setwidth(char* txt){
sscanf(txt, "%d", &width);
return NULL;
}
+char* fillline(char* txt){
+ char* str = malloc(sizeof(char)*(width+2));
+ str[width] = '\n'; str[width+1] = 0;
+ memset(str, txt[0], width);
+ return str;
+}
-char* cmds[] = {"CT ", "W "};
-char* (*call[])(char* txt) = {center, setwidth};
+char* cmds[] = {"CT ", "FIL ", "W "}; // MUST be sorted alphabetically
+char* (*call[])(char* txt) = {center, fillline, setwidth};
char* cmd(void){
char* dat = popstrbuf(inbuf, chrfill('\n'));
@@ -118,7 +123,7 @@ size_t nextws(size_t start){//searches for \n or [^ \n]-1 in buffer
size_t i;
for (i = 0; i