aboutsummaryrefslogtreecommitdiff
path: root/badroff.c
diff options
context:
space:
mode:
Diffstat (limited to 'badroff.c')
-rw-r--r--badroff.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/badroff.c b/badroff.c
index c86e29f..baed5a7 100644
--- a/badroff.c
+++ b/badroff.c
@@ -146,11 +146,15 @@ char* finlineset(char* txt){
endlineset = true;
return str;
}
+char* vert(char* txt){
+ int ln; sscanf(txt, "%d", &ln);
+ return chrmult('\n', ln);
+}
char* cmds[] = // MUST be sorted alphabetically
- {"CT ", "ELS", "FIL ", "LD ", "LS", "W "};
+ {"CT ", "ELS", "FIL ", "LD ", "LS", "V ", "W "};
char* (*call[])(char* txt) =
- {center, finlineset, fillline, leader, lineset, setwidth};
+ {center, finlineset, fillline, leader, lineset, vert, setwidth};
char* cmd(void){
char* dat = popstrbuf(inbuf, chrfill('\n'));
@@ -209,9 +213,8 @@ char* wordset(char* txt){
}
-char* typeset(void){
- size_t len = chrfill('\n');
- return wordset(popstrbuf(inbuf, len));
+char* norm(void){
+ return popstrbuf(inbuf, chrfill('\n'));
}
// a parser to choose when to typeset and when to run a command
@@ -221,14 +224,14 @@ char* line(void){
if ( (sz = fillbuf(2)) == 0)
return "";
char* twobytes = peekstrbuf(inbuf, 0, 2); // .., .\n, or ^.?
- if (sz == 1 || twobytes[1] == '\n') return typeset();
+ if (sz == 1 || twobytes[1] == '\n') return norm();
if (twobytes[0] == '.') popchrbuf(inbuf);
if (twobytes[0] == '.' && twobytes[1] != '.'){
char* data = cmd();
if (data) return data;
return line();
} else {
- return typeset();
+ return norm();
}
}
@@ -244,8 +247,8 @@ int main(int argc, char** argv){
}
char* out;
while ( (out = line())[0] != '\0'){
- printf("%s",out);
- // free(out);
+ printf("%s",wordset(out));
+ free(out);
}
fclose(in);
return 0;