summaryrefslogtreecommitdiffstats
path: root/term_ps.c
Commit message (Collapse)AuthorAgeFilesLines
* After .ti, there are many reasons why the offset may change, so settingIngo Schwarze2020-09-061-3/+6
| | | | | | it back later requires a guard against underflow, or subsequent assertions may fail. Issue found in an afl run performed by Jan Schreiber <jes at posteo dot de>.
* streamline termp allocation: this will allow the init functionIngo Schwarze2017-11-101-14/+5
| | | | | to do things differently in the ps vs pdf case; from espie@
* Shrink -Tps output by more than 50%Ingo Schwarze2017-11-021-14/+36
| | | | | | | | by using PostScript as a programming language. * Define and use one PostScript procedure to select each font. * Define and use procedures combining "use" and "show". * In one of these, reuse the current row if it did not change. Most ideas and most coding by espie@, tweaked by me.
* Print a human-readable media name in the %%DocumentMedia DSC commentIngo Schwarze2017-10-291-10/+27
| | | | | | | | | and use the setpagedevice PostScript operator to help printers automatically select the paper of the best matching PageSize. Many thanks to Mike Williams <obsd1 at eandem dot co dot uk> for teaching me about the relevant features of PostScript and DSC and for suggesting what to put into the first %%DocumentMedia argument.
* more readable conversion of paper size from millimeters to PostScriptIngo Schwarze2017-10-261-2/+2
| | | | basic units, also slightly more precise
* The page footer line (psmarg) is created in ps_begin(), and theIngo Schwarze2017-10-251-2/+0
| | | | | | | | | | | last call writing to it is always ps_endline(), which ends with ps_pclose(), which prints "ET" (end text). Consequently, do not print another instance of "ET" in ps_closepage() after the footer line and before the "endstream" for the page. Fixing a PDF syntax error found while investigating the bug report from Jan Stary that also resulted in the previous commit.
* Properly close out the top-level Font object, the end-of-pageIngo Schwarze2017-10-251-3/+3
| | | | | | | Resource objects, and the Catalog object, fixing three PDF syntax errors that were present in every PDF file generated with mandoc since the initial checkin of the formatter in July 2010. Bug reported by Jan Stary <hans at stare dot cz> on misc@.
* Prepare the terminal driver for filling multiple columns in parallel,Ingo Schwarze2017-06-071-4/+7
| | | | | | 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.Ingo Schwarze2017-05-081-1/+4
| | | | Needed by about four dozen ports (thanks to naddy@ for the research).
* Be consistent in protecting __attribute__ attributes with __;Ingo Schwarze2017-02-171-1/+1
| | | | from Christos Zoulas <christos @ NetBSD>.
* Fix assertion failures caused by whitespace inside \o'' (overstrike)Ingo Schwarze2016-08-101-57/+45
| | | | | | sequences that jsg@ found with afl(1): * Avoid writing \t\b in term.c. * Handle trailing \b in term_ps.c.
* Use __attribute__((__format__ throughout.Ingo Schwarze2016-07-191-4/+2
| | | | | | | Triggered by a smaller patch from Christos Zoulas. While here, unify style, move several config tests to config.h, and delete the useless MANDOC_CONFIG_H.
* remove NULL-checks before free(); from mmcc@Ingo Schwarze2015-12-231-4/+2
|
* Without HAVE_ERR, don't try to include <err.h>, it probably isn't there.Ingo Schwarze2015-11-071-0/+2
| | | | | In that case, the required prototypes are in "config.h". Patch from Peter Bray <pdb_ml at yahoo dot com dot au>.
* Major character table cleanup:Ingo Schwarze2015-10-131-8/+6
| | | | | | | | | | | | | * 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-2/+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.
* Finally use __progname, err(3) and warn(3).Ingo Schwarze2015-10-111-1/+2
| | | | | | | | | | That's more readable and less error-prone than fumbling around with argv[0], fprintf(3), strerror(3), perror(3), and exit(3). It's a bad idea to boycott good interfaces merely because standards committees ignore them. Instead, let's provide compatibility modules for archaic systems (like commercial Solaris) that still don't have them. The compat module has an UCB Copyright (c) 1993...
* modernize style: "return" is not a functionIngo Schwarze2015-10-061-5/+5
|
* Rounding rules for horizontal scaling widths are more complicated.Ingo Schwarze2015-04-041-7/+7
| | | | | | | | | | | | | 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-22/+9
| | | | Additional functionality, yet minus 45 lines of code.
* Improve overstriking. When overstriking a wider character with aIngo Schwarze2015-01-211-3/+33
| | | | | | narrower one, center the latter horizontally. After a group of characters printed in the same position, advance by the width of the widest one among them.
* Enforcing an arbitrary, implementation dependent, undocumented limitIngo Schwarze2014-12-191-0/+3
| | | | | | 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.
* header cleanup:Ingo Schwarze2014-12-011-2/+1
| | | | | | * add missing forward declarations * remove needless header inclusions * some style unification
* Prevent negative arguments to the .ll request from causing integerIngo Schwarze2014-11-201-3/+5
| | | | | | | | | 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.
* Make the character table available to libroff so it can check theIngo Schwarze2014-10-281-6/+7
| | | | | | | | 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.
* Support overstriking by backspace in PostScript and PDF output.Ingo Schwarze2014-10-271-15/+61
| | | | | | | | | Of course, this is only a minor improvement; it would be much better to support non-ASCII characters in these output modes, but that would require major changes that i'm not going to work on right now. The main reason for doing this is that it allows to get ASCII output closer to groff.
* I just noticed that -Tps writes "%%CreationDate:" headers.Ingo Schwarze2014-08-281-5/+0
| | | | | That's an unwelcome leak of potentially private information. Kill it with fire.
* When support for bold italic font was added to the parsers and to theIngo Schwarze2014-08-241-35/+139
| | | | | | | | | | | generic parts of the formatters some time ago, the PostScript- and PDF-specific part of the formatters was neglected. Now pascal@ reports that mandoc -Tps throws an assertion on perl(1), apparently because that manual actually uses bold italic font. So here is an overdue implementation of bold italic font support for PostScript and PDF output.
* Begin cleaning up scaling units.Kristaps Dzonsons2014-08-131-14/+24
| | | | | | | | | 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-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.
* Clarity with respect to floating point handling:Ingo Schwarze2014-08-011-3/+3
| | | | | | Write double constants as double rather than integer literals. Remove useless explicit (double) cast done at one place and nowhere else. No functional change.
* code readability; no functional changeIngo Schwarze2014-07-271-7/+5
|
* Audit malloc(3)/calloc(3)/realloc(3) usage.Ingo Schwarze2014-04-231-9/+3
| | | | | | | * 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-98/+64
| | | | | 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-3/+8
|
* Implement the roff(7) .ll (line length) request.Ingo Schwarze2014-03-301-1/+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-0/+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.
* Tag functions with format strings as arguments as printf-like.Joerg Sonnenberger2014-01-051-1/+4
| | | | | Fix one case where a non-literal is used as format string. Fix another case where a variable is formatted using the wrong type.
* Remove a bunch of useless assignments,Ingo Schwarze2011-10-161-3/+2
| | | | | | | 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@.
* forgotten Copyright bumps; no code changeIngo Schwarze2011-09-181-1/+1
| | | | found while syncing to OpenBSD
* Fixed mingw compatibility where the "z" printf() modifier isn'tKristaps Dzonsons2011-08-161-4/+5
| | | | | recognised. It's easier to make these u_int than to jump through hoops for a special formatter.
* Add mode for -Tlocale. This mode, with this commit, behaves exactlyKristaps Dzonsons2011-05-171-1/+2
| | | | | | | 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().
* Move struct termp_ps into term_ps.c; remove the engine union in struct termp,Kristaps Dzonsons2011-05-151-168/+196
| | | | | | which only held one entry; finally (as per the first), make "ps" member into a pointer managed by term_ps.c. This frees up a nice chunk of memory during run-time and in the binary.
* Make character engine (-Tascii, -Tpdf, -Tps) ready for Unicode: make bufferKristaps Dzonsons2011-05-141-6/+9
| | | | | | 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.
* Move mandoc_{realloc,malloc,calloc} out of libmandoc.h and into mandoc.hKristaps Dzonsons2011-03-171-6/+1
| | | | | | | | 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.
* Do not leak information about the software usedIngo Schwarze2011-03-071-2/+0
| | | | | | | | | into PostScript and PDF documents behind the user's back. Joerg Sonnenberger pointed out that almost all software creating PostScript and PDF documents does so, even on OpenBSD, but that doesn't make the leakage much better in my book. According to all standards i could find, this information is optional. Issue originally reported by deraadt@; "commit!" kristaps@.
* Remove unnecessary conditional...Kristaps Dzonsons2011-01-251-2/+1
|
* Merge from OpenBSD right after 1.10.6; now back to full sync.Ingo Schwarze2010-09-271-1/+1
| | | | | | | | | | * mdoc.c: blank lines outside literal mode are more similar to .sp than .Pp * backslashes do not terminate macros; partial revert of mdoc.c 1.164; the intention of that commit is fully achieved in roff.c * mdoc_term.c: no need to list the same prototype twice * mdoc_validate.c: drop .Pp before .sp just like .Pp before .Pp * fix off-by-one found by jsg@ with parfait, OpenBSD term_ps.c 1.12 ok kristaps@
* Churny commit to quiet lint. No functional changes.Kristaps Dzonsons2010-09-041-2/+3
|
* "sys/param.h is for kernel interface programs.Kristaps Dzonsons2010-08-261-1/+1
| | | | | | sys/types.h is the file you want to include." From a downstream fix by deraadt@.