aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/man_term.c
Commit message (Collapse)AuthorAgeFilesLines
* If an explicit line break request (.br or .sp) occurs within an .HP block,Ingo Schwarze2015-04-191-1/+12
| | | | | | | 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).
* Decouple the token code for "no request or macro" from the individualIngo Schwarze2015-04-191-2/+2
| | | | | | 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.
* Delete the wrapper functions mdoc_meta(), man_meta(), mdoc_node(),Ingo Schwarze2015-04-181-10/+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-2/+2
| | | | | Almost completely mechanical, no functional change. Written on the train from Exeter to London returning from p2k15.
* Do not mistreat empty arguments to font alternating macrosIngo Schwarze2015-04-061-2/+5
| | | | as vertical spacing requests. Bug found with xmahjongg(6).
* On a new RS nesting level, the saved width starts from the defaultIngo Schwarze2015-04-061-2/+2
| | | | | width, not from the saved width of the previous level. Improves xterm(1) and XSetEventQueueOwner(3); found in transcode_filter(1).
* Use the default width for .RS without arguments.Ingo Schwarze2015-04-061-2/+4
| | | | | Reduces groff-mandoc differences in base and Xenocara by about 4%. Found while looking at wpa_supplicant(8).
* Give man(7) section and subsection headers hanging indentation.Ingo Schwarze2015-04-041-1/+13
| | | | | | Reduces groff-mandoc differences in base by about 2.5% due to various Perl manuals having long section titles. Quirk found in argtable2(3).
* Rounding rules for horizontal scaling widths are more complicated.Ingo Schwarze2015-04-041-6/+6
| | | | | | | | | | | | | 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).
* Fix a quirk with respect to empty .HP.Ingo Schwarze2015-04-041-1/+12
| | | | | Found while writing a regression test for man_macro.c rev. 1.66. Incidentally, this brings rendering of XFreeEventData(3) closer to groff.
* Third step towards parser unification:Ingo Schwarze2015-04-021-18/+16
| | | | | 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-9/+9
| | | | | | | | | 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-47/+48
| | | | | | 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.
* Avoid off-by-one read access to the termacts array, which couldIngo Schwarze2015-03-151-2/+3
| | | | | sometimes result in missing line breaks before subsection headers. Found by carsten dot kunze at arcor dot de on SuSE 13.2.
* Fix vertical spacing at the beginning of tables.Ingo Schwarze2015-03-061-7/+3
| | | | | | man(7) always prints a blank line, mdoc(7) doesn't. Problem in mdoc(7) reported by kristaps@. mdoc(7) part of the patch tested by kristaps@.
* Have pity on the poor stack.Ingo Schwarze2015-01-301-6/+6
| | | | | Replace tail recursion by iteration when walking the syntax trees. No functional change.
* Delete the redundant tbl span flags, just inspect the actual dataIngo Schwarze2015-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)Ingo 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 indentedIngo Schwarze2014-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 forIngo Schwarze2014-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);Ingo Schwarze2014-12-231-106/+72
| | | | minus twenty lines of code in spite of enhanced functionality
* some scaling unit fixes:Ingo 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 itIngo Schwarze2014-12-231-4/+3
|
* correctly handle scaling units after .PDIngo Schwarze2014-12-231-3/+5
|
* fix handling of roff requests having a default scale other than "n",Ingo 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 whetherIngo Schwarze2014-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).Ingo 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 terminalIngo Schwarze2014-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 theIngo Schwarze2014-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 equationsIngo Schwarze2014-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)Ingo Schwarze2014-10-201-1/+3
|
* correct spacing before inline equationsIngo Schwarze2014-10-201-1/+3
|
* Implement the traditional -h option for man(1): show the SYNOPSIS only.Ingo 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.
* Get rid of HAVE_CONFIG_H, it is always defined; idea from libnbcompat.Ingo Schwarze2014-08-101-3/+1
| | | | | | 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.
* As suggested by jmc@, only include line and column numbers into messagesIngo Schwarze2014-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.Ingo 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:Ingo 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 */,Ingo 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)Ingo 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).Ingo Schwarze2014-03-301-2/+2
|
* Implement the roff(7) .ll (line length) request.Ingo 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 breaksIngo Schwarze2014-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,Ingo 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;Ingo 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().Ingo 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,Ingo 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 theIngo Schwarze2013-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 togetherIngo Schwarze2013-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:Ingo 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.Ingo Schwarze2012-07-291-13/+35
| | | | | | Reminded about the missing feature by millert@. This reduces mandoc/groff differences in OpenBSD base by 25%. ok millert@