summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/mdoc_term.c
AgeCommit message (Collapse)Author
2014-04-23Audit strlcpy(3)/strlcat(3) usage.Ingo Schwarze
* 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.
2014-04-20fix unchecked snprintf(3) in page header printing:Ingo Schwarze
the length of the title is unknown, and speed doesn't matter here, so use asprintf/free rather than a static buffer
2014-04-20make sure static buffers for snprintf(3) are large enoughIngo Schwarze
and cast snprintf return value to (void) where they are
2014-04-20KNF: case (FOO): -> case FOO, remove /* LINTED */ and /* ARGSUSED */,Ingo Schwarze
remove trailing whitespace and blanks before tabs, improve some indenting; no functional change
2014-04-08Add a new term_flushln() flag TERMP_BRIND (if break, then indent)Ingo Schwarze
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%.
2014-04-08If the SYNOPSIS section contains an excessively long .Nm,Ingo Schwarze
adjust the right margin to avoid running into an assertion; output in that case now agrees with groff, too.
2014-03-30Support relative arguments to .ll (increase or decrease line length).Ingo Schwarze
2014-03-30Implement the roff(7) .ll (line length) request.Ingo Schwarze
Found by naddy@ in the textproc/enchant(1) port. Of course, do not use this in new manuals.
2014-02-16when indenting, extend the right margin accordingly, when needed;Ingo Schwarze
fixes a crash reported by blambert@ and a few other, similar ones
2013-12-25Oops, .Fa never breaks the output line in the middle of any of itsIngo Schwarze
arguments, not even outside SYNOPSIS mode. Quite surprising as .Fn does break the line in the middle of its arguments outside SYNOPSIS mode, and only doesn't do that in SYNOPSIS mode. Wonders of groff...
2013-12-25Garbage collect two local variables each used only one single time.Ingo Schwarze
2013-12-25In the SYNOPSIS, implement hanging indentation for .FoIngo Schwarze
and avoid output line breaks inside .Fa arguments. This reduces groff-mandoc differences in base by more than 8%. Patch from Franco Fichtner <franco at lastsummer dot de> (DragonFly).
2013-12-25Do not break output lines in .Fn function arguments in SYNOPSIS mode.Ingo Schwarze
Following an idea from Franco Fichtner, but implemented more cleanly. This reduces groff-mandoc-differences in base by a fantastic 7.5%.
2013-12-24Delete the unused flag TERMP_IGNDELIMIngo Schwarze
and the empty callback termp_igndelim_pre(). Sort the remaining termp flags.
2013-12-24It turns out SYNOPSIS mode does not imply .Bk in general,Ingo Schwarze
but only within .Nm blocks. Simplify the code accordingly. This reduces groff-mandoc differences in base by about 2%. Triggered by research done by Franco Fichtner.
2013-12-24When deciding whether two consecutive macros are on the same input line,Ingo Schwarze
we have to compare the line where the first one *ends* (not where it begins) to the line where the second one starts. This fixes the bug that .Bk allowed output line breaks right after block macros spanning more than one input line, even when the next macro follows on the same line.
2013-12-23Implement a long-standing desideratum,Ingo Schwarze
hanging indentation for .Fn in SYNOPSIS mode, exploiting the new trailspace feature by deliberately *NOT* using it.
2013-12-22Polishing the worms in my favourite can, term_flushln().Ingo Schwarze
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*.
2013-06-02Let .Do .Dq .Ql .So .Sq generate the correct roff(7) character escapeIngo Schwarze
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@.
2013-05-29Simplify condition, avoid duplicate code; no functional change.Ingo Schwarze
2013-05-29In SYNOPSIS mode, .Ek doesn't end a keep.Ingo Schwarze
Found and fixed on the plane to the OpenBSD t2k13 hackathon in Toronto.
2013-05-18Should termp_xx_pre() ever get called for a macro it cannot handle,Ingo Schwarze
use abort(3), just like in the three other comparable cases in this file, instead of ignoring the problem and causing a null pointer access. Cosmetical issue reported by Ulrich Spoerlein <uqs@spoerlein.net> found by Coverity Scan CID 976115. No functional change.
2012-11-17Cleanup naming of local variables to make the code easier on the eye:Ingo Schwarze
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
2012-11-16Improve formatting of badly nested font blocks.Ingo Schwarze
The basic idea is to already pop the font at the end marker instead of allowing it to linger until the final end of the block. This requires a few preliminaries: * For each block, save a pointer to the previous font to be used in case the block breaks another and gets extended. * That requires making node information writable during rendering. * Now fonts may get popped in the wrong order; hence, after the stack has already been rewound further by some block that began earlier, ignore popping a font that was put on the stack later. * To be able to exploit all this for font blocks, tie processing to their body, not their block, which is more logical anyway. Triggered by florian@ reporting vaguely similar issues with list blocks.
2012-07-11fix position and formatting of %UIngo Schwarze
2012-07-10* implement -Tman .Bl -item -inset -diag -ohang -dash -hyphen -enum .ItIngo Schwarze
* fix -Tman .Bl -bullet .It * adjust the -Tascii .Bl -bullet -dash -hyphen .It default and minimum width to new groff standards, it changed from 4n (in groff 1.15) to 2n (in groff 1.21) * same for -Tascii -enum, it changed from 5n to 2n * use -hang formatting for -Tascii -enum -width 2n * for -Tascii -enum, the default is -width 3n
2012-07-09fix -Tascii .Fd line breakingIngo Schwarze
and implement -Tman .Fd
2012-07-08fix .Lk for -Tascii and implement it for -TmanIngo Schwarze
2012-07-08implement -Tman .AnIngo Schwarze
also reset -[no]split mode at .Sh AUTHORS in -Tascii
2011-11-13Make the default left text margin configurable from the command line,Ingo Schwarze
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
2011-11-03Correct .Eo spacing:Ingo Schwarze
no space between the delimiters and the enclosed text. The mdoc_html.c part was added by kristaps; ok kristaps@.
2011-10-16Remove a bunch of useless assignments,Ingo Schwarze
and assert that print_bvspace cannot be called on NULL pointers. No change in behaviour, none of these were bugs, but the code becomes easier to understand. Based on a clang report posted by joerg@; ok kristaps@.
2011-09-20Sync print_mdoc_head to print_man_head;Ingo Schwarze
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.
2011-09-19Remove the terminal frontend flag TERMP_NOLPAD.Ingo Schwarze
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@
2011-09-18sync to version 1.11.5:Ingo Schwarze
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.
2011-07-05Sync to bsd.lv (all coded by kristaps@):Ingo Schwarze
- mdoc(7): fix an assertion if the first line after .Bd -column starts with a blank, and some simplifications in mdoc_argv.c - man(7): literal mode ends at .SH and .SS (bug reported by naddy@) - allow .RS/.RE blocks to nest (bug reported by dcoppa@ and gsoares@) - improve vertical spacing of man(7) blocks - roff(7): clear user-defined strings when starting a new file - correct ID tags in -T[x]html
2011-05-29Merge release 1.11.3, almost all code by kristaps@:Ingo Schwarze
* Unicode output support (no Unicode input yet, though). * Refactoring: completely handle predefined strings in roff.c. - New function mandoc_escape() replaces a2roffdeco() and mandoc_special(). - Start using mandoc_getarg() in mdoc_argv.c. - Clean up parsing of delimiters in mdoc(7). * And many minor fixes and lots of cleanup.
2011-04-24Merge version 1.11.1:Ingo Schwarze
Again lots of cleanup and maintenance work by kristaps@. - simplify error reporting: less function pointers, more mandoc_[v]msg - main: split document parsing out of main.c into read.c - roff, mdoc, man: improved recognition of control characters - roff: better handling of if/else stack overflows - roff: add some predefined strings for backward compatibility - mdoc, man: empty sections are not errors - mdoc: move delimiter handling to libmdoc - some header restructuring and some minor features and fixes This merge causes two minor regressions that i will fix in separate commits right afterwards.
2011-03-20Import the foundation for eqn(7) support.Ingo Schwarze
Written by kristaps@. For now, i'm adding one line to each of the four frontends to just pass the input text through to the output, not yet interpreting any of then eqn keywords.
2011-03-07Clean up date handling,Ingo Schwarze
as a first step to get rid of the frequent petty warnings in this area: - always store dates as strings, not as seconds since the Epoch - for input, try the three most common formats everywhere - for unrecognized format, just pass the date though verbatim - when there is no date at all, still use the current date Originally triggered by a one-line patch from Tim van der Molen, <tbvdm at xs4all dot nl>, which is included here. Feedback and OK on manual parts from jmc@. "please check this in" kristaps@
2011-02-06Do not break the line between the arguments of .Bsx .Dx .Fx .Nx .Ox .Ux.Ingo Schwarze
Original patch from kristaps@, but i fixed a regression regarding .Bk.
2011-02-06Some pre-handlers produce output, so reorder the code to set upIngo Schwarze
keep flags before they are called. Without this bugfix, .Bk was ineffective in some cases. "looks reasonable" kristaps@
2011-02-06If .Ns is specified on its own line, ignore it, like groff does;Ingo Schwarze
from kristaps@.
2011-01-30Make .Bx accept not more than two arguments.Ingo Schwarze
Convert the first character of the second argument to uppercase. Append the second argument with a hyphen. Improves chpass(1), column(1), fstat(1), ... from kristaps@
2011-01-30Like in groff, if .%B is specified, quote .%T; from kristaps@.Ingo Schwarze
2011-01-16If the first character of a free-form text input line is whitespace,Ingo Schwarze
then it will start a new output line; from kristaps@.
2011-01-09Only .Bd -literal has 8-character tabs,Ingo Schwarze
while .Bd -unfilled has 5-character tabs just like normal text; from kristaps@.
2011-01-04Merge kristaps@' cleaner tbl integration, removing mine;Ingo Schwarze
there are still a few bugs, but fixing these will be easier in tree.
2010-12-29Reorg by Kristaps: In libmdoc, replace the union of pointers to structsIngo Schwarze
of macro-specific data by a pointer to a union of structs, which makes the code simpler and more robust at the expense of a small memory overhead. Merging was somewhat difficult because we mustn't break tbl(1) support which the bsd.lv version does not yet have.
2010-12-26Behave more like groff (both old and new): Specifying both .%T and .%J inIngo Schwarze
an .Rs block causes the title to be quoted instead of underlined, such that journal title and article title appear visually different. Original diff from kristaps@, simplified by me, tweaked again by kristaps@.