version 1.150, 2011/03/15 16:23:51 |
version 1.153, 2011/03/17 12:08:01 |
|
|
}; |
}; |
|
|
struct curparse { |
struct curparse { |
|
enum mandoclevel exit_status; /* status of all file parses */ |
const char *file; /* current file-name */ |
const char *file; /* current file-name */ |
enum mandoclevel file_status; /* error status of current parse */ |
enum mandoclevel file_status; /* error status of current parse */ |
int fd; /* current file-descriptor */ |
int fd; /* current file-descriptor */ |
Line 232 static void fdesc(struct curparse *); |
|
Line 233 static void fdesc(struct curparse *); |
|
static void ffile(const char *, struct curparse *); |
static void ffile(const char *, struct curparse *); |
static int pfile(const char *, struct curparse *); |
static int pfile(const char *, struct curparse *); |
static int moptions(enum intt *, char *); |
static int moptions(enum intt *, char *); |
static int mmsg(enum mandocerr, void *, |
static void mmsg(enum mandocerr, void *, |
int, int, const char *); |
int, int, const char *); |
static void pset(const char *, int, struct curparse *); |
static void pset(const char *, int, struct curparse *); |
static int toptions(struct curparse *, char *); |
static int toptions(struct curparse *, char *); |
Line 241 static void version(void) __attribute__((noreturn)) |
|
Line 242 static void version(void) __attribute__((noreturn)) |
|
static int woptions(struct curparse *, char *); |
static int woptions(struct curparse *, char *); |
|
|
static const char *progname; |
static const char *progname; |
static enum mandoclevel exit_status = MANDOCLEVEL_OK; |
|
|
|
int |
int |
main(int argc, char *argv[]) |
main(int argc, char *argv[]) |
Line 260 main(int argc, char *argv[]) |
|
Line 260 main(int argc, char *argv[]) |
|
curp.inttype = INTT_AUTO; |
curp.inttype = INTT_AUTO; |
curp.outtype = OUTT_ASCII; |
curp.outtype = OUTT_ASCII; |
curp.wlevel = MANDOCLEVEL_FATAL; |
curp.wlevel = MANDOCLEVEL_FATAL; |
|
curp.exit_status = MANDOCLEVEL_OK; |
|
|
/* LINTED */ |
/* LINTED */ |
while (-1 != (c = getopt(argc, argv, "m:O:T:VW:"))) |
while (-1 != (c = getopt(argc, argv, "m:O:T:VW:"))) |
Line 300 main(int argc, char *argv[]) |
|
Line 301 main(int argc, char *argv[]) |
|
|
|
while (*argv) { |
while (*argv) { |
ffile(*argv, &curp); |
ffile(*argv, &curp); |
if (MANDOCLEVEL_OK != exit_status && curp.wstop) |
if (MANDOCLEVEL_OK != curp.exit_status && curp.wstop) |
break; |
break; |
++argv; |
++argv; |
} |
} |
Line 314 main(int argc, char *argv[]) |
|
Line 315 main(int argc, char *argv[]) |
|
if (curp.roff) |
if (curp.roff) |
roff_free(curp.roff); |
roff_free(curp.roff); |
|
|
return((int)exit_status); |
return((int)curp.exit_status); |
} |
} |
|
|
|
|
Line 359 ffile(const char *file, struct curparse *curp) |
|
Line 360 ffile(const char *file, struct curparse *curp) |
|
|
|
if (-1 == (curp->fd = open(curp->file, O_RDONLY, 0))) { |
if (-1 == (curp->fd = open(curp->file, O_RDONLY, 0))) { |
perror(curp->file); |
perror(curp->file); |
exit_status = MANDOCLEVEL_SYSERR; |
curp->exit_status = MANDOCLEVEL_SYSERR; |
return; |
return; |
} |
} |
|
|
Line 404 resize_buf(struct buf *buf, size_t initial) |
|
Line 405 resize_buf(struct buf *buf, size_t initial) |
|
{ |
{ |
|
|
buf->sz = buf->sz > initial/2 ? 2 * buf->sz : initial; |
buf->sz = buf->sz > initial/2 ? 2 * buf->sz : initial; |
buf->buf = realloc(buf->buf, buf->sz); |
buf->buf = mandoc_realloc(buf->buf, buf->sz); |
if (NULL == buf->buf) { |
|
perror(NULL); |
|
exit((int)MANDOCLEVEL_SYSERR); |
|
} |
|
} |
} |
|
|
|
|
Line 618 fdesc(struct curparse *curp) |
|
Line 615 fdesc(struct curparse *curp) |
|
assert(curp->roff); |
assert(curp->roff); |
roff_reset(curp->roff); |
roff_reset(curp->roff); |
|
|
if (exit_status < curp->file_status) |
if (curp->exit_status < curp->file_status) |
exit_status = curp->file_status; |
curp->exit_status = curp->file_status; |
|
|
return; |
return; |
} |
} |
Line 1039 woptions(struct curparse *curp, char *arg) |
|
Line 1036 woptions(struct curparse *curp, char *arg) |
|
return(1); |
return(1); |
} |
} |
|
|
static int |
static void |
mmsg(enum mandocerr t, void *arg, int ln, int col, const char *msg) |
mmsg(enum mandocerr t, void *arg, int ln, int col, const char *msg) |
{ |
{ |
struct curparse *cp; |
struct curparse *cp; |
Line 1052 mmsg(enum mandocerr t, void *arg, int ln, int col, con |
|
Line 1049 mmsg(enum mandocerr t, void *arg, int ln, int col, con |
|
|
|
cp = (struct curparse *)arg; |
cp = (struct curparse *)arg; |
if (level < cp->wlevel) |
if (level < cp->wlevel) |
return(1); |
return; |
|
|
fprintf(stderr, "%s:%d:%d: %s: %s", |
fprintf(stderr, "%s:%d:%d: %s: %s", |
cp->file, ln, col + 1, mandoclevels[level], mandocerrs[t]); |
cp->file, ln, col + 1, mandoclevels[level], mandocerrs[t]); |
Line 1062 mmsg(enum mandocerr t, void *arg, int ln, int col, con |
|
Line 1059 mmsg(enum mandocerr t, void *arg, int ln, int col, con |
|
|
|
if (cp->file_status < level) |
if (cp->file_status < level) |
cp->file_status = level; |
cp->file_status = level; |
|
|
return(level < MANDOCLEVEL_FATAL); |
|
} |
} |