=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mandoc/main.c,v retrieving revision 1.131 retrieving revision 1.132 diff -c -r1.131 -r1.132 *** src/usr.bin/mandoc/main.c 2015/03/17 07:32:21 1.131 --- src/usr.bin/mandoc/main.c 2015/03/17 13:35:04 1.132 *************** *** 1,4 **** ! /* $OpenBSD: main.c,v 1.131 2015/03/17 07:32:21 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010-2012, 2014, 2015 Ingo Schwarze --- 1,4 ---- ! /* $OpenBSD: main.c,v 1.132 2015/03/17 13:35:04 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010-2012, 2014, 2015 Ingo Schwarze *************** *** 92,100 **** 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 pid_t spawn_pager(void); static int toptions(struct curparse *, char *); static void usage(enum argmode) __attribute__((noreturn)); --- 92,99 ---- 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 *); ! 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,408 **** if (argc < 1) { if (pager_pid == 1 && isatty(STDOUT_FILENO)) pager_pid = spawn_pager(); ! parse(&curp, STDIN_FILENO, "", &rc); } while (argc > 0) { --- 401,407 ---- if (argc < 1) { if (pager_pid == 1 && isatty(STDOUT_FILENO)) pager_pid = spawn_pager(); ! parse(&curp, STDIN_FILENO, ""); } while (argc > 0) { *************** *** 416,432 **** pager_pid = spawn_pager(); if (resp == NULL) ! parse(&curp, fd, *argv, &rc); 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; ! } rctmp = mparse_wait(curp.mp); if (rc < rctmp) --- 415,427 ---- pager_pid = spawn_pager(); if (resp == NULL) ! 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); ! } else ! passthrough(resp->file, fd, synopsis_only); rctmp = mparse_wait(curp.mp); if (rc < rctmp) *************** *** 607,616 **** } static void ! parse(struct curparse *curp, int fd, const char *file, ! enum mandoclevel *level) { ! enum mandoclevel rc; struct mdoc *mdoc; struct man *man; --- 602,610 ---- } static void ! parse(struct curparse *curp, int fd, const char *file) { ! enum mandoclevel rctmp; struct mdoc *mdoc; struct man *man; *************** *** 619,633 **** assert(file); assert(fd >= -1); ! rc = mparse_readfd(curp->mp, fd, file); /* * 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 unset, allocate output dev now (if applicable). */ --- 613,629 ---- assert(file); assert(fd >= -1); ! 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 (rctmp != MANDOCLEVEL_OK && curp->wstop) ! return; /* If unset, allocate output dev now (if applicable). */ *************** *** 705,717 **** (*curp->outman)(curp->outdata, man); if (mdoc && curp->outmdoc) (*curp->outmdoc)(curp->outdata, mdoc); - - cleanup: - if (*level < rc) - *level = rc; } ! static enum mandoclevel passthrough(const char *file, int fd, int synopsis_only) { const char synb[] = "S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS"; --- 701,709 ---- (*curp->outman)(curp->outdata, man); if (mdoc && curp->outmdoc) (*curp->outmdoc)(curp->outdata, mdoc); } ! static void passthrough(const char *file, int fd, int synopsis_only) { const char synb[] = "S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS"; *************** *** 769,780 **** done: fclose(stream); ! return(MANDOCLEVEL_OK); fail: fprintf(stderr, "%s: %s: SYSERR: %s: %s", progname, file, syscall, strerror(errno)); ! return(MANDOCLEVEL_SYSERR); } static int --- 761,773 ---- done: fclose(stream); ! return; fail: fprintf(stderr, "%s: %s: SYSERR: %s: %s", progname, file, syscall, strerror(errno)); ! if (rc < MANDOCLEVEL_SYSERR) ! rc = MANDOCLEVEL_SYSERR; } static int *************** *** 922,928 **** handle_sigpipe(int signum) { ! exit(rc); } static pid_t --- 915,921 ---- handle_sigpipe(int signum) { ! exit((int)rc); } static pid_t