=================================================================== RCS file: /cvs/mandoc/main.c,v retrieving revision 1.213 retrieving revision 1.216 diff -u -p -r1.213 -r1.216 --- mandoc/main.c 2015/01/13 23:17:52 1.213 +++ mandoc/main.c 2015/01/16 21:15:05 1.216 @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.213 2015/01/13 23:17:52 schwarze Exp $ */ +/* $Id: main.c,v 1.216 2015/01/16 21:15:05 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010-2012, 2014, 2015 Ingo Schwarze @@ -19,6 +19,7 @@ #include "config.h" #include +#include /* MACHINE */ #include #include @@ -131,7 +132,7 @@ main(int argc, char *argv[]) int prio, best_prio, synopsis_only; char sec; #endif - enum mandoclevel rc; + enum mandoclevel rc, rctmp; enum outmode outmode; int fd; int show_usage; @@ -176,7 +177,7 @@ main(int argc, char *argv[]) memset(&curp, 0, sizeof(struct curparse)); curp.outtype = OUTT_LOCALE; - curp.wlevel = MANDOCLEVEL_FATAL; + curp.wlevel = MANDOCLEVEL_BADARG; options = MPARSE_SO | MPARSE_UTF8 | MPARSE_LATIN1; defos = NULL; @@ -328,6 +329,10 @@ main(int argc, char *argv[]) argv++; argc--; } + if (search.arch == NULL) + search.arch = getenv("MACHINE"); + if (search.arch == NULL) + search.arch = MACHINE; } rc = MANDOCLEVEL_OK; @@ -431,11 +436,13 @@ main(int argc, char *argv[]) } while (argc) { - rc = mparse_open(curp.mp, &fd, + rctmp = mparse_open(curp.mp, &fd, #if HAVE_SQLITE3 resp != NULL ? resp->file : #endif *argv); + if (rc < rctmp) + rc = rctmp; if (fd != -1) { if (use_pager && isatty(STDOUT_FILENO)) @@ -451,13 +458,17 @@ main(int argc, char *argv[]) /* For .so only; ignore failure. */ chdir(paths.paths[resp->ipath]); parse(&curp, fd, resp->file, &rc); - } else - rc = passthrough(resp->file, fd, + } else { + rctmp = passthrough(resp->file, fd, synopsis_only); + if (rc < rctmp) + rc = rctmp; + } #endif - if (mparse_wait(curp.mp) != MANDOCLEVEL_OK) - rc = MANDOCLEVEL_SYSERR; + rctmp = mparse_wait(curp.mp); + if (rc < rctmp) + rc = rctmp; if (argc > 1 && curp.outtype <= OUTT_UTF8) ascii_sepline(curp.outdata); @@ -641,11 +652,6 @@ parse(struct curparse *curp, int fd, const char *file, rc = mparse_readfd(curp->mp, fd, file); - /* Stop immediately if the parse has failed. */ - - if (MANDOCLEVEL_FATAL <= rc) - goto cleanup; - /* * With -Wstop and warnings or errors of at least the requested * level, do not produce output. @@ -907,7 +913,7 @@ woptions(struct curparse *curp, char *arg) curp->wlevel = MANDOCLEVEL_ERROR; break; case 4: - curp->wlevel = MANDOCLEVEL_FATAL; + curp->wlevel = MANDOCLEVEL_BADARG; break; default: fprintf(stderr, "%s: -W %s: Bad argument\n",