summaryrefslogtreecommitdiffstats
path: root/mdoc_validate.c
Commit message (Collapse)AuthorAgeFilesLines
...
* If a column list starts with implicit rows (that is, rows without .It)Ingo Schwarze2016-08-201-5/+33
| | | | | | and roff-level nodes (e.g. tbl or eqn) follow, don't run into an assertion. Instead, wrap the roff-level nodes in their own row. Issue found by tb@ with afl(1).
* oops, fix stupid typo in previousIngo Schwarze2016-08-111-1/+2
|
* If a .Bd display is on the one hand doomed to be deleted becauseIngo Schwarze2016-08-111-3/+4
| | | | | | | it has no type, but is on the other hand breaking another block, delete its end marker as well, or the end marker may remain behind as an orphan, triggering an assertion in the terminal formatter. Problem found by tb@ with afl(1).
* Don't deref NULL if the only child of the first .Sh is an emptyIngo Schwarze2016-08-101-4/+7
| | | | | | in-line macro, and don't printf("%s", NULL) if the first child of the first .Sh is a macro; again found by tb@ with afl(1). (No, you should never use macros in any .Sh at all, please.)
* Don't printf("%s", NULL) if .It has a macro as an argumentIngo Schwarze2016-08-101-2/+3
| | | | | in a list of a type where items don't takes arguments. Issue found by tb@ with afl(1).
* When validating a .Bl list that defaults to -item for want of a type,Ingo Schwarze2016-08-101-0/+1
| | | | | don't let a subsequent -width access mdoc_argnames[] out of bounds. Found by tb@ with afl(1).
* fix printf("%s", NULL);Ingo Schwarze2016-08-091-3/+4
| | | | found while investigating an unrelated bug report from jsg@
* Delete the redundant "nchild" member of struct roff_node, replacingIngo Schwarze2016-01-081-13/+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.
* If a .Bd block has no arguments at all, drop the block and only keepIngo Schwarze2015-10-301-0/+10
| | | | | its contents. Removing a gratuitious difference to groff output found after a related bug report from krw@.
* Move all mdoc(7) node validation done before child parsingIngo Schwarze2015-10-211-242/+212
| | | | | | to the new separate validation pass, except for a tiny bit needed by the parser which goes to the new mdoc_state() module; cleaner, simpler, and surprisingly also shorter by 15 lines.
* In order to become able to generate syntax tree nodes on the roff(7)Ingo Schwarze2015-10-201-129/+64
| | | | | | | | level, validation must be separated from parsing and rewinding. This first big step moves calling of the mdoc(7) post_*() functions out of the parser loop into their own mdoc_validate() pass, while using a new mdoc_state() module to make syntax tree state handling available to both the parser loop and the validation pass.
* style cleanup, no functional changeIngo Schwarze2015-10-191-55/+58
|
* Delete an assignment that is unconditionally overwritten two lines later;Ingo Schwarze2015-10-121-1/+0
| | | | | found by Svyatoslav Mishyn <juef at openmailbox dot org> with the clang static analyzer.
* To make the code more readable, delete 283 /* FALLTHROUGH */ commentsIngo Schwarze2015-10-121-22/+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.
* modernize style: "return" is not a functionIngo Schwarze2015-10-061-46/+46
|
* /* NOTREACHED */ after abort() is silly, delete itIngo Schwarze2015-09-261-3/+0
|
* Remove the warning about children of .Vt blocks because actually,Ingo Schwarze2015-09-141-24/+1
| | | | | | | .Vt type global_variable No = Dv defined_constant ; is the best way to specify in the SYNOPSIS how a global variable is initialized in the rare case where that matters. Issue noticed by jmc@.
* Unify mdoc_deroff() and man_deroff() into a common function deroff().Ingo Schwarze2015-04-231-4/+4
| | | | | | | | No functional change except that for mdoc(7), it now skips leading escape sequences just like it already did for man(7). Escape sequences rarely occur in mdoc(7) code and if they do, skipping them is an improvement in this context. Minus 30 lines of code.
* Avoid out-of-bounds read access before the beginning of theIngo Schwarze2015-04-201-1/+2
| | | | | mdoc_macros[] array. This sometimes prevented proper warnings about text nodes preceding the first section header.
* Unify some node handling functions that use TOKEN_NONE.Ingo Schwarze2015-04-191-5/+5
| | | | | | | | * mdoc_word_alloc(), man_word_alloc() -> roff_word_alloc() * mdoc_word_append(), man_word_append() -> roff_word_append() * mdoc_addspan(), man_addspan() -> roff_addtbl() * mdoc_addeqn(), man_addeqn() -> roff_addeqn() Minus 50 lines of code, no functional change.
* Decouple the token code for "no request or macro" from the individualIngo Schwarze2015-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:Ingo Schwarze2015-04-191-14/+15
| | | | | | | | | | | * 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-14/+14
| | | | | Almost completely mechanical, no functional change. Written on the train from Exeter to London returning from p2k15.
* Second step towards parser unification:Ingo Schwarze2015-04-021-55/+55
| | | | | | | | | 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-48/+49
| | | | | | 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.
* oops, in NAME, don't nag about the comma after .NmIngo Schwarze2015-02-231-0/+4
|
* improve NAME section diagnostics;Ingo Schwarze2015-02-231-24/+24
| | | | confusing messages reported by Jan Stary <hans at stare dot cz>
* Render \(lq and \(rq as '"' in -Tascii mode but leave the renderingIngo Schwarze2015-02-171-1/+1
| | | | | | of .Do/.Dc, .Dq, .Lb, and .St untouched. Reduces groff-mandoc differences in OpenBSD base by about 7%. Reminded of the issue by naddy@.
* clean up post_dt() validation function;Ingo Schwarze2015-02-161-42/+40
| | | | improved diagnostics, minus six lines of code
* shut up about tabs in SYNOPSIS .Fd lines, there is no good way to avoid themIngo Schwarze2015-02-141-1/+2
|
* Delete the mdoc_node.pending pointer and the function calculatingIngo Schwarze2015-02-121-39/+5
| | | | | | | | | | | | | | | | | | | | | | | it, make_pending(), which was the most difficult function of the whole mdoc(7) parser. After almost five years of maintaining this hellhole, i just noticed the pointer isn't needed after all. Blocks are always rewound in the reverse order they were opened; that even holds for broken blocks. Consequently, it is sufficient to just mark broken blogs with the flag MDOC_BROKEN and breaking blocks with the flag MDOC_ENDED. When rewinding, instead of iterating the pending pointers, just iterate from each broken block to its parents, rewinding all that are MDOC_ENDED and stopping after processing the first ancestor that it not MDOC_BROKEN. For ENDBODY markers, use the mdoc_node.body pointer in place of the former mdoc_node.pending. This also fixes an assertion failure found by jsg@ with afl, test case #467 (Bo Bl It Bd Bc It), where (surprise surprise) the pending pointer got corrupted. Improved functionality, minus one function, minus one struct field, minus 50 lines of code.
* trim trailing white space, no code change;Ingo Schwarze2015-02-101-1/+1
| | | | from Svyatoslav Mishyn <juef at openmailboxd dot org>, Crux Linux
* replace the last legacy generic message type, "argument count wrong",Ingo Schwarze2015-02-061-2/+2
| | | | by more specific messages, improving diagnostics for .cc .tr .Bl -column
* Delete the legacy generic warning type MANDOCERR_ARGCWARN,Ingo Schwarze2015-02-061-80/+18
| | | | | replacing the last instances by more specific warnings. Improved functionality, minus 50 lines of code.
* better handle .Fo and .Fd without argumentIngo Schwarze2015-02-061-12/+21
| | | | better handle .Fo with more than one argument
* better handle empty .Bd .Bl .D1 .Dl blocksIngo Schwarze2015-02-061-38/+44
|
* better handle .In .Sh .Ss .St .Xr without argumentsIngo Schwarze2015-02-061-10/+2
|
* fix handling of empty .An macrosIngo Schwarze2015-02-051-4/+6
|
* Discard excess head arguments for .Bd .Bl .Bk and delete hwarn_eq0().Ingo Schwarze2015-02-041-35/+36
| | | | | Discard empty .Bk blocks. Improve related diagnostics.
* improve diagnostics regarding arguments of .An .Pp .Lp .br .spIngo Schwarze2015-02-041-10/+14
| | | | in particular, get rid of check_count(..., CHECK_EQ, 0)
* discard .Rs head arguments and improve .Rs diagnosticsIngo Schwarze2015-02-041-35/+33
|
* more specific .Nd diagnostics, allowing to get rid of enum check_lvlIngo Schwarze2015-02-041-24/+26
| | | | and the respective argument of check_count()
* Bring .Pp/.Lp handling inside .Nm blocks closer to groff;Ingo Schwarze2015-02-031-3/+11
| | | | as a bonus, get rid of another call to rew_sub().
* Only keep leading .Sm inside a list when it immediately precedesIngo Schwarze2014-12-181-1/+4
| | | | | the first .It. Otherwise, move it out together with whatever follows. Fixing an assertion failure found by jsg@ with afl.
* When the head of a list item is extended with a partial explicitIngo Schwarze2014-12-181-6/+6
| | | | | | | | macro (for example .Xo) and never closed again, the item ends up without a body block. This can even happen for list types that usually don't have heads in the first place. So even in this case, check for the existence of the body before accessing it. NULL pointer access found by jsg@ with afl.
* Multiple fixes with respect to .Pf:Ingo Schwarze2014-11-301-1/+1
| | | | | | | * The first argument of .Pf is not parsed. * Normal delimiter handling does not apply to the first argument of .Pf. * Warn if nothing follows a prefix (inspired by groff_mdoc(7)). * In that case, do not suppress spacing.
* Retire support for CSRG supplementary document titles. These areIngo Schwarze2014-11-281-12/+2
| | | | | long obsolete and were never written in mdoc(7) in the first place. Removes 100 lines from source files.
* Drop useless architecture table. Validating architecture namesIngo Schwarze2014-11-281-13/+6
| | | | | | is a job for makewhatis(8)/mandoc.db(5), not for the parser. Removes 150 lines from source files and 4k (1%) from the binary. Bloat found by deraadt@.
* kill a pointless assertIngo Schwarze2014-11-281-3/+0
|
* Simplify code by making mdoc validation handlers void.Ingo Schwarze2014-11-281-322/+221
| | | | No functional change, minus 90 lines of code.