summaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-03-19 18:30:26 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-03-19 18:30:26 +0000
commitd6927385079d4fc8e93729813362b9123340c85e (patch)
treead3b4b516d0465d5e11f62dec51d6427be849fca /main.c
parent677b18213e2f3cdbe7bb2c9df54a0e2488c89714 (diff)
downloadmandoc-d6927385079d4fc8e93729813362b9123340c85e.tar.gz
Fixed mandoc read from stdin.
Added some more groff_chars.
Diffstat (limited to 'main.c')
-rw-r--r--main.c34
1 files changed, 24 insertions, 10 deletions
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)