summaryrefslogtreecommitdiffstats
path: root/usr.bin/mandoc/man_term.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Delete the redundant tbl span flags, just inspect the actual dataschwarze2015-01-301-2/+2
| | | | | | | | 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.
* Strangely, ignoring the roff(7) .na request was implemented in the man(7)schwarze2015-01-241-2/+1
| | | | | parser. Simplify the code by moving it into the roff(7) parser, also making it work for mdoc(7).
* For .RS, we need to save the information how much we actually indentedschwarze2014-12-241-28/+14
| | | | | | | because negative indents can get truncated, in which case we no longer know how to restore the original indent at the end of the block. This also solves another case of effectively infinite output found by jsg@ with afl, triggered by very large negative indents.
* When a man(7) document contains unreasonably large numbers forschwarze2014-12-241-10/+19
| | | | | | | | | | | indentations or paragraph distances, large output may be generated, which is practically the same as an endless loop; found by jsg@ with afl. Reject such unreasonably large numbers beyond arbitrary limits similar to those used by groff (max. 65 blank lines between paragraphs and max. SHRT_MAX characters per output line) and fall back to defaults when exceeded. Having the limits behave in exactly the same way is not relevant.
* support negative horizontal widths in man(7);schwarze2014-12-231-106/+72
| | | | minus twenty lines of code in spite of enhanced functionality
* some scaling unit fixes:schwarze2014-12-231-15/+5
| | | | | - .sp with an invalid argument is .sp 1v, not .sp 0v - in man(1), trailing garbage doesn't make scaling units invalid
* even if the second argument to .IP is invalid, don't print itschwarze2014-12-231-4/+3
|
* correctly handle scaling units after .PDschwarze2014-12-231-3/+5
|
* fix handling of roff requests having a default scale other than "n",schwarze2014-12-041-2/+2
| | | | | in particular .sp which uses "v", when the scale is not specified; cures groff-mandoc differences in about a dozen Xenocara manuals
* Ignore macros that never produce any text when deciding whetherschwarze2014-12-041-13/+24
| | | | | | vertical whitespace is needed before a section or subsection. Cures groff-mandoc differences in more than 300 manuals, mostly Xenocara, some curses, a few GNU.
* Fix the implementation and documentation of \c (continue text input line).schwarze2014-12-021-4/+5
| | | | | In particular, make it work in no-fill mode, too. Reminded by Carsten dot Kunze at arcor dot de (Heirloom roff).
* We repeatedly observed assertion crashes in the low-level terminalschwarze2014-11-211-19/+11
| | | | | | | | | | | | | | | | | | | | | output handler because the high level terminal formatters could be tricked into setting the left margin further to the right than the right margin. Today, jsg@ found more of these with afl. Change the internal interface between both levels, aiming for simplicity and robustness of the code. Treat both margins as *independent* settings: Now, termp.offset is the requested left margin, and termp.rmargin is the available space. Let the lower level cope with that case of insufficient space. Obviously, high level code that does centering or flush right still has to do careful checks, so i did a full audit of margin settings in the terminal formatters. Fixes crashes caused by excessively long title or date strings in the man(7) footer, operating system or date strings in the mdoc(7) footer, volume strings in the man(7) or mdoc(7) header, and a few cases related to some non-prologue macros.
* Make the character table available to libroff so it can check theschwarze2014-10-281-4/+1
| | | | | | | | validity of character escape names and warn about unknown ones. This requires mchars_spec2cp() to report unknown names again. Fortunately, that doesn't require changing the calling code because according to groff, invalid character escapes should not produce output anyway, and now that we warn about them, that's fine.
* correct the spacing after in-line equationsschwarze2014-10-201-2/+2
| | | | | that start at the beginning of an input line but end before the end of an input line
* correct spacing *after* inline equations (much simpler than expected)schwarze2014-10-201-1/+3
|
* correct spacing before inline equationsschwarze2014-10-201-1/+3
|
* Implement the traditional -h option for man(1): show the SYNOPSIS only.schwarze2014-09-031-14/+26
| | | | | | | As usual, we get mandoc -h and apropos -h for free. Try stuff like "apropos -h In=dirent" or "apropos -h Fa=timespec". Only useful for terminal output, so -Tps, -Tpdf, -Thtml ignore -h for now.
* As suggested by jmc@, only include line and column numbers into messagesschwarze2014-06-201-4/+7
| | | | | | | | | | | | | | when they are meaningful, to avoid confusing stuff like this: $ mandoc /dev/null mandoc: /dev/null:0:1: FATAL: not a manual Instead, just say: mandoc: /dev/null: FATAL: not a manual Another example this applies to is documents having a prologue, but lacking a body. Do not throw a FATAL error for these; instead, issue a warning and show the empty document, in the man(7) case with the same amount of blank lines as groff does. Also downgrade mdoc(7) documents having content before the first .Sh from FATAL to WARNING.
* Audit strlcpy(3)/strlcat(3) usage.schwarze2014-04-231-14/+10
| | | | | | | | | | | | | * Repair three instances of silent truncation, use asprintf(3). * Change two instances of strlen(3)+malloc(3)+strlcpy(3)+strlcat(3)+... to use asprintf(3) instead to make them less error prone. * Cast the return value of four instances where the destination buffer is known to be large enough to (void). * Completely remove three useless instances of strlcpy(3)/strlcat(3). * Mark two places in -Thtml with XXX that can cause information loss and crashes but are not easy to fix, requiring design changes of some internal interfaces. * The file mandocdb.c remains to be audited.
* fix unchecked snprintf(3) in page header printing:schwarze2014-04-201-11/+16
| | | | | the length of the title is unknown, and speed doesn't matter here, so use asprintf/free rather than a static buffer
* KNF: case (FOO): -> case FOO, remove /* LINTED */ and /* ARGSUSED */,schwarze2014-04-201-117/+73
| | | | | remove trailing whitespace and blanks before tabs, improve some indenting; no functional change
* Add a new term_flushln() flag TERMP_BRIND (if break, then indent)schwarze2014-04-081-4/+4
| | | | | | | | | | to control indentation of continuation lines in TERMP_NOBREAK mode. In the past, this was always on; continue using it for .Bl, .Nm, .Fn, .Fo, and .HP, but no longer for .IP and .TP. I looked at this because sthen@ reported the issue in a manual of a Perl module from ports, but it affects base, too: This patch reduces groff-mandoc differences in base by more than 15%.
* Support relative arguments to .ll (increase or decrease line length).schwarze2014-03-301-2/+2
|
* Implement the roff(7) .ll (line length) request.schwarze2014-03-301-1/+13
| | | | | Found by naddy@ in the textproc/enchant(1) port. Of course, do not use this in new manuals.
* In .nf mode, use the MAN_LINE flag to detect input line breaksschwarze2014-03-081-2/+2
| | | | | | instead of the man_node line member. This is required to preserve line breaks contained in user-defined macros called in .nf mode. Found in a code audit triggered by fixing a similar issue in .TP.
* To find out whether .TP head arguments are same-line or next-line arguments,schwarze2014-03-081-5/+10
| | | | | | | | use the MAN_LINE flag instead of the man_node line member. This is required such that user-defined macros wrapping .TP work correctly. Issue found by Havard Eidnes in Tcl_NewStringObj(3), reported via the NetBSD bug tracking system and Thomas Klausner <wiz at NetBSD>.
* when indenting, extend the right margin accordingly, when needed;schwarze2014-02-161-6/+9
| | | | fixes a crash reported by blambert@ and a few other, similar ones
* Polishing the worms in my favourite can, term_flushln().schwarze2013-12-221-5/+13
| | | | | | | | | | | The TERMP_TWOSPACE flag i introduced in August 2009 was idiosyncratic and served only a very narrow purpose. Replace it by a more intuitive and more general termp attribute "trailspace", to be used together with TERMP_NOBREAK, to request a minimum amount of whitespace at the end of the current column. Adapt all code to the new interface. No functional change intended; code reviews to confirm that are welcome *eg*.
* In the parser, when closing an explicit block that is not open,schwarze2013-11-111-1/+3
| | | | | | | | close below-subsection implicit scopes that may still be open. In the formatter, make sure indentation is reset when leaving a scope, not only when entering the next one. Improves the formatting of gpg(1); issue reported by jca on ports.
* Implement the .UR/.UE block (uniform resource identifier) introduced in theschwarze2013-10-171-1/+31
| | | | | | | | man-ext macros by Eric S. Raymond, enabled by default in groff_man(7). Usual disclaimer: You don't write new man(7) code, so you are not going to use these, either. Improves e.g. the bzr(1) and etherape(1) manuals. Thanks to naddy@ for bringing these to my attention.
* In literal mode (.nf), each input line must be kept togetherschwarze2013-01-051-4/+4
| | | | | | | | | | on the same output line, even if it is longer than the output width. This commit fixes a bug allowing an overly long last line of an indented block (.RS) to be broken even in literal mode. The bug was found using the sudo_plugin(4) manual provided by millert@. I introduced the bug in rev. 1.84 during the g2k12 Budapest hackathon.
* Cleanup naming of local variables to make the code easier on the eye:schwarze2012-11-171-21/+21
| | | | | | | | 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
* Implement .PD for -Tascii.schwarze2012-07-291-13/+35
| | | | | | Reminded about the missing feature by millert@. This reduces mandoc/groff differences in base by 25%. ok millert@
* Always fix the man(7) subsection header (.SS) indent to 3n,schwarze2012-07-161-2/+2
| | | | | | do not let it depend on the default indent provided by -Oindent. By default, this doesn't change anything because 7 / 2 = 3; in -Omdoc mode, it makes man(7) output the same as mdoc(7) output.
* Translate blank input lines to .sp just like in mdoc(7),schwarze2012-07-141-4/+15
| | | | | and ignore .sp after .PP. This fixes vertical spacing for blank lines after .PP and for .sp after .PP.
* In -man -Tascii, support .sp with negative argument.schwarze2012-07-131-4/+19
| | | | | In -mdoc -Tman, improve the framework to control vertical spacing. Use both to support .Bl -compact (surprisingly hard to get right).
* multiple fixes to -Tascii .HP rendering:schwarze2012-07-101-33/+36
| | | | | | | | | | | | | | | | * do not add an excessive blank line before the block * in literal mode, start a new line after the tag getting this to work requires some general (print_man_node) fixes: * in literal mode, break the output line at the end of each input line, not just after those input lines ending in text * but don't break it when there was no output on the line * and adjust the margins after the .HP tag these general fixes require an adjustment to -Tascii .TP rendering: * set up NOBREAK mode before the body, not after the head finally, based on all this, implement -Tman .Bl -hang in terms of .HP
* Minimal implementation of .EX and .EE for GNU compatibility.schwarze2012-06-021-2/+4
| | | | | Do not use this, it is not portable and only defined in esr's man-ext. For example, sox(1) wants these macros.
* Support .OP, one of the extended man macros; from kristaps@.schwarze2012-02-261-3/+28
| | | | Do not use this GNU extension, we take it for compatibility only.
* As requested by kristaps@, add and improve comments related to -Omdoc;schwarze2011-12-051-14/+25
| | | | while here, clean up some redundant initializations in print_man_head().
* When a man document contains nothing at all except one or more invalidschwarze2011-12-041-1/+6
| | | | | | macros, do not die on an assertion, but show correct error messages. Assertions of meta data validity suggested by joerg@. ok joerg@
* Implement mdoc(7)-like output style variant for man(7) documents:schwarze2011-11-131-6/+14
| | | | | | | * one instead of three blank lines after the page header; * one instead of three blank lines before the page footer; * source instead of title(section) in the lower right corner. Select this style variant with the undocumented command line option -Omdoc.
* Make the man(7) page footer the same as in groff.schwarze2011-11-131-10/+17
|
* Make the default left text margin configurable from the command line,schwarze2011-11-131-13/+14
| | | | | | | just like the default right margin already is. This may be useful for people with expensive screen real estate. Besides, it helps automated man(7) to mdoc(7) output comparisons to validate -Tman output. ok kristaps@ on an earlier version
* As noticed by kristaps@, when breaking an overflowing line,schwarze2011-09-211-5/+3
| | | | | | | forget about pending whitespace (vbl), or the next line would be misaligned and potentially too long; but i'm fixing this in a simpler way than he proposed. Also remove the kludges in .HP that compensated for this bug.
* Using user-defined macros, surprisingly, it is possibleschwarze2011-09-201-2/+2
| | | | | | | to have *next*-line head arguments on the *same* input line. So .TP must not assume that a head argument with a matching input line number is a same-line argument (and access a NULL pointer). Bug found and fix tested by kristaps@ with groff_hdtbl(7).
* When advancing the left margin, .RS also needs to reset the right marginschwarze2011-09-201-2/+3
| | | | | | to the default and check that the left does not outgrow the right one. Otherwise, the (rmargin >= offset) assertion fails in term_flushln(). Bug found and fix tested by kristaps@ with NetBSD slapo-retcode(5).
* Sync print_mdoc_head to print_man_head;schwarze2011-09-201-5/+5
| | | | | | this was forgotten after man_term.c rev. 1.25 on March 2, 2010. The benefit is a sane page header line when .Dt is very long. Reminded by Thomas Klausner <wiz at NetBSD>, thanks.
* Remove the terminal frontend flag TERMP_NOLPAD.schwarze2011-09-191-13/+23
| | | | | | | | | | | | | | | | | | | | In columnated contexts (.Bl -column, .Bl -tag, .IP, .TP, .HP etc.), do not pad after writing a column. Instead, always pad before writing content. In itself, this change avoids: - writing trailing whitespace in some situations - with .fi/.nf in .HP, breaking lines that were already padded It allows several bugfixes included in this patch: - Do not count backspace as a character with positive width. - Set up proper indentation when encountering .fi/.nf in .HP. - Adjust the .HP indentation width to what groff does. - Never unlimit the right margin unless in the final column. This reduces the groff/mandoc-differences in base by nearly 20%, from 89k to 72k lines of diffs. ok kristaps@
* sync to version 1.11.5:schwarze2011-09-181-2/+2
| | | | | | | | adding an implementation of the eqn(7) language by kristaps@ So far, only .EQ/.EN blocks are handled, in-line equations are not, and rendering is not yet very pretty, but the parser is fairly complete.