summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc
AgeCommit message (Collapse)Author
2015-07-19Do not fork and exec gunzip(1), just link with libz instead.Ingo Schwarze
As discussed with deraadt@, that's cleaner and will help tame(2). Something like this was also suggested earlier by bapt at FreeBSD. Minus 50 lines of code, deleting one interface function (mparse_wait), no functional change intended.
2015-07-19If we aren't on a tty, clear the pager flag up front.Ingo Schwarze
Just to clean up code structure, no functional change.
2015-07-18Insist that manual page file name extensions must begin with a digit,Ingo Schwarze
lest pkg.conf(5) be shown when pkg(5) is asked for; issue reported by Michael Reed <m dot reed at mykolab dot com>.
2015-07-18clean up the temporary file when the process dies from a signalIngo Schwarze
2015-07-17Initial, still somewhat experimental implementation to leverageIngo Schwarze
less(1) -T and :t ctags(1)-like functionality to jump to the definitions of various terms inside manual pages. To be polished in the tree, so bear with me and report issues. Technically, if less(1) is used as a pager, information is collected by the mdoc(7) terminal formatter, first stored using the ohash library, then ultimately written to a temporary file which is passed to less via -T. No change intended for other output formatters or when running without a pager. Based on an idea from Kristaps using feedback from many, in particular phessler@ nicm@ millert@ halex@ doug@ kspillner@ deraadt@.
2015-06-27Ignore blank characters at the beginning of a conditional block,Ingo Schwarze
that is, after "\{". Issue found by Markus <Waldeck at gmx dot de> in bash(1).
2015-05-31Implement the roff(7) `r' (register exists) conditional.Ingo Schwarze
Missing feature found by Markus <Waldeck at gmx dot de> in Debian's bash(1) manual page.
2015-05-07Do not let the -m option or MANPATH with leading, trailing, or doubleIngo Schwarze
colon override the default manpath, let them add to the default manpath. Only override the default manpath by the -M option, by MANPATH without leading, trailing, or double colon, or by "manpath" in man.conf(5). Problem reported by Jan Stary <hans at stare dot cz>. Patch OK'ed by millert@.
2015-05-01mdoc_valid_post() may indirectly call roff_node_unlink() which mayIngo Schwarze
set ROFF_NEXT_CHILD, which is desirable for the final call to mdoc_valid_post() - in case the target itself gets deleted, the parse point may need this adjustment - but not for the intermediate calls - if intermediate nodes get deleted, that mustn't clobber the parse point. So move setting ROFF_NEXT_SIBLING to the proper place in rew_last(). This fixes the assertion failure in jsg@'s afl test case 108/Apr27.
2015-05-01Setting the "last" member of struct roff_node was done at an extremelyIngo Schwarze
weird place. Move it to the obviously correct place. Surprisingly, this didn't cause any misformatting in the test suite or in any base system manuals, but i cannot believe the code was really correct for all conceivable input, and it would be very hard to verify. At the very least, it cannot have worked for man(7).
2015-05-01Minor bug fix: When .Pp rewinds .Nm, rewind the whole block,Ingo Schwarze
not just the body. In some unusual edge cases, this caused the .Pp to become a sibling of the .Nm body inside the .Nm block.
2015-04-29If a block body gets broken, that's no good reason to extend theIngo Schwarze
scope of the end macro. Instead, only keep the tail scope open if the end macro macro calls an explicit macro and actually breaks that. This corrects syntax tree structure and fixes an assertion found by jsg@ with afl (test case 098/Apr27).
2015-04-29Replace the kludge for the \z escape sequence by an actualIngo Schwarze
implementation. As a side effect, minus ten lines of code. As another side effect, this also fixes the assertion failure that used to be triggered by "\z\o'ab'c" at the beginning of an output line, found by jsg@ with afl (test case 022/Apr27).
2015-04-29Do not mark a block with the MDOC_BROKEN flag if it merely containsIngo Schwarze
a mismatching explicit end macro without actually being broken. Avoids a subsequent upward search for the non-existent breaker ending up in a NULL pointer access; afl test case 005/Apr27 from jsg@.
2015-04-29When the last line of a table layout turns out to be empty, it is deleted.Ingo Schwarze
Do not just free the struct tbl_row but also make sure that no pointer to it remains. Fixing a use after free found by jsg@ with afl.
2015-04-29Improve the error message in case somebody has configured an invalid PAGER.Ingo Schwarze
Suggested by Lorenzo Beretta <lory dot fulgi at infinito dot it>.
2015-04-23Unify mdoc_deroff() and man_deroff() into a common function deroff().Ingo Schwarze
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.
2015-04-23Get rid of two empty wrapper functions. No functional change.Ingo Schwarze
2015-04-21Avoid a use after free when the target node is deleted during validation.Ingo Schwarze
Bug reported by jsg@.
2015-04-20Fix previous: Don't let man(1) warn twice about non-existant names.Ingo Schwarze
Again noticed by deraadt@.
2015-04-20Avoid out-of-bounds read access before the beginning of theIngo Schwarze
mdoc_macros[] array. This sometimes prevented proper warnings about text nodes preceding the first section header.
2015-04-19More than one data field may follow T} on the same input line.Ingo Schwarze
Issue found by Christian Neukirchen <chneukirchen at gmail dot com> in the socket(2) manual on Linux. Also fixes major rendering bugs (including partial loss of content) in XkbChangeControls(3), XkbFreeClientMap(3), XkbGetMap(3), XkbKeyNumGroups(3), and XkbSetMap(3).
2015-04-19If an explicit line break request (.br or .sp) occurs within an .HP block,Ingo Schwarze
the next line doesn't hang, but is simply indented. Issue found by Christian Neukirchen <chneukirchen at gmail dot com> in the dmsetup(8) manual on Linux. This patch also improves the indentation of XDGA(3) and XrmGetResource(3).
2015-04-19If apropos(1) finds no match, print "nothing appropriate" to stderrIngo Schwarze
similar to what the old apropos did. Requested by and OK deraadt@.
2015-04-19Unify trickier node handling functions.Ingo Schwarze
* man_elem_alloc() -> roff_elem_alloc() * man_block_alloc() -> roff_block_alloc() The functions mdoc_elem_alloc() and mdoc_block_alloc() remain for now because they need to do mdoc(7)-specific argument processing.
2015-04-19Unify some node handling functions that use TOKEN_NONE.Ingo Schwarze
* 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.
2015-04-19Decouple the token code for "no request or macro" from the individualIngo Schwarze
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.
2015-04-19Unify node handling functions:Ingo Schwarze
* 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.
2015-04-18Delete the wrapper functions mdoc_meta(), man_meta(), mdoc_node(),Ingo Schwarze
man_node() from the mandoc(3) semi-public interface and the internal wrapper functions print_mdoc() and print_man() from the HTML formatters. Minus 60 lines of code, no functional change.
2015-04-18Unify {mdoc,man}_{alloc,reset,free}() into roff_man_{alloc,reset,free}().Ingo Schwarze
Minus 80 lines of code, no functional change. Written on the train from Koeln to Wolfsburg returning from p2k15.
2015-04-18Move mdoc_hash_init() and man_hash_init() to libmandoc.hIngo Schwarze
and call them from mparse_alloc() and choose_parser(), preparing unified allocation of struct roff_man.
2015-04-18Profit from the unified struct roff_man and reduce the number ofIngo Schwarze
arguments of mparse_result() by one. No functional change. Written on the ICE Bruxelles-Koeln on the way back from p2k15.
2015-04-18Replace the structs mdoc and man by a unified struct roff_man.Ingo Schwarze
Almost completely mechanical, no functional change. Written on the train from Exeter to London returning from p2k15.
2015-04-16Restore the page headers and page footers that accidentally got lostIngo Schwarze
in rev. 1.225. Regression reported by florian@.
2015-04-16shorten "outdated mandoc.db" warning message; requested by deraadt@Ingo Schwarze
2015-04-06Do not mistreat empty arguments to font alternating macrosIngo Schwarze
as vertical spacing requests. Bug found with xmahjongg(6).
2015-04-06On a new RS nesting level, the saved width starts from the defaultIngo Schwarze
width, not from the saved width of the previous level. Improves xterm(1) and XSetEventQueueOwner(3); found in transcode_filter(1).
2015-04-06Use the default width for .RS without arguments.Ingo Schwarze
Reduces groff-mandoc differences in base and Xenocara by about 4%. Found while looking at wpa_supplicant(8).
2015-04-05If a partial explicit block extending to the next input line followsIngo Schwarze
the end macro of a broken block, put all of it into the breaking block. Needed for example by mutella(1).
2015-04-05Reduce code duplication, no functional change:Ingo Schwarze
Both partial and full implicit blocks can break explicit blocks. Put the code to handle both cases into a common function.
2015-04-05Arguments to end macros of broken partial explicit blocksIngo Schwarze
must go inside the breaking block. For example, in .It Ic cmd Oo .Ar optional_arg Oc Ar mandatory_arg the mandatory_arg is still inside the .It block. Used for example by mutella(1).
2015-04-04Give man(7) section and subsection headers heanging indentation.Ingo Schwarze
Reduces groff-mandoc differences in base by about 2.5% due to various Perl manuals having long section titles. Quirk found in argtable2(3).
2015-04-04Rounding rules for horizontal scaling widths are more complicated.Ingo Schwarze
There is a first rounding to basic units on the input side. After that, rounding rules differ between requests and macros. Requests round to the nearest possible character position. Macros round to the next character position to the left. Implement that by changing the return value of term_hspan() to basic units and leaving the second scaling and rounding stage to the formatters instead of doing it in the terminal handler. Improves for example argtable2(3).
2015-04-04Don't allow breaking the output line after hyphens following escapeIngo Schwarze
sequences. Improves tic(1), sxpm(1), and a few Perl manuals. Quirk found by naddy@ in milter-greylist(8).
2015-04-04Fix a quirk with respect to empty .HP.Ingo Schwarze
Found while writing a regression test for man_macro.c rev. 1.66. Incidentally, this brings rendering of XFreeEventData(3) closer to groff.
2015-04-03Vastly simplify man(7) block unwinding, similar to mdoc_macro.c 1.171.Ingo Schwarze
Drop one enum type, two static functions, 70 lines of code. Also fixes the mpeg_encode(1) manual reported broken by naddy@.
2015-04-03It turns out the man(7) parser suffers from unintelligible handlingIngo Schwarze
of block rewinding, just like then mdoc(7) parser did. First step in getting rid of rew_scope(): Replace the only call where the target block is known. This commit is analogous to mdoc_macro.c rev. 1.167. One down, three to go.
2015-04-03No need to hardcode /usr/bin/ as the path to more(1); helps portability.Ingo Schwarze
We don't hardcode the paths to gunzip(1) and cmp(1) either. Discussed with ajacoutot@.
2015-04-02Third step towards parser unification:Ingo Schwarze
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.
2015-04-02Second step towards parser unification:Ingo Schwarze
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.