summaryrefslogtreecommitdiffstats
path: root/mdoc_man.c
Commit message (Collapse)AuthorAgeFilesLines
* Render \(lq and \(rq as '"' in -Tascii mode but leave the renderingIngo Schwarze2015-02-171-2/+2
| | | | | | 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-7/+10
| | | | | | | | | | | | | | | | | | | | | | | 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-3/+2
| | | | found by jsg@ with afl, test case #16
* better handle .Fo and .Fd without argumentIngo Schwarze2015-02-061-2/+5
| | | | better handle .Fo with more than one argument
* fix .Eo/.Ec spacingIngo Schwarze2015-02-011-2/+24
|
* * Polish tbl(7) error reporting.Ingo Schwarze2015-01-281-5/+8
| | | | | | * 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-5/+5
| | | | | | 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-28/+27
| | | | | | 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-0/+4
| | | | minus twenty lines of code in spite of enhanced functionality
* fix typo in previousIngo Schwarze2014-12-231-2/+2
|
* some scaling unit fixes:Ingo Schwarze2014-12-231-2/+2
| | | | | - .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-1/+2
| | | | | | | * 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-4/+13
| | | | | | | | 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-10/+10
| | | | | 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-2/+23
| | | | just like groff; minibug noticed by bentley@.
* Multiple fixes with respect to in-line macros:Ingo Schwarze2014-11-171-0/+4
| | | | | | | | | | * .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-1/+1
| | | | this is now possible because -Tps now handles backspace overstriking.
* Major bugsquashing with respect to -offset and -width:Ingo Schwarze2014-10-301-8/+8
| | | | | | | | | 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-3/+6
| | | | | | | | | | | | 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-2/+2
| | | | | | 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-2/+3
| | | | | | | | | | | | 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-9/+94
| | | | | | | | | | * 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-4/+6
| | | | | | * 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-3/+8
| | | | | 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-4/+41
| | | | | 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-5/+6
| | | | and cast snprintf return value to (void) where they are
* KNF: case (FOO): -> case FOO:, remove /* LINTED */ and /* ARGSUSED */,Ingo Schwarze2014-04-201-69/+70
| | | | | remove trailing whitespace and blanks before tabs, improve some indenting; no functional change
* Improve formatting of broken blocks in -Tman,Ingo Schwarze2014-03-301-2/+11
| | | | | 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-0/+10
| | | | | 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-2/+3
| | | | | | | 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-1/+4
| | | | | | | 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-3/+8
|
* Do not break output lines in .Fn function arguments in SYNOPSIS mode.Ingo Schwarze2013-12-251-0/+10
| | | | | 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-1/+4
|
* It turns out SYNOPSIS mode does not imply .Bk in general,Ingo Schwarze2013-12-241-18/+17
| | | | | | but only within .Nm blocks. Simplify the code accordingly. Triggered by research done by Franco Fichtner.
* Printf size_t vars with %zu, not %ld;Ingo Schwarze2013-10-071-4/+4
| | | | | from Antonio Huete Jimenez <tuxillo at quantumachine dot net> via Franco Fichtner (both DragonFly).
* Use normal line macro recognition, do not attempt to roll your own.Ingo Schwarze2013-09-151-3/+2
| | | | | This fixes horizontal spacing when an Ns macro follows a block-closing macro and the corresponding block-opening macro is not on the same line.
* Let .Do .Dq .Ql .So .Sq generate the correct roff(7) character escapeIngo Schwarze2013-06-021-5/+5
| | | | | | | sequences such that output modes like -Tutf8 have a chance to select nice glyphs. This doesn't change anything for -Tascii, and, for now, it doesn't affect -Tps and -Tpdf either. OK matthew@ bentley@; like the idea tedu@; no opinion jmc@.
* In SYNOPSIS mode, .Ek doesn't end a keep.Ingo Schwarze2013-05-291-1/+1
| | | | Found and fixed on the plane to the OpenBSD t2k13 hackathon in Toronto.
* Support .Bl -offset in -mdoc -Tman.Ingo Schwarze2013-05-191-3/+21
| | | | | Issue found when Thomas Klausner <wiz at NetBSD dot org> made me look at the manuals of his http://www.nih.at/libzip library.
* Move printing of the .RS macro into print_offs() such that print_offs()Ingo Schwarze2013-05-191-4/+4
| | | | | | | takes care of printing the whole line. This reduces code duplication - in particular after the upcoming commit to repair .Bl -offset - and makes print_offs() more similar to what print_width() does. No functional change.
* Rewrite indentation handling for nested lists in a more systematic wayIngo Schwarze2012-12-311-34/+48
| | | | | | | | | | | | to fix multiple issues reported by Todd Miller; thanks! Specifically, - avoid double indentation after .Bd inside .Bl - set up correct indentation after .Bl inside .Bl - set up correct indentation after .Dl and .D1 inside .Bl While here, also - set up correct indentation *inside* .Dl and .D1 inside .Bl.
* In -Tman mode, support automatic word keeps in the SYNOPSISIngo Schwarze2012-11-191-21/+33
| | | | | | | | | just like in -Tascii mode; requested by millert@. While here, do not escape the blank characters terminating man(7) macros; this is becoming more important as we use more keeps now. Note that -Tman still does not support .nr nS.
* Three portability improvements by millert@:Ingo Schwarze2012-11-191-8/+9
| | | | | | | | | | | * Use "\\ " not "\\~" as the non-breaking space as historic nroff doesn't support the latter. * The '-' before the flags needs to be quoted to prevent nroff from putting a line break between the '-' and the flag character. * Disable hyphenation and, for nroff, disable justification which is consistent with how mdoc behaves (and produces more readable manuals). (OpenBSD rev. 1.39, 1.40 and 1.41)
* Make the generated man(7) code more portable by using .PDIngo Schwarze2012-11-181-5/+19
| | | | | | | instead of .sp -1v, which for example Solaris nroff handles poorly. Problem report and patch by millert@, with the print_word chunk tweaked by me.
* Correct indentation for lists and displays inside lists.Ingo Schwarze2012-11-181-6/+103
| | | | | | | Inspired by a diff from millert@, but implemented rather differently and with slightly better functionality. In particular, this one respects -offset and -width arguments found in the input file.
* Cleanup naming of local variables to make the code easier on the eye:Ingo Schwarze2012-11-171-18/+19
| | | | | | | | Settle for "struct man *man", "struct mdoc *mdoc", "struct meta *meta" and avoid the confusing "*m" which was sometimes this, sometimes that. No functional change. ok kristaps@ some time ago
* For .El .sp, avoid the weird .sp -1v .PP .PP output sequence.Ingo Schwarze2012-07-161-2/+3
| | | | Synching to OpenBSD rev. 1.38.
* Several -mdoc parser improvements related to vertical spacing:Ingo Schwarze2012-07-161-1/+4
| | | | | | | | | | * So far, .Pp and .Lp were removed before paragraph type blocks. * Now also remove .br before paragraph type blocks. * Treat .Lp as a paragraph like .Pp, so remove .Pp, .Lp, .br before it. * Do not treat .sp as a paragraph, don't remove anything before it. * After .Sh, .Ss, .Pp, and .Lp, remove .Pp, .Lp, .sp, .br, and blank lines. * After .sp and .br, remove .br. OpenBSD rev. mdoc.c 1.89 and mdoc_validate.c 1.106
* In -Tman .Bl -compact, skip the blank line only before the first itemIngo Schwarze2012-07-141-1/+2
| | | | | of the first list in a section, not before every item of the first list. OpenBSD rev. 1.37