summaryrefslogtreecommitdiffstats
path: root/usr.bin/mandoc/man_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
* Cleanup, no functional change:schwarze2018-12-311-3/+2
| | | | | | Since the man(7) and roff(7) validators no longer use the parser state flag ROFF_NOFILL, we can finally get rid of the function man_state(), resulting in a better separation of parsing and validation.
* Use the new flag NODE_NOFILL in the validators, which is sometimesschwarze2018-12-311-4/+20
| | | | | | 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.
* Move parsing of the .nf and .fi (fill mode) requests from the man(7)schwarze2018-12-311-4/+3
| | | | | | parser to the roff(7) parser. As a side effect, .nf and .fi are now also parsed in mdoc(7) input, though the mdoc(7) formatters still ignore most of their effect.
* 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.
* Almost mechanical diff to remove the "struct mparse *" argumentschwarze2018-12-141-35/+27
| | | | | | | | 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.
* Major cleanup; may imply minor changes in edge cases of error reporting.schwarze2018-12-141-1/+2
| | | | | | | | | | | 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.
* Clean up the validation of .Pp, .PP, .sp, and .br. Make sure allschwarze2018-12-041-40/+49
| | | | | | | | | | | | | | 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-5/+32
| | | | | | 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.
* implement the GNU man-ext .SY/.YS (synopsis block) macro in man,schwarze2018-08-181-1/+3
| | | | used in most manual pages of the groff package
* implement the GNU man-ext .TQ macro in man(7),schwarze2018-08-161-1/+2
| | | | used for example by groff_diff(7)
* 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.
* preserve comments before .Dd when converting mdoc(7) to man(7)schwarze2018-04-111-4/+4
| | | | with mandoc -Tman; suggested by Thomas Klausner <wiz at NetBSD>
* Fix a typo that caused a non-constant stringschwarze2017-07-261-3/+2
| | | | | to be passed as a format string; no functional change; reported by Michael <Stapelberg at debian>.
* Add support for the MT and ME mailto macros, used for example in wg(8).bentley2017-06-251-2/+4
| | | | feedback and ok schwarze@
* Split -Wstyle into -Wstyle and the even lower -Wbase, and addschwarze2017-06-241-8/+12
| | | | | | | | | | | | | | | -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-1/+9
|
* if .in is used inside the .TP head, it's always relativeschwarze2017-06-171-3/+20
|
* Style message about legacy man(7) date format in mdoc(7) documentsschwarze2017-06-111-4/+3
| | | | | and operating system dependent messages about missing or unexpected Mdocdate; inspired by mdoclint(1).
* Move .sp to the roff modules. Enough infrastructure is in placeschwarze2017-05-051-2/+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-45/+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-2/+12
| | | | | Generate the first node on the roff level: .br Fix some column numbers in diagnostic messages while here.
* Continue parser unification:schwarze2017-04-241-13/+13
| | | | | | | | * Make enum rofft an internal interface as enum roff_tok in "roff.h". * Represent mdoc and man macros in enum roff_tok. * Make TOKEN_NONE a proper enum value and use it throughout. * Put the prologue macros first in the macro tables. * Unify mdoc_macroname[] and man_macroname[] into roff_name[].
* Delete the redundant "nchild" member of struct roff_node, replacingschwarze2016-01-081-11/+11
| | | | | | | | most uses by one, a few by two pointer checks, and only one by a tiny loop - not only making data smaller, but code shorter as well. This gets rid of an implicit invariant that confused both static analysis tools and human auditors. No functional change.
* move man(7) validation into the dedicated validation phase, tooschwarze2015-10-221-33/+18
|
* To make the code more readable, delete 283 /* FALLTHROUGH */ commentsschwarze2015-10-121-9/+1
| | | | | | that were right between two adjacent case statement. Keep only those 24 where the first case actually executes some code before falling through to the next case.
* Decouple the token code for "no request or macro" from the individualschwarze2015-04-191-2/+2
| | | | | | high-level parsers to allow further unification of functions that only need to recognize this code, but that don't care about different high-level macrosets beyond that.
* Unify node handling functions:schwarze2015-04-191-5/+6
| | | | | | | | | | | * node_alloc() for mdoc and man_node_alloc() -> roff_node_alloc() * node_append() for mdoc and man_node_append() -> roff_node_append() * mdoc_head_alloc() and man_head_alloc() -> roff_head_alloc() * mdoc_body_alloc() and man_body_alloc() -> roff_body_alloc() * mdoc_node_unlink() and man_node_unlink() -> roff_node_unlink() * mdoc_node_free() and man_node_free() -> roff_node_free() * mdoc_node_delete() and man_node_delete() -> roff_node_delete() Minus 130 lines of code, no functional change.
* Replace the structs mdoc and man by a unified struct roff_man.schwarze2015-04-181-3/+3
| | | | | Almost completely mechanical, no functional change. Written on the train from Exeter to London returning from p2k15.
* Third step towards parser unification:schwarze2015-04-021-14/+14
| | | | | Replace struct mdoc_meta and struct man_meta by a unified struct roff_meta. Written of the train from London to Exeter on the way to p2k15.
* Second step towards parser unification:schwarze2015-04-021-5/+5
| | | | | | | | | Replace struct mdoc_node and struct man_node by a unified struct roff_node. To be able to use the tok member for both mdoc(7) and man(7) without defining all the macros in roff.h, sacrifice a tiny bit of type safety and make tok an int rather than an enum. Almost mechanical, no functional change. Written on the Eurostar from Bruxelles to London on the way to p2k15.
* First step towards parser unification:schwarze2015-04-021-20/+23
| | | | | | Replace enum mdoc_type and enum man_type by a unified enum roff_type. Almost mechanical, no functional change. Written on the ICE train from Frankfurt to Bruxelles on the way to p2k15.
* better error reporting regarding .OP .RS .UR .TH argumentsschwarze2015-02-061-22/+23
|
* better diagnostics about excess arguments to .PD .ft .spschwarze2015-02-061-11/+2
|
* better error reporting for .br .fi .nf with argumentsschwarze2015-02-061-11/+3
|
* Delete the legacy generic warning type MANDOCERR_ARGCWARN,schwarze2015-02-061-4/+4
| | | | | replacing the last instances by more specific warnings. Improved functionality, minus 50 lines of code.
* Strangely, ignoring the roff(7) .na request was implemented in the man(7)schwarze2015-01-241-2/+1
| | | | | parser. Simplify the code by moving it into the roff(7) parser, also making it work for mdoc(7).
* mdoc(7) already uses the mandoc(1) -Ios argument in the footer lineschwarze2014-12-281-1/+3
| | | | | | when .Os has no argument, so do the same for man(7) when .TH has less than four arguments; there is no reason to treat both differently. Issue found following a question from Thomas Klausner <wiz at NetBSD>.
* Simplify by making many functions in the man(7) parser void,schwarze2014-11-281-65/+50
| | | | and some cleanup; no functional change, minus 70 lines.
* Bring the handling of defective prologues even closer to groff,schwarze2014-08-081-9/+12
| | | | | | | | | | | | in particular relaxing the distinction between prologue and body and further improving messages. * The last .Dd wins and the last .Os wins, even in the body. * The last .Dt before the first body macro wins. * Missing title in .Dt defaults to UNTITLED. Warn about it. * Missing section in .Dt does not default to 1. But warn about it. * Do not warn multiple times about the same mdoc(7) prologue macro. * Warn about missing .Os. * Incomplete .TH defaults to empty strings. Warn about it.
* Simplify man(7) validation:schwarze2014-08-081-121/+70
| | | | | | | | | Drop pre-handlers, they were almost unused. Drop the needless complexity of allowing more than one post-handler. This saves one internal interface function, one static function, one private struct definition, sixteen static arrays, and 45 lines of code. No functional change.
* demacrify: get rid of man_nmsg(), man_pmsg(), mdoc_nmsg(), mdoc_pmsg()schwarze2014-08-081-3/+5
|
* mention requests and macros in more messagesschwarze2014-08-081-6/+10
|
* Improve handling of next-line scope broken by end of file.schwarze2014-08-081-22/+4
| | | | | | Detect the condition earlier, report in the error message which block is broken, and delete the broken block. Consequently, empty section headers can no longer happen.
* Clean up ERROR messages related to document structure and macros:schwarze2014-07-071-5/+4
| | | | Hierarchical naming and mention macro names in messages.
* Clean up messages related to plain text and to escape sequences.schwarze2014-07-061-2/+3
| | | | | * Mention invalid escape sequences and string names, and fallbacks. * Hierarchical naming.
* Cleanup with respect to bad macro arguments.schwarze2014-07-051-3/+3
| | | | | | | | * Fix .Sm with invalid arg: move arg out and toggle mode. * Promote "unknown standard" from WARNING to ERROR, it loses information. * Delete MANDOCERR_BADWIDTH, it would only indicate a mandoc(1) bug. * Do not report MANDOCERR_BL_LATETYPE when there is no type at all. * Mention macro names, arguments and fallbacks.
* Clean up messages regarding excess arguments:schwarze2014-07-041-2/+6
| | | | | | | * Downgrade ".Bf -emphasis Em" from FATAL to WARNING. * Mention the macros, the arguments, and the fallbacks. * Hierarchical naming. Also fix the handling of excess .It head arguments in -Tman.