=================================================================== RCS file: /cvs/mandoc/main.c,v retrieving revision 1.148 retrieving revision 1.152 diff -u -p -r1.148 -r1.152 --- mandoc/main.c 2011/03/15 13:24:42 1.148 +++ mandoc/main.c 2011/03/17 08:49:34 1.152 @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.148 2011/03/15 13:24:42 kristaps Exp $ */ +/* $Id: main.c,v 1.152 2011/03/17 08:49:34 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010, 2011 Ingo Schwarze @@ -42,7 +42,6 @@ #endif #define REPARSE_LIMIT 1000 -#define UNCONST(a) ((void *)(uintptr_t)(const void *)(a)) /* FIXME: Intel's compiler? LLVM? pcc? */ @@ -78,6 +77,7 @@ enum outt { }; struct curparse { + enum mandoclevel exit_status; /* status of all file parses */ const char *file; /* current file-name */ enum mandoclevel file_status; /* error status of current parse */ int fd; /* current file-descriptor */ @@ -242,7 +242,6 @@ static void version(void) __attribute__((noreturn)) static int woptions(struct curparse *, char *); static const char *progname; -static enum mandoclevel exit_status = MANDOCLEVEL_OK; int main(int argc, char *argv[]) @@ -261,6 +260,7 @@ main(int argc, char *argv[]) curp.inttype = INTT_AUTO; curp.outtype = OUTT_ASCII; curp.wlevel = MANDOCLEVEL_FATAL; + curp.exit_status = MANDOCLEVEL_OK; /* LINTED */ while (-1 != (c = getopt(argc, argv, "m:O:T:VW:"))) @@ -301,7 +301,7 @@ main(int argc, char *argv[]) while (*argv) { ffile(*argv, &curp); - if (MANDOCLEVEL_OK != exit_status && curp.wstop) + if (MANDOCLEVEL_OK != curp.exit_status && curp.wstop) break; ++argv; } @@ -315,7 +315,7 @@ main(int argc, char *argv[]) if (curp.roff) roff_free(curp.roff); - return((int)exit_status); + return((int)curp.exit_status); } @@ -360,7 +360,7 @@ ffile(const char *file, struct curparse *curp) if (-1 == (curp->fd = open(curp->file, O_RDONLY, 0))) { perror(curp->file); - exit_status = MANDOCLEVEL_SYSERR; + curp->exit_status = MANDOCLEVEL_SYSERR; return; } @@ -405,11 +405,7 @@ resize_buf(struct buf *buf, size_t initial) { buf->sz = buf->sz > initial/2 ? 2 * buf->sz : initial; - buf->buf = realloc(buf->buf, buf->sz); - if (NULL == buf->buf) { - perror(NULL); - exit((int)MANDOCLEVEL_SYSERR); - } + buf->buf = mandoc_realloc(buf->buf, buf->sz); } @@ -619,8 +615,8 @@ fdesc(struct curparse *curp) assert(curp->roff); roff_reset(curp->roff); - if (exit_status < curp->file_status) - exit_status = curp->file_status; + if (curp->exit_status < curp->file_status) + curp->exit_status = curp->file_status; return; } @@ -807,7 +803,7 @@ rerun: pos = 0; continue; case (ROFF_APPEND): - pos = strlen(ln.buf); + pos = (int)strlen(ln.buf); continue; case (ROFF_RERUN): goto rerun;