summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/mdoc_man.c
AgeCommit message (Collapse)Author
2017-04-17implement display of long .Lk URIs to match -TasciiIngo Schwarze
2017-04-17Fix handling of trailing punctuation in .Lk.Ingo Schwarze
This macro is unusual in so far as trailing punction needs to remain inside the scope because it must be inside, not after the display of long URIs in terminal output mode. Improves formatting of fw_update(1), help(1), less(1), sendbug(1), acx(4), inet6(4), ipsec(4), oce(4), isakmpd.conf(5), afterboot(8), release(8), traceroute(8).
2017-04-14Do not make the colon after the .Lk link text italic.Ingo Schwarze
I just pushed the same change to GNU troff.
2017-03-04Remove a redundant condition in .%T handling, no functional change.Ingo Schwarze
Found by jsg@ with scan-build.
2017-02-17Use typographic quotes rather than '"' for .Rs %T (no change for -TasciiIngo Schwarze
output, of course). Patch from bentley@ in November 2014. This can be committed now because groff merged Anthony's patch yesterday. Simply committing myself because asking Anthony to go search for his two-year-old patch and have him discover that it had accumulated an average of (felt) two or three conflicts per line by now would have been mean, even if hilarious.
2017-02-16Remove the ENDBODY_NOSPACE flag, simplifying the code.Ingo Schwarze
Comparing to groff output, it appears that all cases where it was used and made a difference actually require the opposite, ENDBODY_SPACE. I have no idea why i added it back in 2010; maybe to compensate for some other bug that has long been fixed.
2017-02-06The .Nm macro does not only use the default name when it has noIngo Schwarze
argument, but also when the first argument is a child macro. Arcane issue found in the FreeBSD cxgbetool(8) manual that Baptiste Daroussin <bapt at FreeBSD> sent me long ago for a different reason. While solving this, switch to the new technique of doing text production in the validator, reducing code duplication in the formatters, which also makes -Ttree output clearer.
2017-01-11Do text production for .Bt, .Ex, .Rv, .Ud at the validation stageIngo Schwarze
rather than in the formatters. Use NODE_NOSRC flag for .Lb and NODE_NOSRC and NODE_NOPRT for .St. Results in a more rigorous syntax tree and in 135 lines less code. This work was triggered by a question from Abhinav Upadhyay <er dot abhinav dot upadhyay at gmail dot com> (NetBSD) on discuss@.
2017-01-10Use new NODE_NOSRC and NODE_NOPRT flags for .Bx and .At.Ingo Schwarze
More rigorous AST and 40 lines less code.
2017-01-10For the .Ux/.Ox family of macros, do text production at the validationIngo Schwarze
stage rather than in each and every individual formatter, using the new NODE_NOSRC flag. More rigorous and also ten lines less code.
2017-01-10unify names of AST node flags; no change of cpp outputIngo Schwarze
2017-01-10Introduce flags NODE_NOSRC and NODE_NOPRT for AST nodes.Ingo Schwarze
Use them to mark generated nodes and nodes that shall not produce output. Let -Ttree output mode display these new flags. Use NODE_NOSRC for .Ar, .Mt, and .Pa default arguments. Use NODE_NOPRT for .Dd, .Dt, and .Os. These will help to make handling of text production macros more rigorous.
2016-01-08Delete the redundant "nchild" member of struct roff_node, replacingIngo Schwarze
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.
2015-10-12To make the code more readable, delete 283 /* FALLTHROUGH */ commentsIngo Schwarze
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.
2015-10-06modernize style: "return" is not a function; ok cmp(1)Ingo Schwarze
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-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-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.
2015-04-02First step towards parser unification:Ingo Schwarze
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.
2015-02-17Render \(lq and \(rq as '"' in -Tascii mode but leave the renderingIngo Schwarze
of .Do/.Dc, .Dq, .Lb, and .St untouched. Reduces groff-mandoc differences in base by about 7%. Reminded of the issue by naddy@.
2015-02-12Delete the mdoc_node.pending pointer and the function calculatingIngo Schwarze
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.
2015-02-11do not access a NULL pointer if an .Eo block lacks a tail;Ingo Schwarze
found by jsg@ with afl, test case #16
2015-02-06better handle .Fo and .Fd without argumentIngo Schwarze
better handle .Fo with more than one argument
2015-02-01fix .Eo/.Ec spacingIngo Schwarze
2015-01-28* Polish tbl(7) error reporting.Ingo Schwarze
* Do not print out macro names in tbl(7) data blocks. * Like with GNU tbl, let empty tables cause a blank line. * Avoid producing empty tables in -Tman.
2015-01-23Let .Aq/.Ao/.Ac print "<>" instead of the normal "\(la\(ra"Ingo Schwarze
when the only child is .Mt, not when the preceding node is .An, to improve robustness. Triggered by a question from Svyatoslav Mishyn <juef at openmailbox dot org> (Crux Linux).
2014-12-24Support negative indentations for mdoc(7) displays and lists.Ingo Schwarze
Not exactly recommended for use, rather for groff compatibility. While here, introduce similar SHRT_MAX limits as in man(7), fixing a few cases of infinite output found by jsg@ with afl.
2014-12-23support negative horizontal widths in man(7);Ingo Schwarze
minus twenty lines of code in spite of enhanced functionality
2014-12-23fix typo in previousIngo Schwarze
2014-12-23some scaling unit fixes:Ingo Schwarze
- .sp with an invalid argument is .sp 1v, not .sp 0v - in man(1), trailing garbage doesn't make scaling units invalid
2014-11-30Multiple fixes with respect to .Pf:Ingo Schwarze
* 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.
2014-11-27Multiple fixes with respect to .Eo:Ingo Schwarze
1. Correctly parse stray .Ec without preceding .Eo, avoiding an assertion violation found by jsg@ with afl. 2. Correctly parse .Ec arguments when breaking another block. 3. Correct spacing around closing delimiter when breaking another block. 4. Sync some related formatting control from -Tascii to -Thtml.
2014-11-27Fix the obsolete .Db (toggle debug mode) macro to ignore its argumentsIngo Schwarze
and not trigger an assertion when there is more than one argument; the latter found by jsg@ with afl.
2014-11-19Let .Ao and .Aq render as "<>" after .An and as "\(la\(ra" elsewhere,Ingo Schwarze
just like groff; minibug noticed by bentley@.
2014-11-17Multiple fixes with respect to in-line macros:Ingo Schwarze
* .No selects the default font; relevant e.g. in .Bf blocks * no need to force empty .Li elements * closing delimiters as leading macro arguments do not suppress space * opening delimiters at the end of a macro line do not suppress space * correctly handle delimiter spacing in -Tman As a side effect, these fixes let mandoc warn about empty .No macros as requested by bentley@.
2014-11-06Let -Tascii \(bu (bullet) output agree with groff;Ingo Schwarze
this is now possible because -Tps now handles backspace overstriking.
2014-10-30Major bugsquashing with respect to -offset and -width:Ingo Schwarze
1. Support specifying the .Bd and .Bl -offset as a macro default width; while here, simplify the code handling the same for .Bl -width. 2. Correct handling of .Bl -offset arguments: unlike .Bd -offset, the arguments "left", "indent", and "indent-two" have no special meaning. 3. Fix the scaling of string length -offset and -width arguments in -Thtml. Triggered by an incomplete documentation patch from bentley@.
2014-08-21Right after .Fl, a middle delimiter triggers an empty scope,Ingo Schwarze
just like a closing delimiter. This didn't work in groff-1.15, but it now works in groff-1.22. After being closed by delimiters, .Nm scopes do not reopen. Do not suppress white space after .Fl if the next node is a text node on the same input line; that can happen for middle delimiters. Fixing an issue reported by jmc@.
2014-08-08Bring the handling of defective prologues even closer to groff,Ingo Schwarze
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.
2014-08-08Various improvements related to .Ex and .Rv:Ingo Schwarze
* let .Nm fall back to the empty string, not to UNKNOWN * never let .Rv copy an argument from .Nm * avoid spurious \fR after empty .Nm in -Tman * correct handling of .Ex and .Rv in -Tman * correct the wording of the output for .Rv without arguments * use non-breaking spaces in .Ex and .Rv output where required * split MANDOCERR_NONAME into a warning for .Ex and an error for .Nm
2014-07-04Clean up messages regarding excess arguments:Ingo Schwarze
* 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.
2014-07-02When .Sm is called without an argument, groff toggles the spacing mode,Ingo Schwarze
so let us do the same for compatibility. Using this feature is of course not recommended except in manual page obfuscation contests.
2014-07-02Implement the obsolete macros .En .Es .Fr .Ot for backward compatibility,Ingo Schwarze
since this is hardly more complicated than explicitly ignoring them as we did in the past. Of course, do not use them!
2014-04-20make sure static buffers for snprintf(3) are large enoughIngo Schwarze
and cast snprintf return value to (void) where they are
2014-04-20KNF: case (FOO): -> case FOO, remove /* LINTED */ and /* ARGSUSED */,Ingo Schwarze
remove trailing whitespace and blanks before tabs, improve some indenting; no functional change
2014-03-30Implement the roff(7) .ll (line length) request.Ingo Schwarze
Found by naddy@ in the textproc/enchant(1) port. Of course, do not use this in new manuals.
2014-03-21The files mandoc.c and mandoc.h contained both specialised low-levelIngo Schwarze
functions used for multiple languages (mdoc, man, roff), for example mandoc_escape(), mandoc_getarg(), mandoc_eos(), and generic auxiliary functions. Split the auxiliaries out into their own file and header. While here, do some #include cleanup.
2014-01-24Improve formatting of broken blocks in -Tman,Ingo Schwarze
somewhat similar to what mdoc_term.c already does for -Tascii.
2014-01-22Implement the \: (optional line break) escape sequence,Ingo Schwarze
documented in the Ossanna-Kernighan-Ritter troff manual and also supported by groff. Missing feature reported by Steffen Nurpmeso <sdaoden at gmail dot com>.