summaryrefslogtreecommitdiffstats
path: root/term.c
Commit message (Collapse)AuthorAgeFilesLines
...
* After skipping an escape sequence with incomplete arguments,Ingo Schwarze2014-07-061-2/+2
| | | | do not throw away the rest of the string to be rendered.
* Audit malloc(3)/calloc(3)/realloc(3) usage.Ingo Schwarze2014-04-231-1/+1
| | | | | | | * Change eight reallocs to reallocarray to be safe from overflows. * Change one malloc to reallocarray to be safe from overflows. * Change one calloc to reallocarray, no zeroing needed. * Change the order of arguments of three callocs (aesthetical).
* KNF: case (FOO): -> case FOO:, remove /* LINTED */ and /* ARGSUSED */,Ingo Schwarze2014-04-201-59/+47
| | | | | 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-27/+20
| | | | | | | | | | 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%.
* bugfix: make sure all variables are properly initializedIngo Schwarze2014-04-051-5/+5
| | | | when rendering .ll (line length) requests. oops.
* Support relative arguments to .ll (increase or decrease line length).Ingo Schwarze2014-03-301-0/+30
|
* The files mandoc.c and mandoc.h contained both specialised low-levelIngo Schwarze2014-03-231-1/+1
| | | | | | | 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.
* In -Tutf8 mode, make sure that hyphens get counted against the output lineIngo Schwarze2014-03-131-6/+7
| | | | | | | length even when they are breakable. Before this, a line containing N breakable hyphens could get up to N characters wider than the right margin in -Tutf8 output mode. Issue reported by tedu@ on <bugs at OpenBSD>.
* Implement the \: (optional line break) escape sequence,Ingo Schwarze2014-01-221-3/+9
| | | | | | | documented in the Ossanna-Kernighan-Ritter troff manual and also supported by groff. Missing feature reported by Steffen Nurpmeso <sdaoden at gmail dot com>.
* remove assignments that will be overwritten right afterwards,Ingo Schwarze2013-12-311-1/+0
| | | | | and remove pointless local variables; found in a clang output from Ulrich Spoerlein <uqs at FreeBSD>
* Do not break output lines in .Fn function arguments in SYNOPSIS mode.Ingo Schwarze2013-12-251-1/+11
| | | | | Following an idea from Franco Fichtner, but implemented more cleanly. This reduces groff-mandoc-differences in OpenBSD base by a fantastic 7.5%.
* Delete the unused flag TERMP_IGNDELIMIngo Schwarze2013-12-241-1/+1
| | | | | and the empty callback termp_igndelim_pre(). Sort the remaining termp flags.
* Implement a long-standing desideratum,Ingo Schwarze2013-12-231-3/+14
| | | | | | hanging indentation for .Fn in SYNOPSIS mode, exploiting the new trailspace feature by deliberately *NOT* using it.
* Polishing the worms in my favourite can, term_flushln().Ingo Schwarze2013-12-221-7/+5
| | | | | | | | | | | 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*.
* Move the last column-counting members of struct termp (col and maxcols)Ingo Schwarze2013-08-211-18/+14
| | | | | | | | | from int to size_t, to match some existing ones (offset, *rmargin, viscol). Move some related local variables from int to size_t as well. Needed as a preparation to make a generalized adjbuf() function available beyond the file term.c, i.e. in mandoc.c. Also saves a couple of ugly casts.
* Implement the roff(7) font-escape sequence \f(BI "bold+italic".Ingo Schwarze2013-08-081-28/+22
| | | | | This improves the formatting of about 40 base manuals and reduces groff-mandoc formatting differences in base by about 5%.
* After a leading blank on an output line, the first word was counted twiceIngo Schwarze2013-08-051-1/+1
| | | | | | | | | | | against vend, causing a premature line break. Fix that bug by reverting revision 1.93 which Kristaps committed four years ago. Kristaps patch is no longer needed because the code below /* Write out the [remaining] word. */ now handles leading blanks correctly, probably already for a long time. This avoids premature line breaks in about a dozen base system manuals, for example as(1) and gdb(1), and alignment issues in another twenty, for example mount(2), ip6(4), pfctl(8), and crypto(9).
* In keep mode, if any text is printed (even in NOSPACE mode),Ingo Schwarze2013-05-291-2/+2
| | | | | | | any text that follows must be kept on the same line. I already found the issue and wrote the patch in April 2011, but didn't come round to do proper testing and forgot about it.
* Improve formatting of badly nested font blocks.Ingo Schwarze2012-11-161-1/+1
| | | | | | | | | | | | | | | | | 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.
* In flush-left mode of both man(7) and mdoc(7), when an output line is brokenIngo Schwarze2012-07-161-0/+8
| | | | | at the position of a literal tab, the tab indents the following line. Fixes the perl(1) SYNOPSIS; reminded by deraadt@; OpenBSD rev. 1.66.
* Remove a hack that was intended for groff-1.15 bug compatibility:Ingo Schwarze2012-07-101-6/+1
| | | | | | | | When the width of a tag in .Bl -hang was exactly one character shorter than the maximum length that would fit, the following text would have a negative hang of one character (i.e., hang to the left). That bug is no longer present in groff-1.21, so relax mandoc, too. OpenBSD rev. 1.65
* Implement the roff \z escape sequence, intended to output the nextIngo Schwarze2012-05-311-13/+53
| | | | | | | | | | | | | | | | | | character without advancing the cursor position; implement it to simply skip the next character, as it will usually be overwritten. With this change, the pod2man(1) preamble user-defined string \*:, intended to render as a diaeresis or umlaut diacritic above the preceding character, is rendered in a slightly less ugly way, though still not correctly. It was rendered as "z.." and is now rendered as ".". Given that the definition of \*: uses elaborate manual \h positioning, there is little chance for mandoc(1) to ever render it correctly, but at least we can refrain from printing out a spurious "z", and we can make the \z do something semi-reasonable for easier cases. "just commit" kristaps@
* Fix the vertical spacing around tbl(7) instances in man(7).Ingo Schwarze2012-05-271-2/+5
| | | | | | | | | | | | | | | Groff forces the document author to manually request sufficient spacing after .TE - that is, at least .sp 1v after a table with the "box" option and at least .sp 2v after a table with the "doublebox" option - or else it clobbers the box. I consider that insane, so i'm not imitating groff in that respect. Instead, i add at least as much vertical space as groff, or more where required to avoid clobbering the box. Consequently, output will be identical for input that looks sane with groff, and mandoc will make output look better for input that looks bad with groff. "Please check them in and I'll look into them later!" kristaps@
* As noticed by kristaps@, when breaking an overflowing line,Ingo 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.
* Remove the terminal frontend flag TERMP_NOLPAD.Ingo Schwarze2011-09-191-33/+24
| | | | | | | | | | | | | | | | | 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@
* fix a regression introduced in 1.11.7:Ingo Schwarze2011-09-181-1/+4
| | | | | even a breakable hyphen may be bold or underlined ok kristaps@
* forgotten Copyright bumps; no code changeIngo Schwarze2011-09-181-1/+1
| | | | found while syncing to OpenBSD
* Remove all references to ESCAPE_PREDEF, which is now not exposed passedKristaps Dzonsons2011-05-241-22/+0
| | | | the libroff point. This clears up a nice chunk of code.
* Allow non-ASCII terminal encodings to accept unicode values for theKristaps Dzonsons2011-05-201-17/+61
| | | | | special characters, if possible. This is broken into a separate switch statement for clarity.
* Make any un-recognised font be considered a call for the Roman font.Kristaps Dzonsons2011-05-181-0/+2
| | | | | This makes sequences of \f[unknown] \fP not completely puke. From a TODO by schwarze@.
* Locale support. I'm checking this in to clean up fall-out in-tree, butKristaps Dzonsons2011-05-171-6/+45
| | | | | | | | | | | | | | | | | | | | | | | | it looks pretty good. Basically, the -Tlocale option propogates into term_ascii.c, where we set locale-specific console call-backs IFF (1) setlocale() works; (2) locale support is compiled in (see Makefile for -DUSE_WCHAR); (3) the internal structure of wchar_t maps directly to Unicode codepoints as defined by __STDC_ISO_10646__; and (4) the console supports multi-byte characters. To date, this configuration only supports GNU/Linux. OpenBSD doesn't export __STDC_ISO_10646__ although I'm told by stsp@openbsd.org that it should (it has the correct map). Apparently FreeBSD is the same way. NetBSD? Don't know. Apple also supports this, but doesn't define the macro. Special-casing! Benchmark: -Tlocale incurs less than 0.2 factor overhead when run through several thousand manuals when UTF8 output is enabled. Native mode (whether directly -Tascii or through no locale or whatever) is UNCHANGED: the function callbacks are the same as before. Note. If the underlying system does NOT support STDC_ISO_10646, there is a "slow" version possible with iconv or other means of flipping from a Unicode codepoint to a wchar_t.
* Add mode for -Tlocale. This mode, with this commit, behaves exactlyKristaps Dzonsons2011-05-171-12/+0
| | | | | | | like -Tascii. While adding this, inline term_alloc() (was a one-liner), remove some switches around the terminal encoding for the symbol table (unnecessary), and split out ascii_alloc() into ascii_init(), which is also called from locale_init().
* Flip on printing `?' at Unicode codepoints in -Tascii, -Tpdf, and -Tps.Kristaps Dzonsons2011-05-171-1/+9
| | | | | | The reasoning behind printing SOMETHING at a Unicode codepoint is because the input is not "wrong" (we suppress printing of "wrong" things). It's just that ASCII can't handle it.
* Remove function calls to res() and so forth in term_word(). These wereKristaps Dzonsons2011-05-151-52/+15
| | | | | | only used once and simply bloated the binary. Also fix mchars_num2char to correctly render the character instead of using atoi(). This makes the conversation more strict, but it's more correct.
* Fix missing support for \N'n' when calculating string widths in -TasciiKristaps Dzonsons2011-05-151-2/+7
| | | | (oops). Do the same for -Thtml (oops^2).
* Use strcspn() in term_strlen(). Clarifies the code.Kristaps Dzonsons2011-05-151-10/+10
|
* Make some values "int" that were "size_t". These are primarily used forKristaps Dzonsons2011-05-141-22/+26
| | | | indexing into arrays, so this removes lots of casts from size_t to int.
* Make character engine (-Tascii, -Tpdf, -Tps) ready for Unicode: make bufferKristaps Dzonsons2011-05-141-3/+3
| | | | | | consist of type "int". This will take more work (especially in encode and friends), but this is a strong start. This commit also consists of some harmless lint fixes.
* Make mchars_num2char() return a char like it says.Kristaps Dzonsons2011-04-301-4/+3
|
* Move "chars" interface out of out.h and into mandoc.h. This doesn'tKristaps Dzonsons2011-04-291-6/+6
| | | | | | | | | | change any code but for renaming functions and types to be consistent with other mandoc.h stuff. The reason for moving into libmandoc is that the rendering of special characters is part of mandoc itself---not an external part. From mandoc(1)'s perspective, this changes nothing, but for other utilities, it's important to have these part of libmandoc. Note this isn't documented [yet] in mandoc.3 because there are some parts I'd like to change around beforehand.
* Remove a2roffdeco() and mandoc_special() functions and replace them withKristaps Dzonsons2011-04-091-48/+59
| | | | | | | | | | | | | | | | | | a public (mandoc.h) function mandoc_escape(), which merges the functionality of both prior functions. Reason: code duplication. The a2roffdeco() and mandoc_special() functions were pretty much the same thing and both quite complex. This allows one function to receive improvements in (e.g.) subexpression handling and performance, instead of having to replicate functionality. As such, the mandoc_escape() function already handles a superset of the escapes handled in previous versions and has improvements in performance (using strcspn(), for example) and reliable handling of subexpressions. This code Works For Me, but may need work to catch any regressions. Since the benefits are great (leaner code, simpler API), I'd rather have it in-tree than floating as a patch.
* Remove an unused variable (caught in lint-check)Kristaps Dzonsons2011-04-041-3/+1
|
* Move mandoc_isdelim() back into libmdoc.h. This fixes an unreportedKristaps Dzonsons2011-03-221-7/+0
| | | | | | | | | error where (1) -man pages were punctuating delimiters (e.g., `.B a ;') and where (2) standalone punctuation in -mdoc or -man (e.g., ";" on its own line) would also be punctuated. This introduces a small amount of complexity of mdoc_{html,term}.c must manage their own spacing with running print_word() or print_text(). The check for delimiting now happens in mdoc_macro.c's dword().
* Step 4: merge chars.h into out.h. The functions in this file areKristaps Dzonsons2011-03-221-1/+0
| | | | | necessary to all [real] front-ends, so stop pretending it's special. While here, add some documentation to the variable types.
* Move mdoc_isdelim() into mandoc.h as mandoc_isdelim(). This allows theKristaps Dzonsons2011-03-171-37/+5
| | | | | | removal of manual delimiter checks in html.c and term.c. Finally, add the escaped period as a closing delimiter, removing a TODO to this effect.
* Move mandoc_{realloc,malloc,calloc} out of libmandoc.h and into mandoc.hKristaps Dzonsons2011-03-171-11/+2
| | | | | | | | so that everybody can use them. This follows the convention of libXXXX.h being internal to a library and XXXX.h being the external interface. Not only does this allow the removal of lots of redundant NULL-checking code, it also sets the tone for adding new mandoc-global routines.
* Make lint shut up a little bit.Kristaps Dzonsons2011-03-151-1/+1
|
* Implement the \N'number' (numbered character) roff escape sequence.Ingo Schwarze2011-01-301-1/+15
| | | | | | | Don't use it in new manuals, it is inherently non-portable, but we need it for backward-compatibility with existing manuals, for example in Xenocara driver pages. ok kristaps@ jmc@ and tested by Matthieu Herrb (matthieu at openbsd dot org)
* Fix spacing for tables to use term_len(). Also make term.c properlyKristaps Dzonsons2011-01-041-0/+6
| | | | recode ASCII_HYPHEN and ASCII_NBRSP before passing back for widths.
* Track down a bug of empty `de XX' macros causing uncertain behaviour byKristaps Dzonsons2010-12-061-1/+1
| | | | | | | | | | returning empty strings in roff_getstrn() instead of NULL. This caused maddeningly irregular segfaults in the pod2man preamble for `de IX'. But only on DEC alpha. Also integrate the kinda-probably-safe assertion relaxation in term.c, field-tested by schwarze@. This allows ALL [unpreprocessed] base and xenocara manuals for all BSD systems to run without segfault.