diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2015-03-17 13:35:05 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2015-03-17 13:35:05 +0000 |
commit | ebf8a77075c42a100917a1ed4688a1d64a24d12f (patch) | |
tree | 03f7b705311a8361a721f5bdf19a61bcb23531f2 /usr.bin/mandoc/main.c | |
parent | 11f7351b9924c48e99b058e700a24a3bde9af5f6 (diff) |
Simplify: Now that rc is global anyway, no need to pass it around
as an argument. No functional change.
Diffstat (limited to 'usr.bin/mandoc/main.c')
-rw-r--r-- | usr.bin/mandoc/main.c | 47 |
1 files changed, 20 insertions, 27 deletions
diff --git a/usr.bin/mandoc/main.c b/usr.bin/mandoc/main.c index 2a13145303a..e58b9a8891c 100644 --- a/usr.bin/mandoc/main.c +++ b/usr.bin/mandoc/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.131 2015/03/17 07:32:21 schwarze Exp $ */ +/* $OpenBSD: main.c,v 1.132 2015/03/17 13:35:04 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2012, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org> @@ -92,9 +92,8 @@ int mandocdb(int, char**); static int moptions(int *, char *); static void mmsg(enum mandocerr, enum mandoclevel, const char *, int, int, const char *); -static void parse(struct curparse *, int, - const char *, enum mandoclevel *); -static enum mandoclevel passthrough(const char *, int, int); +static void parse(struct curparse *, int, const char *); +static void passthrough(const char *, int, int); static pid_t spawn_pager(void); static int toptions(struct curparse *, char *); static void usage(enum argmode) __attribute__((noreturn)); @@ -402,7 +401,7 @@ main(int argc, char *argv[]) if (argc < 1) { if (pager_pid == 1 && isatty(STDOUT_FILENO)) pager_pid = spawn_pager(); - parse(&curp, STDIN_FILENO, "<stdin>", &rc); + parse(&curp, STDIN_FILENO, "<stdin>"); } while (argc > 0) { @@ -416,17 +415,13 @@ main(int argc, char *argv[]) pager_pid = spawn_pager(); if (resp == NULL) - parse(&curp, fd, *argv, &rc); + parse(&curp, fd, *argv); else if (resp->form & FORM_SRC) { /* For .so only; ignore failure. */ chdir(paths.paths[resp->ipath]); - parse(&curp, fd, resp->file, &rc); - } else { - rctmp = passthrough(resp->file, fd, - synopsis_only); - if (rc < rctmp) - rc = rctmp; - } + parse(&curp, fd, resp->file); + } else + passthrough(resp->file, fd, synopsis_only); rctmp = mparse_wait(curp.mp); if (rc < rctmp) @@ -607,10 +602,9 @@ fs_search(const struct mansearch *cfg, const struct manpaths *paths, } static void -parse(struct curparse *curp, int fd, const char *file, - enum mandoclevel *level) +parse(struct curparse *curp, int fd, const char *file) { - enum mandoclevel rc; + enum mandoclevel rctmp; struct mdoc *mdoc; struct man *man; @@ -619,15 +613,17 @@ parse(struct curparse *curp, int fd, const char *file, assert(file); assert(fd >= -1); - rc = mparse_readfd(curp->mp, fd, file); + rctmp = mparse_readfd(curp->mp, fd, file); + if (rc < rctmp) + rc = rctmp; /* * With -Wstop and warnings or errors of at least the requested * level, do not produce output. */ - if (MANDOCLEVEL_OK != rc && curp->wstop) - goto cleanup; + if (rctmp != MANDOCLEVEL_OK && curp->wstop) + return; /* If unset, allocate output dev now (if applicable). */ @@ -705,13 +701,9 @@ parse(struct curparse *curp, int fd, const char *file, (*curp->outman)(curp->outdata, man); if (mdoc && curp->outmdoc) (*curp->outmdoc)(curp->outdata, mdoc); - -cleanup: - if (*level < rc) - *level = rc; } -static enum mandoclevel +static void passthrough(const char *file, int fd, int synopsis_only) { const char synb[] = "S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS"; @@ -769,12 +761,13 @@ passthrough(const char *file, int fd, int synopsis_only) done: fclose(stream); - return(MANDOCLEVEL_OK); + return; fail: fprintf(stderr, "%s: %s: SYSERR: %s: %s", progname, file, syscall, strerror(errno)); - return(MANDOCLEVEL_SYSERR); + if (rc < MANDOCLEVEL_SYSERR) + rc = MANDOCLEVEL_SYSERR; } static int @@ -922,7 +915,7 @@ static void handle_sigpipe(int signum) { - exit(rc); + exit((int)rc); } static pid_t |