summaryrefslogtreecommitdiffstats
path: root/usr.bin/mandoc/term_ascii.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Bugfix: never set termp->enc to the ambiguous value TERMENC_LOCALE,schwarze2018-11-281-4/+4
| | | | | | but instead set it to TERMENC_UTF8 or TERMENC_ASCII. Makes tbl(7) box drawing work under -T locale (that is, by default when LC_CTYPE is defined appropriately).
* Improve the ASCII rendering of \(Po (Pound Sterling)schwarze2018-08-211-2/+2
| | | | | and of the playing card suits to match groff, using feedback from Ralph Corderoy <ralph at inputplus dot co dot uk>.
* Unsurprisingly, zero-width non-breaking spaces have... width 0.schwarze2018-08-181-3/+2
|
* Protect against malicious manual pages containing .ll requests withschwarze2018-05-201-1/+7
| | | | | | | | | | | | | | excessive arguments: apply the same cutoff as for the -O width= command line argument. While here, also place some assertions at strategical places to prevent excessive indentations from being printed in case of bugs. In the past, we had more than one bug that caused mandoc to print effectively infinite output, filling up people's /tmp/ file system, which is not funny. We cannot prevent bugs from crashing the program, but we can at least make filling up the disk less likely. Triggered by a remark from sthen@ on source-changes@.
* Make sure that mandoc only goes into UTF-8 mode if the user reallyschwarze2018-04-131-3/+15
| | | | | | selected UTF-8, not some other multibyte locale. This obviously makes no difference on OpenBSD but improves portability. Issue reported by <Nakayama at NetBSD> via wiz@.
* Switch ASCII rendering of the same mathematical symbols and greekschwarze2017-08-231-6/+6
| | | | | | | | | | letters as in groff commit babca15f from trying to imitate the characters' graphical shapes, which resulted in unintelligible renderings in many cases, to transliterations conveying the characters' meanings. One benefit is making these characters usable for portable manual pages. Solving a problem pointed out by bentley@.
* harmless, but weird typo; found with afterstep_faq(1)schwarze2017-06-141-2/+2
|
* Prepare the terminal driver for filling multiple columns in parallel,schwarze2017-06-071-8/+10
| | | | | | 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.
* Basic implementation of the roff(7) .ti (temporary indent) request.schwarze2017-05-081-2/+6
| | | | Needed by about four dozen ports (thanks to naddy@ for the research).
* Basic implementation of the roff(7) .ta (define tab stops) request.schwarze2017-05-071-2/+1
| | | | | | 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@.
* ISO C99 7.19.2.5 doesn't like mixing putchar(3) and putwchar(3) onschwarze2016-07-081-7/+6
| | | | | | the same stream, and actually, it fails spectacularly on glibc. Portability issue pointed out by Svyatoslav Mishyn <juef at openmailbox dot org> after testing on Void Linux.
* Never use LC_ALL. On the one hand, it can cause misformatting.schwarze2015-11-121-2/+10
| | | | | On the other hand, it is a security risk because it might cause buffer overflows. Use LC_CTYPE only, that's all we need.
* Major character table cleanup:schwarze2015-10-131-12/+9
| | | | | | | | | | | | | * 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 */ commentsschwarze2015-10-121-3/+1
| | | | | | 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 function; ok cmp(1)schwarze2015-10-061-10/+10
|
* /* NOTREACHED */ after abort() is silly, delete itschwarze2015-09-261-2/+1
|
* Initial, still somewhat experimental implementation to leverageschwarze2015-07-171-1/+5
| | | | | | | | | | | | | | | less(1) -T and :t ctags(1)-like functionality to jump to the definitions of various terms inside manual pages. To be polished in the tree, so bear with me and report issues. Technically, if less(1) is used as a pager, information is collected by the mdoc(7) terminal formatter, first stored using the ohash library, then ultimately written to a temporary file which is passed to less via -T. No change intended for other output formatters or when running without a pager. Based on an idea from Kristaps using feedback from many, in particular phessler@ nicm@ millert@ halex@ doug@ kspillner@ deraadt@.
* Rounding rules for horizontal scaling widths are more complicated.schwarze2015-04-041-25/+19
| | | | | | | | | | | | | 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).
* Actually use the new man.conf(5) "output" directive.schwarze2015-03-271-49/+22
| | | | Additional functionality, yet minus 45 lines of code.
* Clamp width and indent settings to sensible values. Ignore errors for now.tedu2015-02-161-3/+9
| | | | ok schwarze
* When showing more than one formatted manual page, insert horizontal linesschwarze2014-12-311-1/+15
| | | | | | between pages. Suggested by Theo Buehler <theo at math dot ethz dot ch>. Even in UTF-8 output mode, do not use fancy line drawing characters such that you can easily use /^--- to skip to the next manual in your pager.
* Enforcing an arbitrary, implementation dependent, undocumented limitschwarze2014-12-191-1/+4
| | | | | | 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.
* Prevent negative arguments to the .ll request from causing integerschwarze2014-11-201-4/+6
| | | | | | | | | underflow. Found while preparing an audit of termp.rmargin. Overflow can also happen, but i see no sane way to deal with it, so just let it happen. It doesn't happen for any sane input anyway, groff behaviour is undefined, and the resulting values are legal, even though they are useless.
* In -Tascii mode, print "<?>" only for Unicode escapes of unknownschwarze2014-10-281-3/+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 theschwarze2014-10-281-9/+11
| | | | | | | | 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.
* Refine -Tascii rendering of Unicode characters, mostly to better agreeschwarze2014-10-281-35/+35
| | | | | | | | | with groff, in particular in cases where groff uses backspace overstrike. In two cases, agreement is impossible because groff clobbers the previous line: \(*G \(*S In a number of cases, groff rendering is so misleading that i chose to render differently: \(Sd \(TP \(Tp \(Po \(ps \(sc \(r! \(r? \(de While here, also correct the \(la and \(ra Unicode code points.
* In -Tascii mode, provide approximations even for some Unicode escapeschwarze2014-10-261-3/+5
| | | | | | | | sequences above codepoint 512 by doing a reverse lookup in the existing mandoc_char(7) character table. Again, groff isn't smart enough to do this and silently discards such escape sequences without printing anything.
* Improve -Tascii output for Unicode escape sequences: For the first 512schwarze2014-10-261-1/+76
| | | | | | | | | | | | 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.
* Implement the traditional -h option for man(1): show the SYNOPSIS only.schwarze2014-09-031-3/+7
| | | | | | | 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.
* typo, sorryschwarze2014-08-171-2/+2
|
* While all current callers pass valid data to ascii_hspan() only,schwarze2014-08-171-2/+2
| | | | | | it's safer to assume incoming enum data might be invalid and catch it instead of happily returning an unitialized int. No functional change right now.
* Some compilers apparently worry that abort() might returnschwarze2014-08-141-2/+3
| | | | | | and then throw a "may be used uninitialized" warning, so sprinkle some /* NOTREACHED */. No functional change. Noticed by Thomas Klausner <wiz at NetBSD dot org>.
* Begin cleanup of scaling units.schwarze2014-08-131-11/+21
| | | | | | | | | | | | Note that we use 240u := 1i for all devices, even -Tps and -Tpdf. Big fix of -Tascii rendering of f, m, and u. Small fix of -Tascii rendering of c. Big fix of -Thtml rendering of u. Big fix of -Tps rendering of m, p, and u. Clarify -Tps rendering of c. Correct documentation of scaling units, in particular with respect to u. This for example improves rendering of the OpenGL manuals. Joint work with kristaps@.
* Clarity with respect to floating point handling:schwarze2014-08-081-7/+7
| | | | | | Write double constants as double rather than integer literals. Remove useless explicit (double) cast done at one place and nowhere else. No functional change.
* Even for UTF-8 output, a non-breaking space character has the same widthschwarze2014-07-271-2/+7
| | | | as a normal space character, and not width 0. Bug reported by bentley@.
* KNF: case (FOO): -> case FOO, remove /* LINTED */ and /* ARGSUSED */,schwarze2014-04-201-26/+17
| | | | | remove trailing whitespace and blanks before tabs, improve some indenting; no functional change
* Support relative arguments to .ll (increase or decrease line length).schwarze2014-03-301-8/+12
|
* Implement the roff(7) .ll (line length) request.schwarze2014-03-301-2/+16
| | | | | Found by naddy@ in the textproc/enchant(1) port. Of course, do not use this in new manuals.
* The files mandoc.c and mandoc.h contained both specialised low-levelschwarze2014-03-211-2/+2
| | | | | | | 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.
* Use a standard locale name, "UTF-8" is an ugly non-standard aliasschwarze2013-06-011-3/+2
| | | | | that doesn't work on OpenBSD. OK tedu@ naddy@
* As requested by kristaps@, add and improve comments related to -Omdoc;schwarze2011-12-051-1/+5
| | | | while here, clean up some redundant initializations in print_man_head().
* Support -man -Omdoc to format man(7) manuals in mdoc(7) output style;schwarze2011-11-131-3/+8
| | | | | | | | | | | so far, this is only accepting the option, i will commit the (few) formatting tweaks separately. This is intentionally undocumented for two reasons: (1) We dream of making it the default at some point, so the option will hopefully go away again. (2) It is not needed for production, but mostly for automated man(7) to mdoc(7) output comparisons, to help -Tman development.
* Make the default left text margin configurable from the command line,schwarze2011-11-131-4/+8
| | | | | | | 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
* Merge release 1.11.3, almost all code by kristaps@:schwarze2011-05-291-21/+91
| | | | | | | | | * 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.
* Remove unnecessary conditional: term_alloc() cannot return NULL;schwarze2011-01-311-3/+2
| | | | from kristaps@.
* Merge kristaps@' cleaner tbl integration, removing mine;schwarze2011-01-041-5/+2
| | | | there are still a few bugs, but fixing these will be easier in tree.
* Merge release 1.10.4 (all code by kristaps@), providing four new features:schwarze2010-07-131-9/+53
| | | | | | | | | | 1) Proper .Bk support: allow output line breaks at input line breaks, but keep input lines together in the output, finally fixing synopses like aucat(1), mail(1) and tmux(1). 2) Mostly finished -Tps (PostScript) output. 3) Implement -Thtml output for .Nm blocks and .Bk -words. 4) Allow iterative interpolation of user-defined roff(7) strings. Also contains some minor bugfixes and some performance improvements.
* As a first step towards variable-width font support,schwarze2010-06-261-1/+14
| | | | | move all width calculations in term_*.c, *_width(). From kristaps.
* minimal initial -Tps support, from kristaps@ GSOCschwarze2010-06-101-0/+128
so far, monospace without font decoration, but it already has page headers and footers