summaryrefslogtreecommitdiffstats
path: root/usr.bin/mandoc/mdoc_validate.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Contrary to what the NetBSD attribute(3) manual page suggests,schwarze2019-03-131-3/+3
| | | | | | | | | | | | | using __dead instead of __attribute__((__noreturn__)) actually hinders portability rather than helping it. Given that mandoc already uses __attribute__ in several files and that in the portable version, ./configure already contains rudimentary support for ignoring it on platforms that do not support it, use __attribute__ directly. This is expected to fix build failures that Stephen Gregoratto <dev at sgregoratto dot me> reported from Arch and Debian Linux.
* mark check_abort() and post_abort() as __dead;schwarze2019-03-111-3/+3
| | | | based on a patch by Christos@ Zoulas at NetBSD
* When the -S option is given to man(1) and the requested manual pageschwarze2019-03-041-40/+14
| | | | | | | | | | | | name is not found and the requested architecture is unknown, complain about the architecture rather than about the manual page name: $ man -S vax cpu man: Unknown architecture "vax". $ man -S sparc64 foobar man: No entry for foobar in the manual. Friendlier error message suggested by jmc@, who also OK'ed the patch.
* Fix the last straggler where the struct roff_node "line" memberschwarze2019-03-041-2/+2
| | | | | was abused to detect an input line break; instead, use the NODE_LINE flag to improve robustness.
* Use the new flag NODE_NOFILL in the validators, which is sometimesschwarze2018-12-311-5/+3
| | | | | | simpler and always more robust. In particular, move the nesting warnings for .EX and .EE from man_state(), where they were misplaced, to the man(7) validator.
* Cleanup, no functional change:schwarze2018-12-311-3/+3
| | | | | | Use the new parser flag ROFF_NOFILL in the mdoc(7) parser, too, instead of the old MDOC_LITERAL, which was an alias for the former MAN_LITERAL.
* Cleanup, minus 15 LOC, no functional change:schwarze2018-12-311-3/+3
| | | | | | | | | Simplify the way the man(7) and mdoc(7) validators are called. Reset the parser state with a common function before calling them. There is no need to again reset the parser state afterwards, the parsers are no longer used after validation. This allows getting rid of man_node_validate() and mdoc_node_validate() as separate functions.
* Cleanup, no functional change:schwarze2018-12-301-3/+3
| | | | | | | | | | | | | | The struct roff_man used to be a bad mixture of internal parser state and public parsing results. Move the public results to the parsing result struct roff_meta, which is already public. Move the rest of struct roff_man to the parser-internal header roff_int.h. Since the validators need access to the parser state, call them from the top level parser during mparse_result() rather than from the main programs, also reducing code duplication. This keeps parser internal state out of thee main programs (five in mandoc portable) and out of eight formatters.
* Almost mechanical diff to remove the "struct mparse *" argumentschwarze2018-12-141-224/+159
| | | | | | | | from mandoc_msg(), where it is no longer used. While here, rename mandoc_vmsg() to mandoc_msg() and retire the old version: There is really no point in having another function merely to save "%s" in a few places. Minus 140 lines of code.
* Clean up the validation of .Pp, .PP, .sp, and .br. Make sure allschwarze2018-12-041-41/+14
| | | | | | | | | | | | | | combinations are handled, and are handled in a systematic manner. This resolves some erratic duplicate handling, handles a number of missing cases, and improves diagnostics in various respects. Move validation of .br and .sp to the roff validation module rather than doing that twice in the mdoc and man validation modules. Move the node relinking function to the roff library where it belongs. In validation functions, only look at the node itself, at previous nodes, and at descendants, not at following nodes or ancestors, such that only nodes are inspected which are already validated.
* In the validators, translate obsolete macro aliases (Lp, Ot, LP, P)schwarze2018-12-031-15/+43
| | | | | | to the standard forms (Pp, Ft, PP) up front, such that later code does not need to look for the obsolete versions. This reduces the risk of incomplete handling.
* Remove more pointer arithmetic passing via regions outside the arrayschwarze2018-08-171-2/+2
| | | | | that is undefined according to the C standard. Robert Elz <kre at munnari dot oz dot au> pointed out i wasn't quite done yet.
* Do not calculate a pointer to a memory location before the beginning ofschwarze2018-08-161-4/+3
| | | | | | a static array. Christos Zoulas, Robert Elz, and Andreas Gustafsson point out that is undefined behaviour by the C standard even if we never access the pointer.
* Fix an off-by-one string read access that could happen if an emptyschwarze2018-08-011-3/+2
| | | | | string argument preceded a string argument beginning with "--". Found by Leah Neukirchen <leah at vuxu dot org> with -Wpointer-compare.
* Avoid a read access one byte beyond the end of an allocated stringschwarze2018-08-011-2/+2
| | | | | which occurred in situations like ".Fl a Cm --"; found by Leah Neukirchen <leah at vuxu dot org> with valgrind on Void Linux.
* preserve comments before .Dd when converting mdoc(7) to man(7)schwarze2018-04-111-3/+6
| | | | with mandoc -Tman; suggested by Thomas Klausner <wiz at NetBSD>
* use the portable \(lq and \(rq internally rather than \(Lq and \(Rqschwarze2018-04-051-3/+3
|
* Ouch, fix previous: In the edge case of a single-character stringschwarze2018-03-161-2/+3
| | | | | containing nothing but a single hyphen, the pointer got incremented twice at one point, causing a read overrun found by naddy@.
* Style message about bad input encoding of em-dashes as -- instead of \(em.schwarze2018-03-161-9/+66
| | | | Suggested by Thomas Klausner <wiz at NetBSD>; discussed with jmc@.
* Delete the "no blank before trailing delimiter" check from theschwarze2018-02-061-10/+9
| | | | | partial explicit macros. Leah Neukirchen <leah at vuxu dot org> rightfully points out that the check makes no sense for these macros.
* Do not segfault when there are two .Dt macros, the first withoutschwarze2017-09-121-2/+5
| | | | | an architecture argument and the second with an invalid one. Bug found by jsg@ with afl(1).
* No longer use names that only occur in the SYNOPSIS section as namesschwarze2017-08-021-6/+3
| | | | | | | | | | | | | | | | | | | | | | | | | for man(1) lookup. For OpenBSD base and Xenocara, that functionality was never intended to be required, and i just fixed the last handful of offenders using it - not counting the horribly ill-designed interfaces engine(3) and lh_new(3) which are impossible to properly document in the first place. Of course, apropos(1) and whatis(1) continue to use SYNOPSIS .Nm, .Fn, and .Fo macros, so "man -k ENGINE_get_load_privkey_function" still works. This change also gets rid of a few bogus warnings "cross reference to self" which actually are *not* to self, like in yp(8). This former functionality was intended to help third-party software in the ports tree and on non-OpenBSD systems containing manual pages with incomplete or corrupt NAME sections. But it turned out it did more harm than good, and caused more confusion than relief, specifically for third party manuals and for maintainers of mandoc-portable on other operating systems. So kill it. Problems reported, among others, by Yuri Pankov (illumos). OK jmc@
* Fix an out of bounds read access to a constant array that causedschwarze2017-07-311-2/+2
| | | | | | | segfaults on certain hardened versions of glibc. Triggered by .sp or blank lines right before .SS or .SH, or before the first .Sh. Found the hard way by Dr. Markus Waldner on Debian and by Leah Neukirchen on Void Linux.
* correctly handle letters in .Nx arguments; improves for exampleschwarze2017-07-201-1/+16
| | | | getpgid(2), ac(8), ldconfig(8), mount_ffs(8), sa(8), ttyflags(8), ...
* If -column, -diag, -inset, -item, or -ohang lists have a -width,schwarze2017-07-151-5/+6
| | | | | don't just talk about ignoring it, actually do ignore it. No change for terminal output, improves HTML output.
* report trailing delimiters after macros where they are usually a mistake;schwarze2017-07-031-49/+95
| | | | the idea came up in a discussion with Thomas Klausner <wiz at NetBSD>
* add warning "cross reference to self"; inspired by mdoclintschwarze2017-07-021-3/+13
|
* Basic reporting of .Xrs to manual pages that don't existschwarze2017-07-011-2/+6
| | | | | | | | | | | | in the base system, inspired by mdoclint(1). We are able to do this because (1) the -mdoc parser, the -Tlint validator, and the man(1) manual page lookup code are all in the same program and (2) the mandoc.db(5) database format allows fast lookup. Feedback from, previous versions tested by, and OK jmc@. A few features will be added to this in the tree, step by step.
* warn about some non-portable idioms in .Bl -column;schwarze2017-06-291-5/+20
| | | | triggered by a question from Yuri Pankov (illumos)
* warn about .Ns macros that have no effect because they are followedschwarze2017-06-271-3/+6
| | | | by an isolated closing delimiter; inspired by mdoclint
* Catch typos in .Sh names; suggested by jmc@.schwarze2017-06-251-2/+63
| | | | | | I'm using a very simple, linear time / zero space fuzzy string matching heuristic rather than a full Levenshtein metric, to keep the code both simple and fast.
* operating system dependent message about unknown architecture;schwarze2017-06-241-1/+40
| | | | inspired by mdoclint
* in the base system, suggest leaving .Os blank; inspired by mdoclintschwarze2017-06-241-1/+8
|
* Split -Wstyle into -Wstyle and the even lower -Wbase, and addschwarze2017-06-241-15/+21
| | | | | | | | | | | | | | | -Wopenbsd and -Wnetbsd to check conventions for the base system of a specific operating system. Mark operating system specific messages with "(OpenBSD)" at the end. Please use just "-Tlint" to check base system manuals (defaulting to -Wall, which is now -Wbase), but prefer "-Tlint -Wstyle" for the manuals of portable software projects you maintain that are not part of OpenBSD base, to avoid bogus recommendations about base system conventions that do not apply. Issue originally reported by semarie@, solution using an idea from tedu@, discussed with jmc@ and jca@.
* style message about missing RCS ids; inspired by mdoclintschwarze2017-06-171-2/+5
|
* ooops, fix a glitch in the previous commit...schwarze2017-06-111-2/+2
|
* Style message about legacy man(7) date format in mdoc(7) documentsschwarze2017-06-111-6/+28
| | | | | and operating system dependent messages about missing or unexpected Mdocdate; inspired by mdoclint(1).
* style message about missing .Fn markup; inspired by mdoclintschwarze2017-06-111-8/+25
|
* Do not issue the message "no blank before trailing delimiter" for .No.schwarze2017-06-111-4/+4
| | | | | | | In practice, that message only matters inside .Bf, and even there, it can occasionally be a false positive. In all other cases, it usually is a false positive, so it is better to drop it outright. Suggested by jmc@.
* Reduce false positives for the "no blank before trailing delimiter" message.schwarze2017-06-101-3/+76
| | | | This brings us down to one false positive for about every 18 pages.
* style message about missing blank before trailing delimiter;schwarze2017-06-101-39/+75
| | | | inspired by mdoclint(1), and jmc@ considers it useful
* style checks related to .Er; inspired by mdoclint(1)schwarze2017-06-071-3/+37
|
* STYLE message about full stop at the end of .Nd; inspired by mdoclint(1)schwarze2017-06-011-1/+7
|
* STYLE message about missing use of Ox/Nx/Fx/Dx; OK jmc@ wiz@schwarze2017-05-311-1/+33
|
* STYLE message about useless macros we don't want (Bt Tn Ud);schwarze2017-05-301-2/+14
| | | | not a WARNING because they don't endanger portability
* warn about punctuation between .Xr and .Rs in SEE ALSO;schwarze2017-05-141-2/+2
| | | | inspired by mdoclint
* Move .sp to the roff modules. Enough infrastructure is in placeschwarze2017-05-051-5/+5
| | | | now that this actually saves code: -70 LOC.
* move .ll to the roff modulesschwarze2017-05-051-2/+1
|
* Move handling of the roff(7) .ft request from the man(7)schwarze2017-05-051-2/+3
| | | | | modules to the new roff(7) modules. As a side effect, mdoc(7) now handles .ft, too. Of course, do not use that.
* Parser reorg:schwarze2017-05-041-7/+18
| | | | | Generate the first node on the roff level: .br Fix some column numbers in diagnostic messages while here.