From d6927385079d4fc8e93729813362b9123340c85e Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Thu, 19 Mar 2009 18:30:26 +0000 Subject: Fixed mandoc read from stdin. Added some more groff_chars. --- main.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 703b9483..31ed41d4 100644 --- a/main.c +++ b/main.c @@ -165,19 +165,33 @@ main(int argc, char *argv[]) mdoc = mdoc_alloc(&wflags, fflags, &cb); - while (*argv) { - if ( ! file(&line, &linesz, &buf, &bufsz, *argv, mdoc)) - break; - if (outrun && ! (*outrun)(outdata, mdoc)) - break; + /* + * Loop around available files. + */ - /* Reset the parser for another file. */ - mdoc_reset(mdoc); - argv++; + if (NULL == *argv) { + c = fdesc(&line, &linesz, &buf, &bufsz, + "stdin", STDIN_FILENO, mdoc); + rc = 0; + if (c && NULL == outrun) + rc = 1; + else if (c && outrun && (*outrun)(outdata, mdoc)) + rc = 1; + } else { + while (*argv) { + c = file(&line, &linesz, &buf, + &bufsz, *argv, mdoc); + if ( ! c) + break; + if (outrun && ! (*outrun)(outdata, mdoc)) + break; + /* Reset the parser for another file. */ + mdoc_reset(mdoc); + argv++; + } + rc = NULL == *argv; } - rc = NULL == *argv; - if (buf) free(buf); if (line) -- cgit