aboutsummaryrefslogtreecommitdiffstatshomepage
Commit message (Collapse)AuthorAgeFilesLines
* Delete the mdoc_node.pending pointer and the function calculatingIngo Schwarze2015-02-127-174/+115
| | | | | | | | | | | | | | | | | | | | | | | 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.
* do not access a NULL pointer if an .Eo block lacks a tail;Ingo Schwarze2015-02-113-12/+9
| | | | found by jsg@ with afl, test case #16
* explicit blocks close out .Nd; fixing data structure corruptionIngo Schwarze2015-02-111-1/+8
| | | | | eventually leading to NULL pointer access; found by jsg@ with afl, text case #455.
* Be more careful to not generate empty .In, .St, and .Xr nodes.Ingo Schwarze2015-02-101-34/+44
| | | | | | | | That could happen when their first argument was another called macro, causing a NULL pointer access in .St validation found by jsg@ with afl. Make in_line_argn() easier to understand by using one state variable rather than two.
* Do not read past the end of the buffer if an "f" layout font modifierIngo Schwarze2015-02-101-11/+27
| | | | | | | | | | | is followed by the end of the input line instead of a font specifier. Found by jsg@ with afl, test case #591. While here, improve functionality as well: * There is no "r" font modifier. * Font specifiers (as opposed to font modifiers) are case sensitive. * One-character font specifiers require trailing whitespace. * Ignore parenthised and two-letter font specifiers.
* trim trailing white space, no code change;Ingo Schwarze2015-02-1010-47/+47
| | | | from Svyatoslav Mishyn <juef at openmailboxd dot org>, Crux Linux
* Closing a block validates it, which may end up deleting it,Ingo Schwarze2015-02-071-1/+2
| | | | | so if we are in a loop over blocks, cleanly restart the loop rather than risking use after free; found by jsg@ with afl.
* some tweaks to the DIAGNOSTICS sectionIngo Schwarze2015-02-071-14/+11
|
* ignore O_CLOEXEC when the operating system doesn't provide it;Ingo Schwarze2015-02-071-1/+4
| | | | | needed for some older versions of SunOS; from jperkin@ via wiz@, both at NetBSD
* trivial sync to OpenBSD: <sys/param.h> no longer neededIngo Schwarze2015-02-071-5/+5
|
* be more careful about argc == 0Ingo Schwarze2015-02-072-11/+15
|
* replace the last legacy generic message type, "argument count wrong",Ingo Schwarze2015-02-065-19/+31
| | | | by more specific messages, improving diagnostics for .cc .tr .Bl -column
* better error reporting regarding .OP .RS .UR .TH argumentsIngo Schwarze2015-02-065-58/+80
|
* better diagnostics about excess arguments to .PD .ft .spIngo Schwarze2015-02-063-12/+14
|
* better error reporting for .br .fi .nf with argumentsIngo Schwarze2015-02-063-13/+15
|
* Delete the legacy generic warning type MANDOCERR_ARGCWARN,Ingo Schwarze2015-02-066-100/+44
| | | | | replacing the last instances by more specific warnings. Improved functionality, minus 50 lines of code.
* better handle .Fo and .Fd without argumentIngo Schwarze2015-02-066-21/+49
| | | | better handle .Fo with more than one argument
* better handle empty .Bd .Bl .D1 .Dl blocksIngo Schwarze2015-02-061-39/+45
|
* better handle .In .Sh .Ss .St .Xr without argumentsIngo Schwarze2015-02-062-12/+15
|
* fix handling of empty .An macrosIngo Schwarze2015-02-054-15/+11
|
* Simplify by deleting the "lastline" member of struct mdoc_node.Ingo Schwarze2015-02-056-31/+14
| | | | Minus one struct member, minus 17 lines of code, no functional change.
* Discard excess head arguments for .Bd .Bl .Bk and delete hwarn_eq0().Ingo Schwarze2015-02-043-46/+56
| | | | | Discard empty .Bk blocks. Improve related diagnostics.
* improve diagnostics regarding arguments of .An .Pp .Lp .br .spIngo Schwarze2015-02-042-13/+29
| | | | in particular, get rid of check_count(..., CHECK_EQ, 0)
* fix column numbers of macro arguments in messagesIngo Schwarze2015-02-041-2/+2
|
* discard .Rs head arguments and improve .Rs diagnosticsIngo Schwarze2015-02-045-43/+57
|
* more specific .Nd diagnostics, allowing to get rid of enum check_lvlIngo Schwarze2015-02-044-29/+39
| | | | and the respective argument of check_count()
* Enable the integrated man(1) even when database support is disabled,Ingo Schwarze2015-02-033-68/+48
| | | | | | using the file system lookup fallback code, also reducing the number of preprocessor conditional directives. Hopefully, it will make some small Linux distros happy.
* reduce indentation for better readabilityIngo Schwarze2015-02-031-13/+21
|
* Avoid closing out an explicit block twice when broken by .ItIngo Schwarze2015-02-031-1/+2
| | | | (assertion failure); regression found in jsg@'s afl test case 847.
* minimal support for Heirloom nroffIngo Schwarze2015-02-031-5/+17
|
* Finally delete the kitchensink functions rew_sub() and rew_dohalt().Ingo Schwarze2015-02-031-160/+75
| | | | | | | They were a maintenance and auditing nightmare because if you changed one bit in there, stuff tended to break at seemingly unrelated places. No functional change except getting rid of one bogus error message, but minus 80 lines of code.
* Bring .Pp/.Lp handling inside .Nm blocks closer to groff;Ingo Schwarze2015-02-032-8/+23
| | | | as a bonus, get rid of another call to rew_sub().
* Simplify and reindent make_pending(). No functional changeIngo Schwarze2015-02-021-57/+50
| | | | | | except that some error messages become less confusing. Now the function is almost readable (but still requires nineteen lines of comments for fourteen lines of code).
* Simplify: Do not call rew_dohalt() from make_pending(),Ingo Schwarze2015-02-021-31/+21
| | | | | the calling macro handler already found the breaking block. No functional change except tiny variations in error messages.
* Get rid of all remaining calls to rew_sub() where the target blockIngo Schwarze2015-02-021-66/+37
| | | | | is known. This only leaves three that do actual searching. No functional change, minus 30 lines of code.
* Get rid of all calls to rew_sub() in blk_exp_close(); only ten callsIngo Schwarze2015-02-023-69/+72
| | | | | | remain in other functions. As a bonus, this fixes an assertion failure jsg@ found some time ago with afl (test case 982) and improves minor details in error reporting.
* When a full block macro gets closed out by a mismatchingIngo Schwarze2015-02-021-4/+7
| | | | | | | | | block closure macro it calls, do not attempt to open its body. This can for example happen for (nonsensical) constructions like .Fo .Nm Fc in the SYNOPSIS. Fixing an assertion failure jsg@ found with afl some time ago (test case number 731).
* get rid of rew_sub() in blk_part_imp(); no functional changeIngo Schwarze2015-02-011-3/+14
|
* fix .Eo/.Ec spacingIngo Schwarze2015-02-013-31/+132
|
* Simplify blk_part_exp(), no functional change.Ingo Schwarze2015-02-011-24/+8
| | | | | | * Replace calls to rew_sub() with rew_last() - two less out of 18. * No need to keep track of the body, it's always opened right after the head and never used for anything in this function.
* The function rew_sub() tries to rewind any all all kinds of blocksIngo Schwarze2015-02-011-5/+4
| | | | | | | | | | and elements under any and all circumstances, even handling some bad block nesting now and then. Little surprisingly, this ends up in excessive complexity and has caused many bugs in the past. Start to slowly disentangle this mess by replacing calls to rew_sub() immediately following mdoc_head_alloc() by the much simpler rew_last(). Gets rid of the first two rew_sub() calls out of twenty. No functional change.
* Use relative offsets instead of absolute pointers for the terminalIngo Schwarze2015-01-315-25/+16
| | | | | | font stack. The latter fail after the stack is grown with realloc(). Fixing an assertion failure found by jsg@ with afl some time ago (test case number 51).
* Have pity on the poor stack.Ingo Schwarze2015-01-304-19/+22
| | | | | Replace tail recursion by iteration when walking the syntax trees. No functional change.
* starting a tbl(7) breaks man(7) next-line scope;Ingo Schwarze2015-01-301-59/+66
| | | | triggered by a bug report from jsg@
* Delete the redundant tbl span flags, just inspect the actual dataIngo Schwarze2015-01-306-19/+11
| | | | | | | | where needed, which is less fragile. This fixes a subtle NULL pointer access to tp->tbl.cols: Due to a bug in the man(7) parser, the first span of a table can end up in a .TP head, in which case tblcalc() was never called. Found by jsg@ with afl.
* Abolish struct tbl_head and replace it by an "int col" member inIngo Schwarze2015-01-309-124/+134
| | | | struct tbl_cell. No functional change, minus 40 lines of code.
* Auditing the tbl(7) code for more NULL pointer accesses, i came outIngo Schwarze2015-01-305-72/+55
| | | | | empty-handed; so this is just KNF and some code simplifications, no functional change.
* Make sure every layout line contains at least one cell;Ingo Schwarze2015-01-301-11/+31
| | | | fixing a NULL pointer access in term_tbl() that jsg@ found with afl.
* correctly handle table layout lines starting with a dotIngo Schwarze2015-01-301-2/+2
|
* Radical cleanup of COMPATIBILITY sections:Ingo Schwarze2015-01-296-311/+92
| | | | | | | | Remove lots of lies, dozens of irrelevant implementation details, and all references to groff versions older than 1.17. Move relevant information to the pages where it belongs, and out of mandoc(1) in particular. Add some missing general remarks to roff(7), where it fits the character and purpose of the page much better.