From 4b28d69cb526c7730c8e7cb0ab14e2a77e732211 Mon Sep 17 00:00:00 2001 From: Holden Rohrer Date: Mon, 30 Mar 2020 17:24:42 -0400 Subject: minor changes and actually exiting w/ return code --- badroff.c | 10 +++++----- 1 file 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; } -- cgit