summaryrefslogtreecommitdiffstats
path: root/mdoc_validate.c
Commit message (Collapse)AuthorAgeFilesLines
* Improve validation of function names:Ingo Schwarze2019-09-131-5/+11
| | | | | | 1. Relax checking to accept function types of the form "ret_type (fname)(args)" (suggested by Yuri Pankov <yuripv dot net>). 2. Tighten checking to require the closing parenthesis.
* Fix mandoc_normdate() and the way it is used.Ingo Schwarze2019-06-271-15/+3
| | | | | | | | | | In the past, it could return NULL but the calling code wasn't prepared to handle that. Make sure it always returns an allocated string. While here, simplify the code by handling the "quick" attribute inside mandoc_normdate() rather than at multiple callsites. Triggered by deraadt@ pointing out that snprintf(3) error handling was incomplete in time2a().
* Contrary to what the NetBSD attribute(3) manual page suggests,Ingo Schwarze2019-03-131-2/+2
| | | | | | | | | | | | | 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;Ingo Schwarze2019-03-111-2/+2
| | | | based on a patch by Christos@ Zoulas at NetBSD
* When the -S option is given to man(1) and the requested manual pageIngo Schwarze2019-03-041-39/+13
| | | | | | | | | | | | 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" memberIngo Schwarze2019-03-041-1/+1
| | | | | 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 sometimesIngo Schwarze2018-12-311-4/+2
| | | | | | 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:Ingo Schwarze2018-12-311-2/+2
| | | | | | 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:Ingo Schwarze2018-12-311-2/+2
| | | | | | | | | 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:Ingo Schwarze2018-12-301-2/+2
| | | | | | | | | | | | | | 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 *" argumentIngo Schwarze2018-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 allIngo Schwarze2018-12-041-40/+13
| | | | | | | | | | | | | | 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)Ingo Schwarze2018-12-031-14/+42
| | | | | | 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 arrayIngo Schwarze2018-08-171-1/+1
| | | | | 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 ofIngo Schwarze2018-08-161-3/+2
| | | | | | 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 emptyIngo Schwarze2018-08-011-2/+1
| | | | | 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 stringIngo Schwarze2018-08-011-1/+1
| | | | | 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)Ingo Schwarze2018-04-111-2/+5
| | | | with mandoc -Tman; suggested by Thomas Klausner <wiz at NetBSD>
* use the portable \(lq and \(rq internally rather than \(Lq and \(RqIngo Schwarze2018-04-051-2/+2
|
* Ouch, fix previous: In the edge case of a single-character stringIngo Schwarze2018-03-161-1/+2
| | | | | 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.Ingo Schwarze2018-03-161-8/+65
| | | | Suggested by Thomas Klausner <wiz at NetBSD>; discussed with jmc@.
* Delete the "no blank before trailing delimiter" check from theIngo Schwarze2018-02-061-9/+8
| | | | | 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 withoutIngo Schwarze2017-09-121-1/+4
| | | | | 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 namesIngo Schwarze2017-08-021-5/+2
| | | | | | | | | | | | | | | | | | | | | | | | | 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 causedIngo Schwarze2017-07-311-1/+1
| | | | | | | 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 exampleIngo Schwarze2017-07-201-0/+15
| | | | getpgid(2), ac(8), ldconfig(8), mount_ffs(8), sa(8), ttyflags(8), ...
* If -column, -diag, -inset, -item, or -ohang lists have a -width,Ingo Schwarze2017-07-151-4/+5
| | | | | 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;Ingo Schwarze2017-07-031-48/+94
| | | | the idea came up in a discussion with Thomas Klausner <wiz at NetBSD>
* add warning "cross reference to self"; inspired by mdoclintIngo Schwarze2017-07-021-2/+12
|
* Basic reporting of .Xrs to manual pages that don't existIngo Schwarze2017-07-011-1/+5
| | | | | | | | | | | | 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;Ingo Schwarze2017-06-291-4/+19
| | | | triggered by a question from Yuri Pankov (illumos)
* warn about .Ns macros that have no effect because they are followedIngo Schwarze2017-06-271-2/+5
| | | | by an isolated closing delimiter; inspired by mdoclint
* Catch typos in .Sh names; suggested by jmc@.Ingo Schwarze2017-06-251-1/+62
| | | | | | 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;Ingo Schwarze2017-06-241-0/+39
| | | | inspired by mdoclint
* in the base system, suggest leaving .Os blank; inspired by mdoclintIngo Schwarze2017-06-241-0/+7
|
* Split -Wstyle into -Wstyle and the even lower -Wbase, and addIngo Schwarze2017-06-241-14/+20
| | | | | | | | | | | | | | | -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 mdoclintIngo Schwarze2017-06-171-1/+4
|
* ooops, fix a glitch in the previous commit...Ingo Schwarze2017-06-111-1/+1
|
* Style message about legacy man(7) date format in mdoc(7) documentsIngo Schwarze2017-06-111-5/+27
| | | | | and operating system dependent messages about missing or unexpected Mdocdate; inspired by mdoclint(1).
* style message about missing .Fn markup; inspired by mdoclintIngo Schwarze2017-06-111-7/+24
|
* Do not issue the message "no blank before trailing delimiter" for .No.Ingo Schwarze2017-06-111-3/+3
| | | | | | | 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.Ingo Schwarze2017-06-101-2/+75
| | | | This brings us down to one false positive for about every 18 pages.
* style message about missing blank before trailing delimiter;Ingo Schwarze2017-06-101-38/+74
| | | | inspired by mdoclint(1), and jmc@ considers it useful
* warning about unknown .Lb arguments; inspired by mdoclint(1)Ingo Schwarze2017-06-081-0/+3
|
* style checks related to .Er; inspired by mdoclint(1)Ingo Schwarze2017-06-071-2/+36
|
* STYLE message about full stop at the end of .Nd; inspired by mdoclint(1)Ingo Schwarze2017-06-011-0/+6
|
* STYLE message about missing use of Ox/Nx/Fx/Dx; OK jmc@ wiz@Ingo Schwarze2017-05-311-0/+32
|
* STYLE message about useless macros we don't want (Bt Tn Ud);Ingo Schwarze2017-05-301-1/+13
| | | | not a WARNING because they don't endanger portability
* warn about punctuation between .Xr and .Rs in SEE ALSO;Ingo Schwarze2017-05-141-1/+1
| | | | inspired by mdoclint
* Move .sp to the roff modules. Enough infrastructure is in placeIngo Schwarze2017-05-051-4/+4
| | | | now that this actually saves code: -70 LOC.