summaryrefslogtreecommitdiffstats
path: root/man_term.c
Commit message (Collapse)AuthorAgeFilesLines
...
* correctly handle scaling units after .PDIngo Schwarze2014-12-231-2/+4
|
* fix handling of roff requests having a default scale other than "n",Ingo Schwarze2014-12-041-1/+1
| | | | | 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-12/+23
| | | | | | 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-3/+4
| | | | | 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-18/+10
| | | | | | | | | | | | | | | | | | | | | 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-3/+0
| | | | | | | | 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-1/+1
| | | | | 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-0/+2
|
* correct spacing before inline equationsIngo Schwarze2014-10-201-0/+2
|
* Implement the traditional -h option for man(1): show the SYNOPSIS only.Ingo Schwarze2014-09-031-13/+25
| | | | | | | 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-2/+0
| | | | | | 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-3/+6
| | | | | | | | | | | | | | 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-13/+9
| | | | | | | | | | | | | * 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-10/+15
| | | | | 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-116/+72
| | | | | 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-3/+3
| | | | | | | | | | 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-1/+1
|
* Implement the roff(7) .ll (line length) request.Ingo Schwarze2014-03-301-0/+12
| | | | | 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-1/+1
| | | | | | 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-4/+9
| | | | | | | | 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-5/+8
| | | | 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-4/+12
| | | | | | | | | | | 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-0/+2
| | | | | | | | 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-0/+30
| | | | | | | | 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-3/+3
| | | | | | | | | | 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-20/+20
| | | | | | | | 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-12/+34
| | | | | | Reminded about the missing feature by millert@. This reduces mandoc/groff differences in OpenBSD base by 25%. ok millert@
* Always fix the man(7) subsection header (.SS) indent to 3n,Ingo Schwarze2012-07-161-1/+1
| | | | | | | 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. OpenBSD rev. 1.87
* Translate blank input lines to .sp just like in mdoc(7),Ingo Schwarze2012-07-141-3/+14
| | | | | | and ignore .sp after .PP. This fixes vertical spacing for blank lines after .PP and for .sp after .PP. OpenBSD rev. man.c 1.68 and man_term.c 1.86
* In -man -Tascii, support .sp with negative argument.Ingo Schwarze2012-07-131-3/+18
| | | | | | In -mdoc -Tman, improve the framework to control vertical spacing. Use both to support .Bl -compact (surprisingly hard to get right). OpenBSD rev. 1.85 and 1.34, respectively.
* multiple fixes to -Tascii .HP rendering:Ingo Schwarze2012-07-101-31/+34
| | | | | | | | | | | | | | | | | | * 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 OpenBSD rev. 1.84 and 1.29, respectively
* Minimal implementation of .EX and .EE for GNU compatibility.Ingo Schwarze2012-06-021-1/+3
| | | | | Do not use this, it is not portable and only defined in esr's man-ext. For example, sox(1) wants these macros.
* update Copyright years according to the CVS logs; no code changeIngo Schwarze2012-05-271-1/+1
|
* Add support for `OP', one of the extended man macros. This also requiresKristaps Dzonsons2012-01-031-2/+27
| | | | some man(7) changes to accomodate for the an-ext compatibility.
* Implement mdoc(7)-like output style variant for man(7) documents:Ingo Schwarze2011-12-041-18/+37
| | | | | | | | | | | * 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. In the long run, we hope to unify the ouput of both languages and to pull this out again, but that requires coordination with groff. Grudgingly ok and, (as usual,-) more comments requested by kristaps@
* Jumping out of man_unscope() for the root node is a bad ideaIngo Schwarze2011-12-041-6/+9
| | | | | | | | because that will skip root node validation, potentially entering rendering modules will NULL pointers lurking in the meta data. Instead, always validate the root node and (as suggested by joerg@) assert validity of the meta data before using it in the renderers. ok joerg@
* Don't crash if the date can't be extracted. Don't depend on snprintfJoerg Sonnenberger2011-11-181-4/+6
| | | | handling NULL strings.
* Make the man(7) page footer the same as in groff.Ingo Schwarze2011-11-131-9/+16
|
* Make the default left text margin configurable from the command line,Ingo Schwarze2011-11-131-12/+13
| | | | | | | 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,Ingo Schwarze2011-09-211-4/+2
| | | | | | | 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 possibleIngo Schwarze2011-09-201-1/+1
| | | | | | | 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 marginIngo Schwarze2011-09-201-1/+2
| | | | | | 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;Ingo Schwarze2011-09-201-4/+4
| | | | | | 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.Ingo Schwarze2011-09-191-12/+22
| | | | | | | | | | | | | | | | | 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. ok kristaps@
* Support nesting of indented blocks.Ingo Schwarze2011-09-181-34/+28
| | | | | | | | This patch was originally written in July 2011 by kristaps@, i promptly committed it to OpenBSD, and then it was forgotten. Now i rediscovered it when merging 1.11.7 to OpenBSD. ok kristaps@ (on his own patch :)
* Add character output (-Tpdf, -Tps, -Tascii) for equations. This is theKristaps Dzonsons2011-07-221-1/+1
| | | | minimum: unseparated terms.
* Flip eqn into using parsed nodes. I've temporarily disabled printingKristaps Dzonsons2011-07-211-1/+1
| | | | | | | these in the front-ends except for -Ttree, which will display the parsed tree. While here, fix that quoted strings aren't scanned for replacement parts.
* Fix a TODO noted by schwarze@, originally by Christian Weisgerber:Kristaps Dzonsons2011-07-031-0/+2
| | | | | literal mode (`nf') is ended by SH (and, it turns out, SS as well). Noted the updated behaviour in man.7 as well.
* First fix how `sp 1' doesn't imply `1v' (it now does) and that 1Kristaps Dzonsons2011-06-291-1/+8
| | | | | | followed by non-digits, e.g. `1g', really means `1'. Next, fix some spacing issues where `sp' was invoked in -man after sections or subsections. Make sure this behaviour is mirrored in -Thtml.
* Fix two TODOs with one check-in. Both of these relate to vertical spaceKristaps Dzonsons2011-06-181-11/+15
| | | | before paragraphs and/or within `RS' blocks.