summaryrefslogtreecommitdiffstats
path: root/term.c
Commit message (Collapse)AuthorAgeFilesLines
* Implement the \f(CW and \f(CR (constant width font) escape sequencesIngo Schwarze2018-10-251-0/+1
| | | | | | | | | for HTML output. Somewhat relevant because pod2man(1) relies on this. Missing feature reported by Pali dot Rohar at gmail dot com. Note that constant width font was already correctly selected before this when required by semantic markup. Only attempting physical markup with the low-level escape sequence was ineffective.
* Implement the \*(.T predefined string (interpolate device name)Ingo Schwarze2018-08-161-1/+26
| | | | | by allowing the preprocessor to pass it through to the formatters. Used for example by the groff_char(7) manual page.
* fix typo in TERMP_MULTICOL flag test;Ingo Schwarze2017-07-281-1/+1
| | | | patch from florian@, found with clang
* implement so-called absolute horizontal motion: \h'|...',Ingo Schwarze2017-06-141-1/+6
| | | | used for example by zoem(1)
* let \l use the right fill characterIngo Schwarze2017-06-141-5/+5
|
* improve rounding rules for scaling unitsIngo Schwarze2017-06-141-3/+17
| | | | in horizontal orientation in the terminal formatter
* implement the roff(7) \p (break output line) escape sequenceIngo Schwarze2017-06-141-0/+32
|
* Implement automatic line breakingIngo Schwarze2017-06-121-24/+39
| | | | | inside individual table cells that contain text blocks. This cures overlong lines in various Xenocara manuals.
* make the internal a2roffsu() interface more powerful by returningIngo Schwarze2017-06-081-13/+4
| | | | | a pointer to the end of the parsed data, making it easier to parse subsequent bytes
* Prepare the terminal driver for filling multiple columns in parallel,Ingo Schwarze2017-06-071-24/+39
| | | | | | | | | | second step: make the per-column byte pointer persistent across term_flushln() calls, such that a subsequent call can continue at the point where the previous call left. If more than one column is in use, return from term_flushln() when the column is full, rather than breaking the output line. No functional change, because nothing sets up multiple columns yet.
* Prepare the terminal driver for filling multiple columns in parallel,Ingo Schwarze2017-06-071-66/+68
| | | | | | first step: split column data out of the terminal state struct into a new column state struct and use an array of such column state structs. No functional change.
* The \h escape sequence provides another method for moving backwards,Ingo Schwarze2017-06-071-14/+27
| | | | | | and after that, previously written output gets overwritten, but overwriting with blanks does *not* erase previously written content. Yes, manual pages exist that are crazy enough to rely on that...
* Implement the roff(7) .mc (right margin character) request.Ingo Schwarze2017-06-041-39/+60
| | | | | | The Tcl/Tk manual pages use this extensively. Delete the TERM_MAXMARGIN hack, it breaks .mc inside .nf; instead, implement a proper TERMP_BRNEVER flag.
* Make term_flushln() simpler and more robust:Ingo Schwarze2017-06-041-61/+24
| | | | | | Eliminate the "overstep" state variable. The information is already contained in "viscol". Minus 60 lines of code, no functional change intended.
* Partial implementation of \h (horizontal line drawing function).Ingo Schwarze2017-06-021-1/+57
| | | | | | | | | | | A full implementation would require access to output device properties and state variables (both only available after the main parser has finalized the parse tree) before numerical expansions in the roff preprocessor (i.e., before the main parser is even started). Not trying to pull that stunt right now because the static-width implementation committed here is sufficient for tcl-style manual pages and already more complicated than i would have suspected.
* Minimal implementation of the \h (horizontal motion) escape sequence.Ingo Schwarze2017-06-011-0/+22
| | | | Good enough to cope with the average DocBook insanity.
* Basic implementation of the roff(7) .ta (define tab stops) request.Ingo Schwarze2017-05-071-11/+14
| | | | | | This is the first feature made possible by the parser reorganization. Improves the formatting of the SYNOPSIS in many Xenocara GL manuals. Also important for ports, as reported by many, including naddy@.
* Fix an assertion failure caused by \z\[u00FF] with -Tps/-Tpdf.Ingo Schwarze2017-01-081-2/+14
| | | | Reported by jsg@ after an afl(1) run long ago.
* Fix assertion failures caused by whitespace inside \o'' (overstrike)Ingo Schwarze2016-08-101-3/+5
| | | | | | sequences that jsg@ found with afl(1): * Avoid writing \t\b in term.c. * Handle trailing \b in term_ps.c.
* sed 's/the the/the/' in a comment; from krw@Ingo Schwarze2016-04-121-1/+1
|
* This code wasted memory by allocating sizeof(enum termfont *)Ingo Schwarze2016-01-071-1/+1
| | | | | where only sizeof(enum termfont) is needed. Fixes CID 1288941. From christos@ via wiz@, both at NetBSD.
* apply bold and italic to all non-ASCII Unicode codepoints,Ingo Schwarze2015-10-231-1/+1
| | | | fixing input like \fB\('e; issue reported by bentley@
* Major character table cleanup:Ingo Schwarze2015-10-131-7/+4
| | | | | | | | | | | | | * Use ohash(3) rather than a hand-rolled hash table. * Make the character table static in the chars.c module: There is no need to pass a pointer around, we most certainly never want to use two different character tables concurrently. * No need to keep the characters in a separate file chars.in; that merely encourages downstream porters to mess with them. * Sort the characters to agree with the mandoc_chars(7) manual page. * Specify Unicode codepoints in hex, not decimal (that's the detail that originally triggered this patch). No functional change, minus 100 LOC, and i don't see a performance change.
* To make the code more readable, delete 283 /* FALLTHROUGH */ commentsIngo Schwarze2015-10-121-4/+0
| | | | | | that were right between two adjacent case statement. Keep only those 24 where the first case actually executes some code before falling through to the next case.
* modernize style: "return" is not a functionIngo Schwarze2015-10-061-6/+6
|
* /* NOTREACHED */ after abort() is silly, delete itIngo Schwarze2015-09-261-1/+0
|
* Trailing whitespace is significant when determining the width of a tagIngo Schwarze2015-09-211-0/+6
| | | | | in mdoc(7) .Bl -tag and man(7) .TP, but not in man(7) .IP. Quirk reported by Jan Stary <hans at stare dot cz> on ports@.
* Drop leading, internal, and trailing blank characters in \o (overstrike)Ingo Schwarze2015-08-301-1/+7
| | | | | | escape sequences; that's cleaner for all output modes, and it's required to prevent the PostScript/PDF formatter from dying on assertions. Bug found by jsg@ with afl.
* Replace the kludge for the \z escape sequence by an actualIngo Schwarze2015-04-291-42/+26
| | | | | | | | implementation. As a side effect, minus ten lines of code. As another side effect, this also fixes the assertion failure that used to be triggered by "\z\o'ab'c" at the beginning of an output line, found by jsg@ with afl (test case 022/Apr27).
* Rounding rules for horizontal scaling widths are more complicated.Ingo Schwarze2015-04-041-5/+5
| | | | | | | | | | | | | 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).
* Third step towards parser unification:Ingo Schwarze2015-04-021-3/+3
| | | | | 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.
* prevent the skipvsp flag from creeping past actual textIngo Schwarze2015-03-061-0/+1
|
* Use relative offsets instead of absolute pointers for the terminalIngo Schwarze2015-01-311-14/+6
| | | | | | font stack. The latter fail after the stack is grown with realloc(). Fixing an assertion failure found by jsg@ with afl some time ago (test case number 51).
* Rudimentary implementation of the roff(7) \o escape sequence (overstrike).Ingo Schwarze2015-01-211-1/+26
| | | | | | This is of some relevance because the pod2man(1) preamble abuses it for the icelandic letter Thorn, instead of simply using \(TP and \(Tp. Missing feature found by sthen@ in DateTime::Locale::is_IS(3p).
* Support negative indentations for mdoc(7) displays and lists.Ingo Schwarze2014-12-241-1/+1
| | | | | | Not exactly recommended for use, rather for groff compatibility. While here, introduce similar SHRT_MAX limits as in man(7), fixing a few cases of infinite output found by jsg@ with afl.
* When a man(7) document contains unreasonably large numbers forIngo Schwarze2014-12-241-1/+3
| | | | | | | | | | | 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-14/+8
| | | | minus twenty lines of code in spite of enhanced functionality
* Fix vertical scaling. Obviously, nobody ever had a serious look at this.Ingo Schwarze2014-12-231-7/+18
| | | | | Basic units, centimeters, points, ens, ems, and the rounding algorithm were all wrong, only inches, pica, and the default vertical span worked.
* Enforcing an arbitrary, implementation dependent, undocumented limitIngo Schwarze2014-12-191-14/+18
| | | | | | by calling assert() when valid user input exceeds it is a bad idea. Allocate the terminal font stack dynamically instead of crashing above 10 entries. Issue found by jsg@ with afl.
* Fix the implementation and documentation of \c (continue text input line).Ingo Schwarze2014-12-021-2/+2
| | | | | 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-8/+12
| | | | | | | | | | | | | | | | | | | | | 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.
* When a line (in the sense of term_flushln()) contains white space only,Ingo Schwarze2014-11-161-1/+3
| | | | | | the `vbl' variable includes the left margin, but `vis' does not. Prevent a `vis' underflow that caused a bogus blank line. Bug reported by Carsten Kunze, found in less(1): .Bl -tag ... .It " "
* fix a typo causing crashes in Unicode string length measurementIngo Schwarze2014-11-011-1/+1
|
* In terminal output, unify handling of Unicode and numbered characterIngo Schwarze2014-10-291-38/+64
| | | | | | | | | | | escape sequences just like it was earlier implemented for -Thtml. Do not let control characters other than ASCII 9 (horizontal tab) propagate to the output, even though groff allows them; but that really doesn't look like a great idea. Let mchars_num2char() return int such that we can distinguish invalid \N syntax from \N'0'. This also reduces the danger of signed char issues popping up.
* In -Tascii mode, print "<?>" only for Unicode escapes of unknownIngo Schwarze2014-10-281-9/+3
| | | | | | representation, not for character escapes with unknown names. According to groff, the latter produce no output, and we now warn about them.
* Make the character table available to libroff so it can check theIngo Schwarze2014-10-281-5/+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.
* Fix a regression in term.c rev. 1.229 reported by bentley@:Ingo Schwarze2014-10-271-6/+4
| | | | | | | | | | In UTF-8 output, do not print anything if mchars_spec2cp() returns 0. In particular, this repairs handling of zero-width spaces (\&). While here, let mchars_spec2cp() return 0xFFFD instead of -1 if the character is not found, simplifying the using code. In HTML output, do not print obfuscated ASCII characters and do not test for one-char escapes, mchars_spec2cp() already does that.
* Improve -Tascii output for Unicode escape sequences: For the first 512Ingo Schwarze2014-10-261-53/+39
| | | | | | | | | | | | code points, provide ASCII approximations. This is already much better than what groff does, which prints nothing for most code points. A few minor fixes while here: * Handle Unicode escape sequences in the ASCII range. * In case of errors, use the REPLACEMENT CHARACTER U+FFFD for -Tutf8 and the string "<?>" for -Tascii output. * Handle all one-character escape sequences in mchars_spec2{cp,str}() and remove the workarounds on the higher level.
* Control reading off the edge of our buffer in term_flushln().Kristaps Dzonsons2014-08-181-1/+1
| | | | | | | | This happens in specific conditions (trailing whitespace in certain terminal modes), but in practise, it happens quite often (as reported by valgrind). In short, "Nothing about term_flushln() is simple. Srsly!" (schwarze@) Discussed on tech@, ok schwarze@.
* 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.