aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_man.c
Commit message (Collapse)AuthorAgeFilesLines
* Use typographic quotes rather than '"' for .Rs %T (no change for -TasciiIngo Schwarze2017-02-171-5/+3
| | | | | output, of course). Patch from bentley@ in November 2014. This can be committed now because groff merged Anthony's patch yesterday.
* Remove the ENDBODY_NOSPACE flag, simplifying the code.Ingo Schwarze2017-02-161-4/+1
| | | | | | | | 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.
* The .Nm macro does not only use the default name when it has noIngo Schwarze2017-02-061-5/+3
| | | | | | | | | | 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.
* Do text production for .Bt, .Ex, .Rv, .Ud at the validation stageIngo Schwarze2017-01-111-101/+11
| | | | | | | | | 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@.
* Use new NODE_NOSRC and NODE_NOPRT flags for .Bx and .At.Ingo Schwarze2017-01-101-23/+2
| | | | More rigorous AST and 40 lines less code.
* For the .Ux/.Ox family of macros, do text production at the validationIngo Schwarze2017-01-101-7/+7
| | | | | stage rather than in each and every individual formatter, using the new NODE_NOSRC flag. More rigorous and also ten lines less code.
* unify names of AST node flags; no change of cpp outputIngo Schwarze2017-01-101-18/+18
|
* Introduce flags NODE_NOSRC and NODE_NOPRT for AST nodes.Ingo Schwarze2017-01-101-2/+5
| | | | | | | | | 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.
* Delete the redundant "nchild" member of struct roff_node, replacingIngo Schwarze2016-01-081-26/+25
| | | | | | | | 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.
* To make the code more readable, delete 283 /* FALLTHROUGH */ commentsIngo Schwarze2015-10-121-15/+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-72/+72
|
* Delete the wrapper functions mdoc_meta(), man_meta(), mdoc_node(),Ingo Schwarze2015-04-181-12/+6
| | | | | | 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.
* Replace the structs mdoc and man by a unified struct roff_man.Ingo Schwarze2015-04-181-3/+3
| | | | | 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-3/+3
| | | | | 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-11/+11
| | | | | | | | | 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-34/+35
| | | | | | 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.
* Render \(lq and \(rq as '"' in -Tascii mode but leave the renderingIngo Schwarze2015-02-171-3/+3
| | | | | | of .Do/.Dc, .Dq, .Lb, and .St untouched. Reduces groff-mandoc differences in OpenBSD base by about 7%. Reminded of the issue by naddy@.
* Delete the mdoc_node.pending pointer and the function calculatingIngo Schwarze2015-02-121-8/+11
| | | | | | | | | | | | | | | | | | | | | | | 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-111-4/+3
| | | | found by jsg@ with afl, test case #16
* better handle .Fo and .Fd without argumentIngo Schwarze2015-02-061-3/+6
| | | | better handle .Fo with more than one argument
* fix .Eo/.Ec spacingIngo Schwarze2015-02-011-3/+25
|
* * Polish tbl(7) error reporting.Ingo Schwarze2015-01-281-6/+9
| | | | | | * 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.
* Let .Aq/.Ao/.Ac print "<>" instead of the normal "\(la\(ra"Ingo Schwarze2015-01-231-6/+6
| | | | | | 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).
* Support negative indentations for mdoc(7) displays and lists.Ingo Schwarze2014-12-241-29/+28
| | | | | | 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.
* support negative horizontal widths in man(7);Ingo Schwarze2014-12-231-1/+5
| | | | minus twenty lines of code in spite of enhanced functionality
* fix typo in previousIngo Schwarze2014-12-231-3/+3
|
* some scaling unit fixes:Ingo Schwarze2014-12-231-3/+3
| | | | | - .sp with an invalid argument is .sp 1v, not .sp 0v - in man(1), trailing garbage doesn't make scaling units invalid
* Multiple fixes with respect to .Pf:Ingo Schwarze2014-11-301-2/+3
| | | | | | | * 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.
* Multiple fixes with respect to .Eo:Ingo Schwarze2014-11-271-5/+14
| | | | | | | | 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.
* Fix the obsolete .Db (toggle debug mode) macro to ignore its argumentsIngo Schwarze2014-11-271-11/+11
| | | | | and not trigger an assertion when there is more than one argument; the latter found by jsg@ with afl.
* Let .Ao and .Aq render as "<>" after .An and as "\(la\(ra" elsewhere,Ingo Schwarze2014-11-191-3/+24
| | | | just like groff; minibug noticed by bentley@.
* Multiple fixes with respect to in-line macros:Ingo Schwarze2014-11-171-1/+5
| | | | | | | | | | * .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@.
* Let -Tascii \(bu (bullet) output agree with groff;Ingo Schwarze2014-11-061-2/+2
| | | | this is now possible because -Tps now handles backspace overstriking.
* Major bugsquashing with respect to -offset and -width:Ingo Schwarze2014-10-301-9/+9
| | | | | | | | | 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@.
* Right after .Fl, a middle delimiter triggers an empty scope,Ingo Schwarze2014-08-211-4/+7
| | | | | | | | | | | | 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@.
* Get rid of HAVE_CONFIG_H, it is always defined; idea from libnbcompat.Ingo Schwarze2014-08-101-3/+3
| | | | | | 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-3/+4
| | | | | | | | | | | | 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.
* Various improvements related to .Ex and .Rv:Ingo Schwarze2014-07-301-10/+95
| | | | | | | | | | * 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
* Clean up messages regarding excess arguments:Ingo Schwarze2014-07-041-5/+7
| | | | | | * Downgrade ".Bf -emphasis Em" from FATAL to WARNING. * Mention the macros, the arguments, and the fallbacks. * Hierarchical naming.
* When .Sm is called without an argument, groff toggles the spacing mode,Ingo Schwarze2014-07-021-4/+9
| | | | | so let us do the same for compatibility. Using this feature is of course not recommended except in manual page obfuscation contests.
* Implement the obsolete macros .En .Es .Fr .Ot for backward compatibility,Ingo Schwarze2014-07-021-5/+42
| | | | | since this is hardly more complicated than explicitly ignoring them as we did in the past. Of course, do not use them!
* make sure static buffers for snprintf(3) are large enoughIngo Schwarze2014-04-201-6/+7
| | | | and cast snprintf return value to (void) where they are
* KNF: case (FOO): -> case FOO:, remove /* LINTED */ and /* ARGSUSED */,Ingo Schwarze2014-04-201-70/+71
| | | | | remove trailing whitespace and blanks before tabs, improve some indenting; no functional change
* Improve formatting of broken blocks in -Tman,Ingo Schwarze2014-03-301-3/+12
| | | | | somewhat similar to what mdoc_term.c already does for -Tascii. OpenBSD rev. 1.58.
* Implement the roff(7) .ll (line length) request.Ingo Schwarze2014-03-301-1/+11
| | | | | Found by naddy@ in the textproc/enchant(1) port. Of course, do not use this in new manuals.
* The files mandoc.c and mandoc.h contained both specialised low-levelIngo Schwarze2014-03-231-3/+4
| | | | | | | 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.
* Implement the \: (optional line break) escape sequence,Ingo Schwarze2014-01-221-2/+5
| | | | | | | documented in the Ossanna-Kernighan-Ritter troff manual and also supported by groff. Missing feature reported by Steffen Nurpmeso <sdaoden at gmail dot com>.
* Implement .Fo/.Fa/.Fc indentation and break handling for -Tman.Ingo Schwarze2013-12-251-4/+9
|
* Do not break output lines in .Fn function arguments in SYNOPSIS mode.Ingo Schwarze2013-12-251-1/+11
| | | | | Following an idea from Franco Fichtner, but implemented more cleanly. This reduces groff-mandoc-differences in OpenBSD base by a fantastic 7.5%.
* Implement SYNOPSIS .Fn indentation for -Tman.Ingo Schwarze2013-12-241-2/+5
|