]>
git.cameronkatri.com Git - mandoc.git/blob - mandoc_msg.c
1 /* $OpenBSD: mandoc_msg.c,v 1.8 2020/01/19 17:59:01 schwarze Exp $ */
3 * Copyright (c) 2014-2022 Ingo Schwarze <schwarze@openbsd.org>
4 * Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 * Implementation of warning and error messages for mandoc(1).
28 static const enum mandocerr lowest_type
[MANDOCLEVEL_MAX
] = {
38 static const char *const level_name
[MANDOCLEVEL_MAX
] = {
48 static const char *const type_message
[MANDOCERR_MAX
] = {
51 "base system convention",
55 "unknown architecture",
56 "operating system explicitly specified",
59 "generic style suggestion",
61 "legacy man(7) date format",
62 "normalizing date format to",
63 "lower case character in document title",
65 "possible typo in section name",
66 "unterminated quoted argument",
68 "consider using OS macro",
69 "errnos out of order",
71 "referenced manual not found",
73 "no blank before trailing delimiter",
74 "fill mode already enabled, skipping",
75 "fill mode already disabled, skipping",
76 "input text line longer than 80 bytes",
77 "verbatim \"--\", maybe consider using \\(em",
78 "function name without markup",
79 "whitespace at end of input line",
84 /* related to the prologue */
85 "missing manual title, using UNTITLED",
86 "missing manual title, using \"\"",
87 "missing manual section, using \"\"",
88 "unknown manual section",
89 "filename/section mismatch",
90 "missing date, using \"\"",
91 "cannot parse date, using it verbatim",
92 "date in the future, using it anyway",
93 "missing Os macro, using \"\"",
94 "late prologue macro",
95 "prologue macros out of order",
97 /* related to document structure */
98 ".so is fragile, better use ln(1)",
100 "content before first section header",
101 "first section is not \"NAME\"",
102 "NAME section without Nm before Nd",
103 "NAME section without description",
104 "description not at the end of NAME",
105 "bad NAME section content",
106 "missing comma before name",
107 "missing description line, using \"\"",
108 "description line outside NAME section",
109 "sections out of conventional order",
110 "duplicate section title",
111 "unexpected section",
112 "cross reference to self",
114 "unusual Xr punctuation",
115 "AUTHORS section without An macro",
117 /* related to macros and nesting */
119 "macro neither callable nor escaped",
120 "skipping paragraph macro",
121 "moving paragraph macro out of list",
122 "skipping no-space macro",
123 "blocks badly nested",
124 "nested displays are not portable",
125 "moving content out of list",
126 "first macro on line",
128 "skipping blank line in line scope",
130 /* related to missing macro arguments */
131 "skipping empty request",
132 "conditional request controls empty scope",
133 "skipping empty macro",
135 "empty argument, using 0n",
136 "missing display type, using -ragged",
137 "list type is not the first argument",
138 "missing -width in -tag list, using 6n",
139 "missing utility name, using \"\"",
140 "missing function name, using \"\"",
141 "empty head in list item",
143 "missing argument, using next line",
144 "missing font type, using \\fR",
145 "unknown font type, using \\fR",
146 "nothing follows prefix",
147 "empty reference block",
148 "missing section argument",
149 "missing -std argument, adding it",
150 "missing option string, using \"\"",
151 "missing resource identifier, using \"\"",
152 "missing eqn box, using \"\"",
154 /* related to bad macro arguments */
155 "duplicate argument",
156 "skipping duplicate argument",
157 "skipping duplicate display type",
158 "skipping duplicate list type",
159 "skipping -width argument",
160 "wrong number of cells",
161 "unknown AT&T UNIX version",
162 "comma in function argument",
163 "parenthesis in function name",
164 "unknown library name",
165 "invalid content in Rs block",
166 "invalid Boolean argument",
167 "argument contains two font escapes",
168 "unknown font, skipping request",
169 "odd number of characters in request",
171 /* related to plain text */
172 "blank line in fill mode, using .sp",
173 "tab in filled text",
174 "new sentence, new line",
175 "invalid escape sequence",
176 "undefined escape, printing literally",
177 "undefined string, using \"\"",
179 /* related to tables */
180 "tbl line starts with span",
181 "tbl column starts with span",
182 "skipping vertical bar in tbl layout",
186 /* related to tables */
187 "non-alphabetic character in tbl options",
188 "skipping unknown tbl option",
189 "missing tbl option argument",
190 "wrong tbl option argument size",
192 "invalid character in tbl layout",
193 "unmatched parenthesis in tbl layout",
194 "ignoring excessive spacing in tbl layout",
195 "tbl without any data cells",
196 "ignoring data in spanned tbl cell",
197 "ignoring extra tbl data cells",
198 "data block open at end of tbl",
200 /* related to document structure and macros */
201 "duplicate prologue macro",
202 "skipping late title macro",
203 "input stack limit exceeded, infinite loop?",
204 "skipping bad character",
205 "skipping unknown macro",
206 "ignoring request outside macro",
207 "skipping insecure request",
208 "skipping item outside list",
209 "skipping column outside column list",
210 "skipping end of block that is not open",
211 "fewer RS blocks open, skipping",
212 "inserting missing end of block",
213 "appending missing end of block",
215 /* related to request and macro arguments */
216 "escaped character not allowed in a name",
217 "using macro argument outside macro",
218 "argument number is not numeric",
219 "negative argument, using 0",
220 "NOT IMPLEMENTED: Bd -file",
221 "skipping display without arguments",
222 "missing list type, using -item",
223 "argument is not numeric, using 1",
224 "argument is not a character",
225 "missing manual name, using \"\"",
226 "uname(3) system call failed, using UNKNOWN",
227 "unknown standard specifier",
228 "skipping request without numeric argument",
230 "NOT IMPLEMENTED: .so with absolute path or \"..\"",
231 ".so request failed",
232 "skipping tag containing whitespace",
233 "skipping all arguments",
234 "skipping excess arguments",
237 "unsupported feature",
239 "unsupported control character",
240 "unsupported escape sequence",
241 "unsupported roff request",
242 "nested .while loops",
243 "end of scope with open .while loop",
244 "end of .while loop in inner scope",
245 "cannot continue this .while loop",
246 "eqn delim option in tbl",
247 "unsupported tbl layout modifier",
248 "ignoring macro in table",
249 "skipping tbl in -Tman mode",
250 "skipping eqn in -Tman mode",
252 /* bad command line arguments */
254 "bad command line argument",
255 "duplicate command line argument",
256 "option has a superfluous value",
257 "missing option value",
259 "duplicate option value",
261 "-Tmarkdown unsupported for man(7) input",
283 static FILE *fileptr
= NULL
;
284 static const char *filename
= NULL
;
285 static enum mandocerr min_type
= MANDOCERR_BADARG
;
286 static enum mandoclevel rc
= MANDOCLEVEL_OK
;
290 mandoc_msg_setoutfile(FILE *fp
)
296 mandoc_msg_getinfilename(void)
302 mandoc_msg_setinfilename(const char *fn
)
308 mandoc_msg_getmin(void)
314 mandoc_msg_setmin(enum mandocerr t
)
320 mandoc_msg_getrc(void)
326 mandoc_msg_setrc(enum mandoclevel level
)
333 mandoc_msg(enum mandocerr t
, int line
, int col
, const char *fmt
, ...)
336 enum mandoclevel level
;
341 level
= MANDOCLEVEL_SYSERR
;
342 while (t
< lowest_type
[level
])
344 mandoc_msg_setrc(level
);
349 fprintf(fileptr
, "%s:", getprogname());
350 if (filename
!= NULL
)
351 fprintf(fileptr
, " %s:", filename
);
354 fprintf(fileptr
, "%d:%d:", line
, col
+ 1);
356 fprintf(fileptr
, " %s", level_name
[level
]);
357 if (type_message
[t
] != NULL
)
358 fprintf(fileptr
, ": %s", type_message
[t
]);
361 fprintf(fileptr
, ": ");
363 vfprintf(fileptr
, fmt
, ap
);
366 fputc('\n', fileptr
);
370 mandoc_msg_summary(void)
372 if (fileptr
!= NULL
&& rc
!= MANDOCLEVEL_OK
)
374 "%s: see above the output for %s messages\n",
375 getprogname(), level_name
[rc
]);