summaryrefslogtreecommitdiffstats
path: root/man_validate.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix mandoc_normdate() and the way it is used.Ingo Schwarze2019-06-271-14/+12
| | | | | | | | | | 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
* Cleanup, no functional change:Ingo Schwarze2018-12-311-2/+1
| | | | | | 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 sometimesIngo Schwarze2018-12-311-3/+19
| | | | | | 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)Ingo Schwarze2018-12-311-3/+2
| | | | | | 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: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.
* s/OpenBSD/Id/ in CVS IdsIngo Schwarze2018-12-161-1/+1
|
* Almost mechanical diff to remove the "struct mparse *" argumentIngo Schwarze2018-12-141-34/+26
| | | | | | | | 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.Ingo Schwarze2018-12-141-0/+1
| | | | | | | | | | | 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 allIngo Schwarze2018-12-041-39/+48
| | | | | | | | | | | | | | 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-4/+31
| | | | | | 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(7),Ingo Schwarze2018-08-181-0/+2
| | | | used in most manual pages of the groff package
* implement the GNU man-ext .TQ macro in man(7),Ingo Schwarze2018-08-161-0/+1
| | | | used for example by groff_diff(7)
* 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.
* preserve comments before .Dd when converting mdoc(7) to man(7)Ingo Schwarze2018-04-111-3/+3
| | | | with mandoc -Tman; suggested by Thomas Klausner <wiz at NetBSD>
* Fix a typo that caused a non-constant stringIngo Schwarze2017-07-261-2/+1
| | | | | 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);Ingo Schwarze2017-06-251-1/+3
| | | | patch from bentley@
* Split -Wstyle into -Wstyle and the even lower -Wbase, and addIngo Schwarze2017-06-241-7/+11
| | | | | | | | | | | | | | | -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-0/+8
|
* if .in is used inside the .TP head, it's always relativeIngo Schwarze2017-06-171-2/+19
|
* Style message about legacy man(7) date format in mdoc(7) documentsIngo Schwarze2017-06-111-3/+2
| | | | | and operating system dependent messages about missing or unexpected Mdocdate; inspired by mdoclint(1).
* Move .sp to the roff modules. Enough infrastructure is in placeIngo Schwarze2017-05-051-1/+4
| | | | now that this actually saves code: -70 LOC.
* move .ll to the roff modulesIngo Schwarze2017-05-051-1/+0
|
* Move handling of the roff(7) .ft request from the man(7)Ingo Schwarze2017-05-051-44/+2
| | | | | 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:Ingo Schwarze2017-05-041-1/+11
| | | | | Generate the first node on the roff level: .br Fix some column numbers in diagnostic messages while here.
* Continue parser unification:Ingo Schwarze2017-04-241-12/+12
| | | | | | | | * 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, replacingIngo Schwarze2016-01-081-10/+10
| | | | | | | | 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, tooIngo Schwarze2015-10-221-32/+17
|
* To make the code more readable, delete 283 /* FALLTHROUGH */ commentsIngo Schwarze2015-10-121-8/+0
| | | | | | 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 individualIngo Schwarze2015-04-191-1/+1
| | | | | | 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:Ingo Schwarze2015-04-191-4/+5
| | | | | | | | | | | * 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.Ingo Schwarze2015-04-181-2/+2
| | | | | Almost completely mechanical, no functional change. Written on the train from Exeter to London returning from p2k15.
* Third step towards parser unification:Ingo Schwarze2015-04-021-13/+13
| | | | | 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:Ingo Schwarze2015-04-021-4/+4
| | | | | | | | | 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:Ingo Schwarze2015-04-021-19/+22
| | | | | | 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 argumentsIngo Schwarze2015-02-061-21/+22
|
* better diagnostics about excess arguments to .PD .ft .spIngo Schwarze2015-02-061-10/+1
|
* better error reporting for .br .fi .nf with argumentsIngo Schwarze2015-02-061-10/+2
|
* Delete the legacy generic warning type MANDOCERR_ARGCWARN,Ingo Schwarze2015-02-061-3/+3
| | | | | 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)Ingo Schwarze2015-01-241-1/+0
| | | | | 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 lineIngo Schwarze2014-12-281-0/+2
| | | | | | 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,Ingo Schwarze2014-11-281-65/+50
| | | | and some cleanup; no functional change, minus 70 lines.
* Get rid of HAVE_CONFIG_H, it is always defined; idea from libnbcompat.Ingo Schwarze2014-08-101-2/+0
| | | | | | Include <sys/types.h> where needed, it does not belong in config.h. Remove <stdio.h> from config.h; if it is missing somewhere, it should be added, but i cannot find a *.c file where it is missing.
* Bring the handling of defective prologues even closer to groff,Ingo Schwarze2014-08-061-8/+11
| | | | | | | | | | | | 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:Ingo Schwarze2014-08-011-120/+69
| | | | | | | | | 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()Ingo Schwarze2014-08-011-2/+4
|
* mention requests and macros in more messagesIngo Schwarze2014-08-011-5/+9
|
* Improve handling of next-line scope broken by end of file.Ingo Schwarze2014-07-301-21/+3
| | | | | | 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:Ingo Schwarze2014-07-071-4/+3
| | | | Hierarchical naming and mention macro names in messages.