aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/term_ascii.c
Commit message (Collapse)AuthorAgeFilesLines
* Rounding rules for horizontal scaling widths are more complicated.Ingo 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.Ingo Schwarze2015-03-271-49/+22
| | | | Additional functionality, yet minus 45 lines of code.
* Clamp width and indent settings to sensible values.Ingo Schwarze2015-02-161-3/+9
| | | | | Ignore errors for now. Patch from tedu@.
* When showing more than one formatted manual page, insert horizontal linesIngo Schwarze2014-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 limitIngo Schwarze2014-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 integerIngo Schwarze2014-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 unknownIngo Schwarze2014-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 theIngo Schwarze2014-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 agreeIngo Schwarze2014-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.
* Grrr, patch(1) merged the new function to the wrong place in this file.Ingo Schwarze2014-10-261-78/+78
| | | | Resync with OpenBSD. No code change.
* In -Tascii mode, provide approximations even for some Unicode escapeIngo Schwarze2014-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 512Ingo Schwarze2014-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.Ingo 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.
* While all current callers pass valid data to ascii_hspan() only,Ingo 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.
* Improve build system and autodetection.Ingo Schwarze2014-08-161-17/+6
| | | | | | | | | * Make ./configure standalone, that's what people expect. * Let people write a ./configure.local from scratch, not edit existing files. * Autodetect wchar, sqlite3, and manpath and act accordingly. * Autodetect the need for -L/usr/local/lib and -lutil. * Get rid of config.h.p{re,ost}, let ./configure only write what's needed. * Let ./configure write a Makefile.local snippet, that's quite flexible.
* Some compilers apparently worry that abort() might returnIngo Schwarze2014-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 cleaning up scaling units.Kristaps Dzonsons2014-08-131-11/+21
| | | | | | | | | Start with the horizontal terminal specifiers, making sure that they match up with troff. Then move on to PS, PDF, and HTML, noting that we stick to the terminal default width for "u". Lastly, fix some completely-wrong documentation and note that we diverge from troff w/r/t "u".
* Get rid of HAVE_CONFIG_H, it is always defined; idea from libnbcompat.Ingo Schwarze2014-08-101-5/+3
| | | | | | 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.
* Clarity with respect to floating point handling:Ingo Schwarze2014-08-011-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 widthIngo Schwarze2014-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 */,Ingo 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).Ingo Schwarze2014-03-301-8/+12
|
* Implement the roff(7) .ll (line length) request.Ingo 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-levelIngo Schwarze2014-03-231-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 aliasIngo Schwarze2013-06-011-3/+2
| | | | | that doesn't work on OpenBSD. OK tedu@ naddy@
* Implement mdoc(7)-like output style variant for man(7) documents:Ingo Schwarze2011-12-041-3/+12
| | | | | | | | | | | * 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@
* Make the default left text margin configurable from the command line,Ingo 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
* forgotten Copyright bumps; no code changeIngo Schwarze2011-09-181-2/+2
| | | | found while syncing to OpenBSD
* Flip on -Tutf8 backend support. This forces the UTF-8 LC_CTYPE and doesKristaps Dzonsons2011-05-201-4/+16
| | | | | | little else. Also remove the check for __STDC_ISO_10646__. It turns out that very few systems---even those that support it---actually declare this and it's just causing problems instead of being useful.
* It seems that __STDC_ISO_10646__ isn't defined even where it can beKristaps Dzonsons2011-05-191-1/+8
| | | | | | | | defined, so remove the check for it and leave it up to people compiling the software (DOWNSTREAM) to take care of this. This will eventually need to be fixed up with a proper non-10646 converter and so on, but this is a simple start. While here, strengthen then language in the Makefile to this effect.
* Locale support. I'm checking this in to clean up fall-out in-tree, butKristaps Dzonsons2011-05-171-13/+70
| | | | | | | | | | | | | | | | | | | | | | | | 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-6/+20
| | | | | | | 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().
* Make character engine (-Tascii, -Tpdf, -Tps) ready for Unicode: make bufferKristaps Dzonsons2011-05-141-5/+5
| | | | | | 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.
* Remove unnecessary conditional...Kristaps Dzonsons2011-01-251-3/+2
|
* Turn on -Tascii tbl printing. The output still has some issues---I'mKristaps Dzonsons2011-01-021-1/+2
| | | | | | not sure whether it's in the header calculation or term.c squashing spaces or whatever, but let's get this in for general testing as soon as possible.
* Churny commit to quiet lint. No functional changes.Kristaps Dzonsons2010-09-041-1/+2
|
* correct lots of copyright notices;Ingo Schwarze2010-07-131-2/+2
| | | | ok kristaps@
* Pushed normalisation of scaling units into term_hspan().Kristaps Dzonsons2010-06-301-10/+4
|
* Move term_hspan() calculation into the output devices, where it belongs.Kristaps Dzonsons2010-06-301-8/+57
|
* Remove "pt" from struct roffsu, as CSS (the only reason it was there) isKristaps Dzonsons2010-06-251-1/+2
| | | | | unclear about which units accept floats/integers, which leads me to assume that it handles either and rounds as appropriate.
* Initial chunks for variable-width fonts. Pushes all width calculationsKristaps Dzonsons2010-06-251-1/+14
| | | | | | | | in mdoc_term.c and man_term.c down into term.c. This is still not implemented in term.c, although stubs for width calculations are in place. From now on, offset, rmargin, and other layout variables are abstract screen widths. They will resolve to the the familiar values for -Tascii but -Tps will eventually use points instead of chars.
* Churn as I finish email address migration kth.se -> bsd.lv.Kristaps Dzonsons2010-06-191-2/+2
|
* Have the standard manpage header and footer print on every page of -TpsKristaps Dzonsons2010-06-091-2/+1
| | | | | | | | | | | | | | | output. This is more tricky than you may think: we can't just call the header function out-of-state (i.e., before a flushln has occured) because we'd clobber our current state. Thus, we call at the beginning and dump the output into an auxiliary buffer. For the record, I don't think there's any other clean way to do this. The only other Way That Works is to copy-aside *all* termp state, zero it, and do the necessary headf/footf. This is just as complex, as memory needs to be alloc'd and free'd per margin. Unfortunately, this prohibits page numbering (the margin is only printed once), so I'll probably end up re-writing this down the line.
* Lint noops. Also fixed getsubopt() to be in unistd.h (noted by joerg@).Kristaps Dzonsons2010-06-081-1/+2
|
* Broke ascii_*() functions into term_ascii.cKristaps Dzonsons2010-06-081-0/+128
Made low-level engine functions into function pointers.