diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2018-12-14 01:17:47 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2018-12-14 01:17:47 +0000 |
commit | 6a76c27b111b58fe097f93aad3fe3382e68dca2b (patch) | |
tree | d773bd6b0dea93a52a02448fe91f1d7efb1d42fa | |
parent | 5ac712832fc9d0ee58e5ca5dac1d4c4724e741dc (diff) |
Major cleanup; may imply minor changes in edge cases of error reporting.
Finally, drop support for the run-time configurable mandocmsg()
callback. It was over-engineered from the start, never used for
anything in a decade, and repeatedly caused maintenance headaches.
Consolidate reporting infrastructure into two files, mandoc.h and
mandoc_msg.c, mopping up the bits and pieces that were scattered
around main.c, read.c, mandoc_parse.h, libmandoc.h, the prototypes
of four parsing-related functions, and both parser structs.
-rw-r--r-- | usr.bin/mandoc/Makefile | 8 | ||||
-rw-r--r-- | usr.bin/mandoc/cgi.c | 4 | ||||
-rw-r--r-- | usr.bin/mandoc/chars.c | 3 | ||||
-rw-r--r-- | usr.bin/mandoc/libmandoc.h | 7 | ||||
-rw-r--r-- | usr.bin/mandoc/main.c | 112 | ||||
-rw-r--r-- | usr.bin/mandoc/man_macro.c | 3 | ||||
-rw-r--r-- | usr.bin/mandoc/man_validate.c | 3 | ||||
-rw-r--r-- | usr.bin/mandoc/mandoc.h | 16 | ||||
-rw-r--r-- | usr.bin/mandoc/mandoc_msg.c | 335 | ||||
-rw-r--r-- | usr.bin/mandoc/mandoc_parse.h | 10 | ||||
-rw-r--r-- | usr.bin/mandoc/mandocdb.c | 5 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_state.c | 3 | ||||
-rw-r--r-- | usr.bin/mandoc/msec.c | 3 | ||||
-rw-r--r-- | usr.bin/mandoc/read.c | 308 | ||||
-rw-r--r-- | usr.bin/mandoc/roff_term.c | 4 | ||||
-rw-r--r-- | usr.bin/mandoc/roff_validate.c | 4 | ||||
-rw-r--r-- | usr.bin/mandoc/st.c | 4 | ||||
-rw-r--r-- | usr.bin/mandoc/tbl_data.c | 3 | ||||
-rw-r--r-- | usr.bin/mandoc/tbl_layout.c | 3 |
19 files changed, 428 insertions, 410 deletions
diff --git a/usr.bin/mandoc/Makefile b/usr.bin/mandoc/Makefile index d069a94f493..29e9a930f37 100644 --- a/usr.bin/mandoc/Makefile +++ b/usr.bin/mandoc/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.112 2018/12/13 11:55:14 schwarze Exp $ +# $OpenBSD: Makefile,v 1.113 2018/12/14 01:17:46 schwarze Exp $ .include <bsd.own.mk> @@ -6,7 +6,7 @@ CFLAGS += -W -Wall -Wstrict-prototypes -Wno-unused-parameter DPADD += ${LIBUTIL} LDADD += -lutil -lz -SRCS= mandoc_aux.c mandoc_ohash.c mandoc.c mandoc_xr.c \ +SRCS= mandoc_aux.c mandoc_ohash.c mandoc.c mandoc_msg.c mandoc_xr.c \ chars.c preconv.c read.c \ roff.c roff_validate.c tbl.c tbl_opts.c tbl_layout.c tbl_data.c eqn.c SRCS+= mdoc_macro.c mdoc.c \ @@ -50,8 +50,8 @@ LIBMAN_OBJS = man.o man_macro.o man_validate.o LIBROFF_OBJS = roff.o roff_validate.o eqn.o \ tbl.o tbl_data.o tbl_layout.o tbl_opts.o LIBMANDOC_OBJS = ${LIBMDOC_OBJS} ${LIBMAN_OBJS} ${LIBROFF_OBJS} \ - mandoc.o mandoc_aux.o mandoc_ohash.o mandoc_xr.o \ - chars.o msec.o preconv.o read.o + mandoc.o mandoc_aux.o mandoc_msg.o mandoc_ohash.o \ + mandoc_xr.o chars.o msec.o preconv.o read.o HTML_OBJS = html.o roff_html.o mdoc_html.o man_html.o \ tbl_html.o eqn_html.o out.o CGI_OBJS = ${LIBMANDOC_OBJS} ${HTML_OBJS} \ diff --git a/usr.bin/mandoc/cgi.c b/usr.bin/mandoc/cgi.c index 00d392d2f90..706e924853b 100644 --- a/usr.bin/mandoc/cgi.c +++ b/usr.bin/mandoc/cgi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cgi.c,v 1.100 2018/12/13 11:55:14 schwarze Exp $ */ +/* $OpenBSD: cgi.c,v 1.101 2018/12/14 01:17:46 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2014, 2015, 2016, 2017, 2018 Ingo Schwarze <schwarze@usta.de> @@ -857,7 +857,7 @@ resp_format(const struct req *req, const char *file) mchars_alloc(); mp = mparse_alloc(MPARSE_SO | MPARSE_UTF8 | MPARSE_LATIN1, - MANDOCERR_MAX, NULL, MANDOC_OS_OTHER, req->q.manpath); + MANDOC_OS_OTHER, req->q.manpath); mparse_readfd(mp, fd, file); close(fd); diff --git a/usr.bin/mandoc/chars.c b/usr.bin/mandoc/chars.c index f78bab01be4..c28e78b50eb 100644 --- a/usr.bin/mandoc/chars.c +++ b/usr.bin/mandoc/chars.c @@ -1,4 +1,4 @@ -/* $OpenBSD: chars.c,v 1.46 2018/08/21 16:01:38 schwarze Exp $ */ +/* $OpenBSD: chars.c,v 1.47 2018/12/14 01:17:46 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011, 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org> @@ -21,6 +21,7 @@ #include <ctype.h> #include <stddef.h> #include <stdint.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> diff --git a/usr.bin/mandoc/libmandoc.h b/usr.bin/mandoc/libmandoc.h index b5e492e1752..26384fc38bc 100644 --- a/usr.bin/mandoc/libmandoc.h +++ b/usr.bin/mandoc/libmandoc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: libmandoc.h,v 1.59 2018/08/24 22:56:37 schwarze Exp $ */ +/* $OpenBSD: libmandoc.h,v 1.60 2018/12/14 01:17:46 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2013,2014,2015,2017,2018 Ingo Schwarze <schwarze@openbsd.org> @@ -49,11 +49,6 @@ struct mparse; struct roff; struct roff_man; -void mandoc_msg(enum mandocerr, struct mparse *, - int, int, const char *); -void mandoc_vmsg(enum mandocerr, struct mparse *, - int, int, const char *, ...) - __attribute__((__format__ (__printf__, 5, 6))); char *mandoc_getarg(struct mparse *, char **, int, int *); char *mandoc_normdate(struct roff_man *, char *, int, int); int mandoc_eos(const char *, size_t); diff --git a/usr.bin/mandoc/main.c b/usr.bin/mandoc/main.c index 9edce62b755..66f677de825 100644 --- a/usr.bin/mandoc/main.c +++ b/usr.bin/mandoc/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.214 2018/12/13 11:55:14 schwarze Exp $ */ +/* $OpenBSD: main.c,v 1.215 2018/12/14 01:17:46 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2012, 2014-2018 Ingo Schwarze <schwarze@openbsd.org> @@ -76,7 +76,6 @@ struct curparse { void *outdata; /* data for output */ char *os_s; /* operating system for display */ int wstop; /* stop after a file with a warning */ - enum mandocerr mmin; /* ignore messages below this */ enum mandoc_os os_e; /* check base system conventions */ enum outt outtype; /* which output to use */ }; @@ -84,7 +83,7 @@ struct curparse { int mandocdb(int, char *[]); -static void check_xr(const char *); +static void check_xr(void); static int fs_lookup(const struct manpaths *, size_t ipath, const char *, const char *, const char *, @@ -94,8 +93,6 @@ static int fs_search(const struct mansearch *, struct manpage **, size_t *); static int koptions(int *, char *); static void moptions(int *, char *); -static void mmsg(enum mandocerr, enum mandoclevel, - const char *, int, int, const char *); static void outdata_alloc(struct curparse *); static void parse(struct curparse *, int, const char *); static void passthrough(const char *, int, int); @@ -107,8 +104,6 @@ static int woptions(struct curparse *, char *); static const int sec_prios[] = {1, 4, 5, 8, 6, 3, 7, 2, 9}; static char help_arg[] = "help"; static char *help_argv[] = {help_arg, NULL}; -static enum mandoclevel rc; -static FILE *mmsg_stream; int @@ -168,10 +163,8 @@ main(int argc, char *argv[]) memset(&curp, 0, sizeof(struct curparse)); curp.outtype = OUTT_LOCALE; - curp.mmin = MANDOCERR_MAX; curp.outopts = &conf.output; options = MPARSE_SO | MPARSE_UTF8 | MPARSE_LATIN1; - mmsg_stream = stderr; use_pager = 1; tag_files = NULL; @@ -344,8 +337,6 @@ main(int argc, char *argv[]) search.arch = MACHINE; } - rc = MANDOCLEVEL_OK; - /* man(1), whatis(1), apropos(1) */ if (search.argmode != ARG_FILE) { @@ -387,7 +378,7 @@ main(int argc, char *argv[]) if (sz == 0) { if (search.argmode != ARG_NAME) warnx("nothing appropriate"); - rc = MANDOCLEVEL_BADARG; + mandoc_msg_setrc(MANDOCLEVEL_BADARG); goto out; } @@ -453,13 +444,15 @@ main(int argc, char *argv[]) moptions(&options, auxpaths); mchars_alloc(); - curp.mp = mparse_alloc(options, curp.mmin, mmsg, - curp.os_e, curp.os_s); + curp.mp = mparse_alloc(options, curp.os_e, curp.os_s); if (argc < 1) { if (use_pager) tag_files = tag_init(); - parse(&curp, STDIN_FILENO, "<stdin>"); + thisarg = "<stdin>"; + mandoc_msg_setinfilename(thisarg); + parse(&curp, STDIN_FILENO, thisarg); + mandoc_msg_setinfilename(NULL); } /* @@ -483,9 +476,12 @@ main(int argc, char *argv[]) (void)chdir(conf.manpath.paths[resp->ipath]); else if (startdir != -1) (void)fchdir(startdir); - } + thisarg = resp->file; + } else + thisarg = *argv; - fd = mparse_open(curp.mp, resp != NULL ? resp->file : *argv); + mandoc_msg_setinfilename(thisarg); + fd = mparse_open(curp.mp, thisarg); if (fd != -1) { if (use_pager) { use_pager = 0; @@ -497,10 +493,8 @@ main(int argc, char *argv[]) conf.output.tag : *argv; } - if (resp == NULL) - parse(&curp, fd, *argv); - else if (resp->form == FORM_SRC) - parse(&curp, fd, resp->file); + if (resp == NULL || resp->form == FORM_SRC) + parse(&curp, fd, thisarg); else passthrough(resp->file, fd, conf.output.synopsisonly); @@ -512,7 +506,7 @@ main(int argc, char *argv[]) tag_files = NULL; } else warn("stdout"); - rc = MANDOCLEVEL_SYSERR; + mandoc_msg_setrc(MANDOCLEVEL_SYSERR); break; } @@ -521,10 +515,10 @@ main(int argc, char *argv[]) outdata_alloc(&curp); terminal_sepline(curp.outdata); } - } else if (rc < MANDOCLEVEL_ERROR) - rc = MANDOCLEVEL_ERROR; + } + mandoc_msg_setinfilename(NULL); - if (MANDOCLEVEL_OK != rc && curp.wstop) + if (curp.wstop && mandoc_msg_getrc() != MANDOCLEVEL_OK) break; if (resp != NULL) @@ -615,7 +609,7 @@ out: if (pid == -1) { warn("wait"); - rc = MANDOCLEVEL_SYSERR; + mandoc_msg_setrc(MANDOCLEVEL_SYSERR); break; } if (!WIFSTOPPED(status)) @@ -625,8 +619,7 @@ out: } tag_unlink(); } - - return (int)rc; + return (int)mandoc_msg_getrc(); } static void @@ -776,7 +769,6 @@ fs_search(const struct mansearch *cfg, const struct manpaths *paths, static void parse(struct curparse *curp, int fd, const char *file) { - enum mandoclevel rctmp; struct roff_man *man; /* Begin by parsing the file itself. */ @@ -784,18 +776,16 @@ parse(struct curparse *curp, int fd, const char *file) assert(file); assert(fd >= 0); - rctmp = mparse_readfd(curp->mp, fd, file); + mparse_readfd(curp->mp, fd, file); if (fd != STDIN_FILENO) close(fd); - 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) + if (curp->wstop && mandoc_msg_getrc() != MANDOCLEVEL_OK) return; if (curp->outdata == NULL) @@ -859,13 +849,12 @@ parse(struct curparse *curp, int fd, const char *file) break; } } - if (curp->mmin < MANDOCERR_STYLE) - check_xr(file); - mparse_updaterc(curp->mp, &rc); + if (mandoc_msg_getmin() < MANDOCERR_STYLE) + check_xr(); } static void -check_xr(const char *file) +check_xr(void) { static struct manpaths paths; struct mansearch search; @@ -893,8 +882,7 @@ check_xr(const char *file) else mandoc_asprintf(&cp, "Xr %s %s (%d times)", xr->name, xr->sec, xr->count); - mmsg(MANDOCERR_XR_BAD, MANDOCLEVEL_STYLE, - file, xr->line, xr->pos + 1, cp); + mandoc_msg(MANDOCERR_XR_BAD, NULL, xr->line, xr->pos + 1, cp); free(cp); } } @@ -994,8 +982,7 @@ done: fail: free(line); warn("%s: SYSERR: %s", file, syscall); - if (rc < MANDOCLEVEL_SYSERR) - rc = MANDOCLEVEL_SYSERR; + mandoc_msg_setrc(MANDOCLEVEL_SYSERR); } static int @@ -1037,8 +1024,8 @@ toptions(struct curparse *curp, char *arg) curp->outtype = OUTT_ASCII; else if (0 == strcmp(arg, "lint")) { curp->outtype = OUTT_LINT; - curp->mmin = MANDOCERR_BASE; - mmsg_stream = stdout; + mandoc_msg_setoutfile(stdout); + mandoc_msg_setmin(MANDOCERR_BASE); } else if (0 == strcmp(arg, "tree")) curp->outtype = OUTT_TREE; else if (0 == strcmp(arg, "man")) @@ -1089,29 +1076,29 @@ woptions(struct curparse *curp, char *arg) break; case 1: case 2: - curp->mmin = MANDOCERR_BASE; + mandoc_msg_setmin(MANDOCERR_BASE); break; case 3: - curp->mmin = MANDOCERR_STYLE; + mandoc_msg_setmin(MANDOCERR_STYLE); break; case 4: - curp->mmin = MANDOCERR_WARNING; + mandoc_msg_setmin(MANDOCERR_WARNING); break; case 5: - curp->mmin = MANDOCERR_ERROR; + mandoc_msg_setmin(MANDOCERR_ERROR); break; case 6: - curp->mmin = MANDOCERR_UNSUPP; + mandoc_msg_setmin(MANDOCERR_UNSUPP); break; case 7: - curp->mmin = MANDOCERR_MAX; + mandoc_msg_setmin(MANDOCERR_MAX); break; case 8: - curp->mmin = MANDOCERR_BASE; + mandoc_msg_setmin(MANDOCERR_BASE); curp->os_e = MANDOC_OS_OPENBSD; break; case 9: - curp->mmin = MANDOCERR_BASE; + mandoc_msg_setmin(MANDOCERR_BASE); curp->os_e = MANDOC_OS_NETBSD; break; default: @@ -1122,29 +1109,6 @@ woptions(struct curparse *curp, char *arg) return 1; } -static void -mmsg(enum mandocerr t, enum mandoclevel lvl, - const char *file, int line, int col, const char *msg) -{ - const char *mparse_msg; - - fprintf(mmsg_stream, "%s: %s:", getprogname(), - file == NULL ? "<stdin>" : file); - - if (line) - fprintf(mmsg_stream, "%d:%d:", line, col + 1); - - fprintf(mmsg_stream, " %s", mparse_strlevel(lvl)); - - if ((mparse_msg = mparse_strerror(t)) != NULL) - fprintf(mmsg_stream, ": %s", mparse_msg); - - if (msg) - fprintf(mmsg_stream, ": %s", msg); - - fputc('\n', mmsg_stream); -} - static pid_t spawn_pager(struct tag_files *tag_files) { diff --git a/usr.bin/mandoc/man_macro.c b/usr.bin/mandoc/man_macro.c index 58021086bc2..a419113a62d 100644 --- a/usr.bin/mandoc/man_macro.c +++ b/usr.bin/mandoc/man_macro.c @@ -1,4 +1,4 @@ -/* $OpenBSD: man_macro.c,v 1.95 2018/08/26 16:18:38 schwarze Exp $ */ +/* $OpenBSD: man_macro.c,v 1.96 2018/12/14 01:17:46 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2012-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org> @@ -20,6 +20,7 @@ #include <assert.h> #include <ctype.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> diff --git a/usr.bin/mandoc/man_validate.c b/usr.bin/mandoc/man_validate.c index e6d3775dd6e..34404af3bb1 100644 --- a/usr.bin/mandoc/man_validate.c +++ b/usr.bin/mandoc/man_validate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: man_validate.c,v 1.110 2018/12/04 02:53:45 schwarze Exp $ */ +/* $OpenBSD: man_validate.c,v 1.111 2018/12/14 01:17:46 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2012-2018 Ingo Schwarze <schwarze@openbsd.org> @@ -22,6 +22,7 @@ #include <errno.h> #include <limits.h> #include <stdarg.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> diff --git a/usr.bin/mandoc/mandoc.h b/usr.bin/mandoc/mandoc.h index 5abba9a0377..aa4eeb1358d 100644 --- a/usr.bin/mandoc/mandoc.h +++ b/usr.bin/mandoc/mandoc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mandoc.h,v 1.200 2018/12/13 11:55:14 schwarze Exp $ */ +/* $OpenBSD: mandoc.h,v 1.201 2018/12/14 01:17:46 schwarze Exp $ */ /* * Copyright (c) 2010, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2012-2018 Ingo Schwarze <schwarze@openbsd.org> @@ -265,11 +265,19 @@ enum mandoc_esc { ESCAPE_OVERSTRIKE /* overstrike all chars in the argument */ }; -typedef void (*mandocmsg)(enum mandocerr, enum mandoclevel, - const char *, int, int, const char *); - enum mandoc_esc mandoc_escape(const char **, const char **, int *); +void mandoc_msg_setoutfile(FILE *); +const char *mandoc_msg_getinfilename(void); +void mandoc_msg_setinfilename(const char *); +enum mandocerr mandoc_msg_getmin(void); +void mandoc_msg_setmin(enum mandocerr); +enum mandoclevel mandoc_msg_getrc(void); +void mandoc_msg_setrc(enum mandoclevel); +void mandoc_msg(enum mandocerr, void *, int, int, const char *); +void mandoc_vmsg(enum mandocerr, void *, int, int, + const char *, ...) + __attribute__((__format__ (__printf__, 5, 6))); void mchars_alloc(void); void mchars_free(void); int mchars_num2char(const char *, size_t); diff --git a/usr.bin/mandoc/mandoc_msg.c b/usr.bin/mandoc/mandoc_msg.c new file mode 100644 index 00000000000..c94125e4611 --- /dev/null +++ b/usr.bin/mandoc/mandoc_msg.c @@ -0,0 +1,335 @@ +/* $OpenBSD: mandoc_msg.c,v 1.1 2018/12/14 01:17:46 schwarze Exp $ */ +/* + * Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> + * Copyright (c) 2014,2015,2016,2017,2018 Ingo Schwarze <schwarze@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> + +#include "mandoc.h" + +static const enum mandocerr lowest_type[MANDOCLEVEL_MAX] = { + MANDOCERR_OK, + MANDOCERR_OK, + MANDOCERR_WARNING, + MANDOCERR_ERROR, + MANDOCERR_UNSUPP, + MANDOCERR_MAX, + MANDOCERR_MAX +}; + +static const char *const level_name[MANDOCLEVEL_MAX] = { + "SUCCESS", + "STYLE", + "WARNING", + "ERROR", + "UNSUPP", + "BADARG", + "SYSERR" +}; + +static const char *const type_message[MANDOCERR_MAX] = { + "ok", + + "base system convention", + + "Mdocdate found", + "Mdocdate missing", + "unknown architecture", + "operating system explicitly specified", + "RCS id missing", + "referenced manual not found", + + "generic style suggestion", + + "legacy man(7) date format", + "normalizing date format to", + "lower case character in document title", + "duplicate RCS id", + "possible typo in section name", + "unterminated quoted argument", + "useless macro", + "consider using OS macro", + "errnos out of order", + "duplicate errno", + "trailing delimiter", + "no blank before trailing delimiter", + "fill mode already enabled, skipping", + "fill mode already disabled, skipping", + "verbatim \"--\", maybe consider using \\(em", + "function name without markup", + "whitespace at end of input line", + "bad comment style", + + "generic warning", + + /* related to the prologue */ + "missing manual title, using UNTITLED", + "missing manual title, using \"\"", + "missing manual section, using \"\"", + "unknown manual section", + "missing date, using today's date", + "cannot parse date, using it verbatim", + "date in the future, using it anyway", + "missing Os macro, using \"\"", + "late prologue macro", + "prologue macros out of order", + + /* related to document structure */ + ".so is fragile, better use ln(1)", + "no document body", + "content before first section header", + "first section is not \"NAME\"", + "NAME section without Nm before Nd", + "NAME section without description", + "description not at the end of NAME", + "bad NAME section content", + "missing comma before name", + "missing description line, using \"\"", + "description line outside NAME section", + "sections out of conventional order", + "duplicate section title", + "unexpected section", + "cross reference to self", + "unusual Xr order", + "unusual Xr punctuation", + "AUTHORS section without An macro", + + /* related to macros and nesting */ + "obsolete macro", + "macro neither callable nor escaped", + "skipping paragraph macro", + "moving paragraph macro out of list", + "skipping no-space macro", + "blocks badly nested", + "nested displays are not portable", + "moving content out of list", + "first macro on line", + "line scope broken", + "skipping blank line in line scope", + + /* related to missing macro arguments */ + "skipping empty request", + "conditional request controls empty scope", + "skipping empty macro", + "empty block", + "empty argument, using 0n", + "missing display type, using -ragged", + "list type is not the first argument", + "missing -width in -tag list, using 6n", + "missing utility name, using \"\"", + "missing function name, using \"\"", + "empty head in list item", + "empty list item", + "missing argument, using next line", + "missing font type, using \\fR", + "unknown font type, using \\fR", + "nothing follows prefix", + "empty reference block", + "missing section argument", + "missing -std argument, adding it", + "missing option string, using \"\"", + "missing resource identifier, using \"\"", + "missing eqn box, using \"\"", + + /* related to bad macro arguments */ + "duplicate argument", + "skipping duplicate argument", + "skipping duplicate display type", + "skipping duplicate list type", + "skipping -width argument", + "wrong number of cells", + "unknown AT&T UNIX version", + "comma in function argument", + "parenthesis in function name", + "unknown library name", + "invalid content in Rs block", + "invalid Boolean argument", + "argument contains two font escapes", + "unknown font, skipping request", + "odd number of characters in request", + + /* related to plain text */ + "blank line in fill mode, using .sp", + "tab in filled text", + "new sentence, new line", + "invalid escape sequence", + "undefined string, using \"\"", + + /* related to tables */ + "tbl line starts with span", + "tbl column starts with span", + "skipping vertical bar in tbl layout", + + "generic error", + + /* related to tables */ + "non-alphabetic character in tbl options", + "skipping unknown tbl option", + "missing tbl option argument", + "wrong tbl option argument size", + "empty tbl layout", + "invalid character in tbl layout", + "unmatched parenthesis in tbl layout", + "tbl without any data cells", + "ignoring data in spanned tbl cell", + "ignoring extra tbl data cells", + "data block open at end of tbl", + + /* related to document structure and macros */ + NULL, + "duplicate prologue macro", + "skipping late title macro", + "input stack limit exceeded, infinite loop?", + "skipping bad character", + "skipping unknown macro", + "ignoring request outside macro", + "skipping insecure request", + "skipping item outside list", + "skipping column outside column list", + "skipping end of block that is not open", + "fewer RS blocks open, skipping", + "inserting missing end of block", + "appending missing end of block", + + /* related to request and macro arguments */ + "escaped character not allowed in a name", + "using macro argument outside macro", + "argument number is not numeric", + "NOT IMPLEMENTED: Bd -file", + "skipping display without arguments", + "missing list type, using -item", + "argument is not numeric, using 1", + "argument is not a character", + "missing manual name, using \"\"", + "uname(3) system call failed, using UNKNOWN", + "unknown standard specifier", + "skipping request without numeric argument", + "excessive shift", + "NOT IMPLEMENTED: .so with absolute path or \"..\"", + ".so request failed", + "skipping all arguments", + "skipping excess arguments", + "divide by zero", + + "unsupported feature", + "input too large", + "unsupported control character", + "unsupported roff request", + "nested .while loops", + "end of scope with open .while loop", + "end of .while loop in inner scope", + "cannot continue this .while loop", + "eqn delim option in tbl", + "unsupported tbl layout modifier", + "ignoring macro in table", +}; + +static FILE *fileptr = stderr; +static const char *filename = NULL; +static enum mandocerr min_type = MANDOCERR_MAX; +static enum mandoclevel rc = MANDOCLEVEL_OK; + + +void +mandoc_msg_setoutfile(FILE *fp) +{ + fileptr = fp; +} + +const char * +mandoc_msg_getinfilename(void) +{ + return filename; +} + +void +mandoc_msg_setinfilename(const char *fn) +{ + filename = fn; +} + +enum mandocerr +mandoc_msg_getmin(void) +{ + return min_type; +} + +void +mandoc_msg_setmin(enum mandocerr t) +{ + min_type = t; +} + +enum mandoclevel +mandoc_msg_getrc(void) +{ + return rc; +} + +void +mandoc_msg_setrc(enum mandoclevel level) +{ + if (rc < level) + rc = level; +} + +void +mandoc_vmsg(enum mandocerr t, void *dummy, int line, int col, + const char *fmt, ...) +{ + va_list ap; + enum mandoclevel level; + + if (t < min_type && t != MANDOCERR_FILE) + return; + + level = MANDOCLEVEL_UNSUPP; + while (t < lowest_type[level]) + level--; + mandoc_msg_setrc(level); + + if (fileptr == NULL) + return; + + fprintf(fileptr, "%s:", getprogname()); + if (filename != NULL) + fprintf(fileptr, " %s:", filename); + + if (line > 0) + fprintf(fileptr, "%d:%d:", line, col + 1); + + fprintf(fileptr, " %s", level_name[level]); + if (type_message[t] != NULL) + fprintf(fileptr, ": %s", type_message[t]); + + if (fmt != NULL) { + fprintf(fileptr, ": "); + va_start(ap, fmt); + vfprintf(fileptr, fmt, ap); + va_end(ap); + } + fputc('\n', fileptr); +} + +void +mandoc_msg(enum mandocerr t, void *dummy, int line, int col, const char *msg) +{ + if (msg == NULL) + mandoc_vmsg(t, dummy, line, col, NULL); + else + mandoc_vmsg(t, dummy, line, col, "%s", msg); +} diff --git a/usr.bin/mandoc/mandoc_parse.h b/usr.bin/mandoc/mandoc_parse.h index f3a0e982f97..dab15d8de85 100644 --- a/usr.bin/mandoc/mandoc_parse.h +++ b/usr.bin/mandoc/mandoc_parse.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mandoc_parse.h,v 1.1 2018/12/13 11:55:14 schwarze Exp $ */ +/* $OpenBSD: mandoc_parse.h,v 1.2 2018/12/14 01:17:46 schwarze Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2014,2015,2016,2017,2018 Ingo Schwarze <schwarze@openbsd.org> @@ -33,15 +33,11 @@ struct mparse; struct roff_man; -struct mparse *mparse_alloc(int, enum mandocerr, mandocmsg, - enum mandoc_os, const char *); +struct mparse *mparse_alloc(int, enum mandoc_os, const char *); void mparse_copy(const struct mparse *); void mparse_free(struct mparse *); int mparse_open(struct mparse *, const char *); -enum mandoclevel mparse_readfd(struct mparse *, int, const char *); +void mparse_readfd(struct mparse *, int, const char *); void mparse_reset(struct mparse *); void mparse_result(struct mparse *, struct roff_man **, char **); -const char *mparse_strerror(enum mandocerr); -const char *mparse_strlevel(enum mandoclevel); -void mparse_updaterc(struct mparse *, enum mandoclevel *); diff --git a/usr.bin/mandoc/mandocdb.c b/usr.bin/mandoc/mandocdb.c index 2bed68e7a9d..a8154daada5 100644 --- a/usr.bin/mandoc/mandocdb.c +++ b/usr.bin/mandoc/mandocdb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mandocdb.c,v 1.209 2018/12/13 11:55:14 schwarze Exp $ */ +/* $OpenBSD: mandocdb.c,v 1.210 2018/12/14 01:17:46 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011-2018 Ingo Schwarze <schwarze@openbsd.org> @@ -396,8 +396,7 @@ mandocdb(int argc, char *argv[]) exitcode = (int)MANDOCLEVEL_OK; mchars_alloc(); - mp = mparse_alloc(mparse_options, MANDOCERR_MAX, NULL, - MANDOC_OS_OTHER, NULL); + mp = mparse_alloc(mparse_options, MANDOC_OS_OTHER, NULL); mandoc_ohash_init(&mpages, 6, offsetof(struct mpage, inodev)); mandoc_ohash_init(&mlinks, 6, offsetof(struct mlink, file)); diff --git a/usr.bin/mandoc/mdoc_state.c b/usr.bin/mandoc/mdoc_state.c index 9d335146a35..44905b6a676 100644 --- a/usr.bin/mandoc/mdoc_state.c +++ b/usr.bin/mandoc/mdoc_state.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mdoc_state.c,v 1.10 2018/08/17 20:31:52 schwarze Exp $ */ +/* $OpenBSD: mdoc_state.c,v 1.11 2018/12/14 01:17:46 schwarze Exp $ */ /* * Copyright (c) 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org> * @@ -17,6 +17,7 @@ #include <sys/types.h> #include <assert.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> diff --git a/usr.bin/mandoc/msec.c b/usr.bin/mandoc/msec.c index bd91cd5bfe0..813a1407cc1 100644 --- a/usr.bin/mandoc/msec.c +++ b/usr.bin/mandoc/msec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: msec.c,v 1.12 2015/10/06 18:30:44 schwarze Exp $ */ +/* $OpenBSD: msec.c,v 1.13 2018/12/14 01:17:46 schwarze Exp $ */ /* * Copyright (c) 2009 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -16,6 +16,7 @@ */ #include <sys/types.h> +#include <stdio.h> #include <string.h> #include "mandoc.h" diff --git a/usr.bin/mandoc/read.c b/usr.bin/mandoc/read.c index 42c524090ec..9297119a363 100644 --- a/usr.bin/mandoc/read.c +++ b/usr.bin/mandoc/read.c @@ -1,4 +1,4 @@ -/* $OpenBSD: read.c,v 1.174 2018/12/13 11:55:14 schwarze Exp $ */ +/* $OpenBSD: read.c,v 1.175 2018/12/14 01:17:46 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2018 Ingo Schwarze <schwarze@openbsd.org> @@ -46,14 +46,10 @@ struct mparse { struct roff *roff; /* roff parser (!NULL) */ struct roff_man *man; /* man parser */ char *sodest; /* filename pointed to by .so */ - const char *file; /* filename of current input file */ struct buf *primary; /* buffer currently being parsed */ struct buf *secondary; /* copy of top level input */ struct buf *loop; /* open .while request line */ const char *os_s; /* default operating system */ - mandocmsg mmsg; /* warning/error message handler */ - enum mandoclevel file_status; /* status of current parse */ - enum mandocerr mmin; /* ignore messages below this */ int options; /* parser options */ int gzip; /* current input file is gzipped */ int filenc; /* encoding of the current file */ @@ -65,229 +61,11 @@ static void choose_parser(struct mparse *); static void free_buf_list(struct buf *); static void resize_buf(struct buf *, size_t); static int mparse_buf_r(struct mparse *, struct buf, size_t, int); -static int read_whole_file(struct mparse *, const char *, int, - struct buf *, int *); +static int read_whole_file(struct mparse *, int, struct buf *, int *); static void mparse_end(struct mparse *); static void mparse_parse_buffer(struct mparse *, struct buf, const char *); -static const enum mandocerr mandoclimits[MANDOCLEVEL_MAX] = { - MANDOCERR_OK, - MANDOCERR_OK, - MANDOCERR_WARNING, - MANDOCERR_ERROR, - MANDOCERR_UNSUPP, - MANDOCERR_MAX, - MANDOCERR_MAX -}; - -static const char * const mandocerrs[MANDOCERR_MAX] = { - "ok", - - "base system convention", - - "Mdocdate found", - "Mdocdate missing", - "unknown architecture", - "operating system explicitly specified", - "RCS id missing", - "referenced manual not found", - - "generic style suggestion", - - "legacy man(7) date format", - "normalizing date format to", - "lower case character in document title", - "duplicate RCS id", - "possible typo in section name", - "unterminated quoted argument", - "useless macro", - "consider using OS macro", - "errnos out of order", - "duplicate errno", - "trailing delimiter", - "no blank before trailing delimiter", - "fill mode already enabled, skipping", - "fill mode already disabled, skipping", - "verbatim \"--\", maybe consider using \\(em", - "function name without markup", - "whitespace at end of input line", - "bad comment style", - - "generic warning", - - /* related to the prologue */ - "missing manual title, using UNTITLED", - "missing manual title, using \"\"", - "missing manual section, using \"\"", - "unknown manual section", - "missing date, using today's date", - "cannot parse date, using it verbatim", - "date in the future, using it anyway", - "missing Os macro, using \"\"", - "late prologue macro", - "prologue macros out of order", - - /* related to document structure */ - ".so is fragile, better use ln(1)", - "no document body", - "content before first section header", - "first section is not \"NAME\"", - "NAME section without Nm before Nd", - "NAME section without description", - "description not at the end of NAME", - "bad NAME section content", - "missing comma before name", - "missing description line, using \"\"", - "description line outside NAME section", - "sections out of conventional order", - "duplicate section title", - "unexpected section", - "cross reference to self", - "unusual Xr order", - "unusual Xr punctuation", - "AUTHORS section without An macro", - - /* related to macros and nesting */ - "obsolete macro", - "macro neither callable nor escaped", - "skipping paragraph macro", - "moving paragraph macro out of list", - "skipping no-space macro", - "blocks badly nested", - "nested displays are not portable", - "moving content out of list", - "first macro on line", - "line scope broken", - "skipping blank line in line scope", - - /* related to missing macro arguments */ - "skipping empty request", - "conditional request controls empty scope", - "skipping empty macro", - "empty block", - "empty argument, using 0n", - "missing display type, using -ragged", - "list type is not the first argument", - "missing -width in -tag list, using 6n", - "missing utility name, using \"\"", - "missing function name, using \"\"", - "empty head in list item", - "empty list item", - "missing argument, using next line", - "missing font type, using \\fR", - "unknown font type, using \\fR", - "nothing follows prefix", - "empty reference block", - "missing section argument", - "missing -std argument, adding it", - "missing option string, using \"\"", - "missing resource identifier, using \"\"", - "missing eqn box, using \"\"", - - /* related to bad macro arguments */ - "duplicate argument", - "skipping duplicate argument", - "skipping duplicate display type", - "skipping duplicate list type", - "skipping -width argument", - "wrong number of cells", - "unknown AT&T UNIX version", - "comma in function argument", - "parenthesis in function name", - "unknown library name", - "invalid content in Rs block", - "invalid Boolean argument", - "argument contains two font escapes", - "unknown font, skipping request", - "odd number of characters in request", - - /* related to plain text */ - "blank line in fill mode, using .sp", - "tab in filled text", - "new sentence, new line", - "invalid escape sequence", - "undefined string, using \"\"", - - /* related to tables */ - "tbl line starts with span", - "tbl column starts with span", - "skipping vertical bar in tbl layout", - - "generic error", - - /* related to tables */ - "non-alphabetic character in tbl options", - "skipping unknown tbl option", - "missing tbl option argument", - "wrong tbl option argument size", - "empty tbl layout", - "invalid character in tbl layout", - "unmatched parenthesis in tbl layout", - "tbl without any data cells", - "ignoring data in spanned tbl cell", - "ignoring extra tbl data cells", - "data block open at end of tbl", - - /* related to document structure and macros */ - NULL, - "duplicate prologue macro", - "skipping late title macro", - "input stack limit exceeded, infinite loop?", - "skipping bad character", - "skipping unknown macro", - "ignoring request outside macro", - "skipping insecure request", - "skipping item outside list", - "skipping column outside column list", - "skipping end of block that is not open", - "fewer RS blocks open, skipping", - "inserting missing end of block", - "appending missing end of block", - - /* related to request and macro arguments */ - "escaped character not allowed in a name", - "using macro argument outside macro", - "argument number is not numeric", - "NOT IMPLEMENTED: Bd -file", - "skipping display without arguments", - "missing list type, using -item", - "argument is not numeric, using 1", - "argument is not a character", - "missing manual name, using \"\"", - "uname(3) system call failed, using UNKNOWN", - "unknown standard specifier", - "skipping request without numeric argument", - "excessive shift", - "NOT IMPLEMENTED: .so with absolute path or \"..\"", - ".so request failed", - "skipping all arguments", - "skipping excess arguments", - "divide by zero", - - "unsupported feature", - "input too large", - "unsupported control character", - "unsupported roff request", - "nested .while loops", - "end of scope with open .while loop", - "end of .while loop in inner scope", - "cannot continue this .while loop", - "eqn delim option in tbl", - "unsupported tbl layout modifier", - "ignoring macro in table", -}; - -static const char * const mandoclevels[MANDOCLEVEL_MAX] = { - "SUCCESS", - "STYLE", - "WARNING", - "ERROR", - "UNSUPP", - "BADARG", - "SYSERR" -}; - static void resize_buf(struct buf *buf, size_t initial) @@ -368,7 +146,6 @@ mparse_buf_r(struct mparse *curp, struct buf blk, size_t i, int start) { struct buf ln; struct buf *firstln, *lastln, *thisln, *loop; - const char *save_file; char *cp; size_t pos; /* byte number in the ln buffer */ int line_result, result; @@ -591,13 +368,10 @@ rerun: curp->sodest = mandoc_strdup(ln.buf + of); goto out; } - save_file = curp->file; if ((fd = mparse_open(curp, ln.buf + of)) != -1) { mparse_readfd(curp, fd, ln.buf + of); close(fd); - curp->file = save_file; } else { - curp->file = save_file; mandoc_vmsg(MANDOCERR_SO_FAIL, curp, curp->line, pos, ".so %s", ln.buf + of); @@ -646,8 +420,7 @@ out: } static int -read_whole_file(struct mparse *curp, const char *file, int fd, - struct buf *fb, int *with_mmap) +read_whole_file(struct mparse *curp, int fd, struct buf *fb, int *with_mmap) { struct stat st; gzFile gz; @@ -777,8 +550,8 @@ mparse_parse_buffer(struct mparse *curp, struct buf blk, const char *file) } /* Line number is per-file. */ - svfile = curp->file; - curp->file = file; + svfile = mandoc_msg_getinfilename(); + mandoc_msg_setinfilename(file); svprimary = curp->primary; curp->primary = &blk; curp->line = 1; @@ -800,21 +573,22 @@ mparse_parse_buffer(struct mparse *curp, struct buf blk, const char *file) mparse_end(curp); curp->primary = svprimary; - curp->file = svfile; + if (svfile != NULL) + mandoc_msg_setinfilename(svfile); } /* * Read the whole file into memory and call the parsers. * Called recursively when an .so request is encountered. */ -enum mandoclevel +void mparse_readfd(struct mparse *curp, int fd, const char *file) { struct buf blk; int with_mmap; int save_filenc; - if (read_whole_file(curp, file, fd, &blk, &with_mmap)) { + if (read_whole_file(curp, fd, &blk, &with_mmap)) { save_filenc = curp->filenc; curp->filenc = curp->options & (MPARSE_UTF8 | MPARSE_LATIN1); @@ -825,7 +599,6 @@ mparse_readfd(struct mparse *curp, int fd, const char *file) else free(blk.buf); } - return curp->file_status; } int @@ -834,7 +607,6 @@ mparse_open(struct mparse *curp, const char *file) char *cp; int fd; - curp->file = file; cp = strrchr(file, '.'); curp->gzip = (cp != NULL && ! strcmp(cp + 1, "gz")); @@ -865,16 +637,13 @@ mparse_open(struct mparse *curp, const char *file) } struct mparse * -mparse_alloc(int options, enum mandocerr mmin, mandocmsg mmsg, - enum mandoc_os os_e, const char *os_s) +mparse_alloc(int options, enum mandoc_os os_e, const char *os_s) { struct mparse *curp; curp = mandoc_calloc(1, sizeof(struct mparse)); curp->options = options; - curp->mmin = mmin; - curp->mmsg = mmsg; curp->os_s = os_s; curp->roff = roff_alloc(curp, options); @@ -901,11 +670,8 @@ mparse_reset(struct mparse *curp) roff_man_reset(curp->man); free_buf_list(curp->secondary); curp->secondary = NULL; - free(curp->sodest); curp->sodest = NULL; - - curp->file_status = MANDOCLEVEL_OK; curp->gzip = 0; } @@ -935,60 +701,6 @@ mparse_result(struct mparse *curp, struct roff_man **man, } void -mparse_updaterc(struct mparse *curp, enum mandoclevel *rc) -{ - if (curp->file_status > *rc) - *rc = curp->file_status; -} - -void -mandoc_vmsg(enum mandocerr t, struct mparse *m, - int ln, int pos, const char *fmt, ...) -{ - char buf[256]; - va_list ap; - - va_start(ap, fmt); - (void)vsnprintf(buf, sizeof(buf), fmt, ap); - va_end(ap); - - mandoc_msg(t, m, ln, pos, buf); -} - -void -mandoc_msg(enum mandocerr er, struct mparse *m, - int ln, int col, const char *msg) -{ - enum mandoclevel level; - - if (er < m->mmin && er != MANDOCERR_FILE) - return; - - level = MANDOCLEVEL_UNSUPP; - while (er < mandoclimits[level]) - level--; - - if (m->mmsg) - (*m->mmsg)(er, level, m->file, ln, col, msg); - - if (m->file_status < level) - m->file_status = level; -} - -const char * -mparse_strerror(enum mandocerr er) -{ - - return mandocerrs[er]; -} - -const char * -mparse_strlevel(enum mandoclevel lvl) -{ - return mandoclevels[lvl]; -} - -void mparse_copy(const struct mparse *p) { struct buf *buf; diff --git a/usr.bin/mandoc/roff_term.c b/usr.bin/mandoc/roff_term.c index 72a339db29e..747fe591f69 100644 --- a/usr.bin/mandoc/roff_term.c +++ b/usr.bin/mandoc/roff_term.c @@ -1,4 +1,4 @@ -/* $OpenBSD: roff_term.c,v 1.15 2018/08/10 20:40:43 schwarze Exp $ */ +/* $OpenBSD: roff_term.c,v 1.16 2018/12/14 01:17:46 schwarze Exp $ */ /* * Copyright (c) 2010,2014,2015,2017,2018 Ingo Schwarze <schwarze@openbsd.org> * @@ -17,7 +17,7 @@ #include <sys/types.h> #include <assert.h> -#include <stddef.h> +#include <stdio.h> #include "mandoc.h" #include "roff.h" diff --git a/usr.bin/mandoc/roff_validate.c b/usr.bin/mandoc/roff_validate.c index ee0c1c23446..8d962028c6b 100644 --- a/usr.bin/mandoc/roff_validate.c +++ b/usr.bin/mandoc/roff_validate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: roff_validate.c,v 1.12 2018/12/04 03:28:54 schwarze Exp $ */ +/* $OpenBSD: roff_validate.c,v 1.13 2018/12/14 01:17:46 schwarze Exp $ */ /* * Copyright (c) 2010, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org> * @@ -17,7 +17,7 @@ #include <sys/types.h> #include <assert.h> -#include <stddef.h> +#include <stdio.h> #include <string.h> #include "mandoc.h" diff --git a/usr.bin/mandoc/st.c b/usr.bin/mandoc/st.c index 3da601724c4..27039fe5c4c 100644 --- a/usr.bin/mandoc/st.c +++ b/usr.bin/mandoc/st.c @@ -1,4 +1,4 @@ -/* $OpenBSD: st.c,v 1.12 2018/12/13 07:25:38 schwarze Exp $ */ +/* $OpenBSD: st.c,v 1.13 2018/12/14 01:17:46 schwarze Exp $ */ /* * Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -15,6 +15,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include <sys/types.h> + +#include <stdio.h> #include <string.h> #include "mandoc.h" diff --git a/usr.bin/mandoc/tbl_data.c b/usr.bin/mandoc/tbl_data.c index efd42b70e67..19cd1c2b12f 100644 --- a/usr.bin/mandoc/tbl_data.c +++ b/usr.bin/mandoc/tbl_data.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tbl_data.c,v 1.36 2018/12/13 02:05:57 schwarze Exp $ */ +/* $OpenBSD: tbl_data.c,v 1.37 2018/12/14 01:17:46 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011, 2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org> @@ -19,6 +19,7 @@ #include <assert.h> #include <ctype.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> diff --git a/usr.bin/mandoc/tbl_layout.c b/usr.bin/mandoc/tbl_layout.c index e09ae25de1e..4431153aa19 100644 --- a/usr.bin/mandoc/tbl_layout.c +++ b/usr.bin/mandoc/tbl_layout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tbl_layout.c,v 1.33 2018/12/13 02:05:57 schwarze Exp $ */ +/* $OpenBSD: tbl_layout.c,v 1.34 2018/12/14 01:17:46 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2012, 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org> @@ -19,6 +19,7 @@ #include <ctype.h> #include <stdint.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> |