aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHolden Rohrer <hr@hrhr.dev>2020-03-30 17:24:42 -0400
committerHolden Rohrer <hr@hrhr.dev>2020-03-30 17:24:50 -0400
commit4b28d69cb526c7730c8e7cb0ab14e2a77e732211 (patch)
tree9a7ddc535789e03e23c0d57770238c48d7e20365
parentf89d0c407e0a581826559dc1e118cb6583889849 (diff)
minor changes and actually exiting w/ return code
-rw-r--r--badroff.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/badroff.c b/badroff.c
index 8a7f825..3d715fb 100644
--- a/badroff.c
+++ b/badroff.c
@@ -56,7 +56,7 @@ char* cmd(void){
if (!strncmp(dat, "CT ", 3)){
return center(dat+3);
}
- return "";
+ return NULL;
}
char* typeset(void){
@@ -68,13 +68,12 @@ char* line(void){
if ( (sz = fillbuf(2)) == 0)
return "";
char* twobytes = peekstrbuf(inbuf, 0, 2); // .., .\n, or ^.?
- if (sz == 1) return typeset();
- if (twobytes[0] == '.' && twobytes[1] == '\n') return typeset();
+ if (sz == 1 || twobytes[1] == '\n') return typeset();
if (twobytes[0] == '.') popchrbuf(inbuf);
if (twobytes[0] == '.' && twobytes[1] != '.'){
char* data = cmd();
- if (data[0] != '\0') return data;
- else return line();
+ if (data) return data;
+ return line();
} else {
return typeset();
}
@@ -93,4 +92,5 @@ int main(int argc, char** argv){
printf("%s",out);
}
fclose(in);
+ return 0;
}