aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_term.c
Commit message (Collapse)AuthorAgeFilesLines
* Delete the wrapper functions mdoc_meta(), man_meta(), mdoc_node(),Ingo Schwarze2015-04-181-9/+7
| | | | | | man_node() from the mandoc(3) semi-public interface and the internal wrapper functions print_mdoc() and print_man() from the HTML formatters. Minus 60 lines of code, no functional change.
* Replace the structs mdoc and man by a unified struct roff_man.Ingo Schwarze2015-04-181-2/+2
| | | | | Almost completely mechanical, no functional change. Written on the train from Exeter to London returning from p2k15.
* Rounding rules for horizontal scaling widths are more complicated.Ingo Schwarze2015-04-041-2/+2
| | | | | | | | | | | | | 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-13/+7
| | | | | 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.
* Second step towards parser unification:Ingo Schwarze2015-04-021-14/+14
| | | | | | | | | Replace struct mdoc_node and struct man_node by a unified struct roff_node. To be able to use the tok member for both mdoc(7) and man(7) without defining all the macros in roff.h, sacrifice a tiny bit of type safety and make tok an int rather than an enum. Almost mechanical, no functional change. Written on the Eurostar from Bruxelles to London on the way to p2k15.
* First step towards parser unification:Ingo Schwarze2015-04-021-81/+82
| | | | | | Replace enum mdoc_type and enum man_type by a unified enum roff_type. Almost mechanical, no functional change. Written on the ICE train from Frankfurt to Bruxelles on the way to p2k15.
* Fix vertical spacing at the beginning of tables.Ingo Schwarze2015-03-061-1/+3
| | | | | | man(7) always prints a blank line, mdoc(7) doesn't. Problem in mdoc(7) reported by kristaps@. mdoc(7) part of the patch tested by kristaps@.
* In mdoc(7), don't mistreat negative .sp arguments as large positive ones.Ingo Schwarze2015-03-061-4/+7
| | | | Instead, use the same logic as for man(7).
* Render \(lq and \(rq as '"' in -Tascii mode but leave the renderingIngo Schwarze2015-02-171-3/+3
| | | | | | of .Do/.Dc, .Dq, .Lb, and .St untouched. Reduces groff-mandoc differences in OpenBSD base by about 7%. Reminded of the issue by naddy@.
* Delete the mdoc_node.pending pointer and the function calculatingIngo Schwarze2015-02-121-3/+4
| | | | | | | | | | | | | | | | | | | | | | | it, make_pending(), which was the most difficult function of the whole mdoc(7) parser. After almost five years of maintaining this hellhole, i just noticed the pointer isn't needed after all. Blocks are always rewound in the reverse order they were opened; that even holds for broken blocks. Consequently, it is sufficient to just mark broken blogs with the flag MDOC_BROKEN and breaking blocks with the flag MDOC_ENDED. When rewinding, instead of iterating the pending pointers, just iterate from each broken block to its parents, rewinding all that are MDOC_ENDED and stopping after processing the first ancestor that it not MDOC_BROKEN. For ENDBODY markers, use the mdoc_node.body pointer in place of the former mdoc_node.pending. This also fixes an assertion failure found by jsg@ with afl, test case #467 (Bo Bl It Bd Bc It), where (surprise surprise) the pending pointer got corrupted. Improved functionality, minus one function, minus one struct field, minus 50 lines of code.
* do not access a NULL pointer if an .Eo block lacks a tail;Ingo Schwarze2015-02-111-4/+3
| | | | found by jsg@ with afl, test case #16
* fix handling of empty .An macrosIngo Schwarze2015-02-051-4/+1
|
* Simplify by deleting the "lastline" member of struct mdoc_node.Ingo Schwarze2015-02-051-7/+4
| | | | Minus one struct member, minus 17 lines of code, no functional change.
* fix .Eo/.Ec spacingIngo Schwarze2015-02-011-14/+55
|
* Use relative offsets instead of absolute pointers for the terminalIngo Schwarze2015-01-311-2/+2
| | | | | | 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).
* Have pity on the poor stack.Ingo Schwarze2015-01-301-4/+5
| | | | | Replace tail recursion by iteration when walking the syntax trees. No functional change.
* Let .Aq/.Ao/.Ac print "<>" instead of the normal "\(la\(ra"Ingo Schwarze2015-01-231-6/+6
| | | | | | when the only child is .Mt, not when the preceding node is .An, to improve robustness. Triggered by a question from Svyatoslav Mishyn <juef at openmailbox dot org> (Crux Linux).
* Support negative indentations for mdoc(7) displays and lists.Ingo Schwarze2014-12-241-50/+57
| | | | | | 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.
* support negative horizontal widths in man(7);Ingo Schwarze2014-12-231-2/+3
| | | | minus twenty lines of code in spite of enhanced functionality
* some scaling unit fixes:Ingo Schwarze2014-12-231-18/+9
| | | | | - .sp with an invalid argument is .sp 1v, not .sp 0v - in man(1), trailing garbage doesn't make scaling units invalid
* Fix the implementation and documentation of \c (continue text input line).Ingo Schwarze2014-12-021-2/+3
| | | | | In particular, make it work in no-fill mode, too. Reminded by Carsten dot Kunze at arcor dot de (Heirloom roff).
* Multiple fixes with respect to .Pf:Ingo Schwarze2014-11-301-2/+3
| | | | | | | * The first argument of .Pf is not parsed. * Normal delimiter handling does not apply to the first argument of .Pf. * Warn if nothing follows a prefix (inspired by groff_mdoc(7)). * In that case, do not suppress spacing.
* mop up an #ifdef turd deraadt@ stepped intoIngo Schwarze2014-11-281-9/+3
|
* Be more careful about meta->name. For weird input, it can be NULL.Ingo Schwarze2014-11-281-7/+11
| | | | Fixing a NULL access jsg@ found with afl.
* Multiple fixes with respect to .Eo:Ingo Schwarze2014-11-271-4/+6
| | | | | | | | 1. Correctly parse stray .Ec without preceding .Eo, avoiding an assertion violation found by jsg@ with afl. 2. Correctly parse .Ec arguments when breaking another block. 3. Correct spacing around closing delimiter when breaking another block. 4. Sync some related formatting control from -Tascii to -Thtml.
* Fix the obsolete .Db (toggle debug mode) macro to ignore its argumentsIngo Schwarze2014-11-271-5/+5
| | | | | and not trigger an assertion when there is more than one argument; the latter found by jsg@ with afl.
* Do not access a NULL pointer when a section has no body,Ingo Schwarze2014-11-251-7/+10
| | | | | which can for example happen for .Sh Xo .Sh without .Xc. Crash found by jsg@ with afl.
* We repeatedly observed assertion crashes in the low-level terminalIngo Schwarze2014-11-211-11/+9
| | | | | | | | | | | | | | | | | | | | | 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.
* Let .Ao and .Aq render as "<>" after .An and as "\(la\(ra" elsewhere,Ingo Schwarze2014-11-191-3/+5
| | | | just like groff; minibug noticed by bentley@.
* Multiple fixes with respect to in-line macros:Ingo Schwarze2014-11-171-2/+2
| | | | | | | | | | * .No selects the default font; relevant e.g. in .Bf blocks * no need to force empty .Li elements * closing delimiters as leading macro arguments do not suppress space * opening delimiters at the end of a macro line do not suppress space * correctly handle delimiter spacing in -Tman As a side effect, these fixes let mandoc warn about empty .No macros as requested by bentley@.
* add required vertical spacing before lists that beginIngo Schwarze2014-11-101-10/+12
| | | | | | at the beginning of the first item of an enclosing list right at the beginning of a new section or subsection; minibug reported by Steffen Nurpmeso <sdaoden at yandex dot com>
* Major bugsquashing with respect to -offset and -width:Ingo Schwarze2014-10-301-26/+13
| | | | | | | | | 1. Support specifying the .Bd and .Bl -offset as a macro default width; while here, simplify the code handling the same for .Bl -width. 2. Correct handling of .Bl -offset arguments: unlike .Bd -offset, the arguments "left", "indent", and "indent-two" have no special meaning. 3. Fix the scaling of string length -offset and -width arguments in -Thtml. Triggered by an incomplete documentation patch from bentley@.
* Make the character table available to libroff so it can check theIngo Schwarze2014-10-281-4/+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.
* correct the spacing after in-line equationsIngo Schwarze2014-10-201-2/+2
| | | | | that start at the beginning of an input line but end before the end of an input line
* correct spacing *after* inline equations (much simpler than expected)Ingo Schwarze2014-10-201-1/+3
|
* correct spacing before inline equationsIngo Schwarze2014-10-201-1/+3
|
* Properly scale string length measurements for PostScript and PDF output;Ingo Schwarze2014-10-131-3/+7
| | | | | this doesn't change anything for ASCII and UTF-8. Problem reported by bentley@.
* simplify handling of .An -[no]split for terminal output:Ingo Schwarze2014-09-171-45/+17
| | | | | delete one static function, one flag #define, and 25 lines of code; no functional change
* Implement the traditional -h option for man(1): show the SYNOPSIS only.Ingo Schwarze2014-09-031-18/+25
| | | | | | | 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.
* Right after .Fl, a middle delimiter triggers an empty scope,Ingo Schwarze2014-08-211-4/+5
| | | | | | | | | | | | just like a closing delimiter. This didn't work in groff-1.15, but it now works in groff-1.22. After being closed by delimiters, .Nm scopes do not reopen. Do not suppress white space after .Fl if the next node is a text node on the same input line; that can happen for middle delimiters. Fixing an issue reported by jmc@.
* ... and remove the trailing spaces (duh. i should pay more attention)Ingo Schwarze2014-08-171-6/+6
|
* KNF: fix indentation of previous commit, see style(9):Ingo Schwarze2014-08-171-10/+10
| | | | | "Indentation is an 8 character tab. Second level indents are four spaces." All the rest of this file already conforms.
* Protect against accessing "n->next->child" by first checking "n->next".Kristaps Dzonsons2014-08-171-9/+14
| | | | | Noticed in a crash against ".It Nm Fo" with no closing "Fc". Original patch expanded by schwarze@ then extended even more.
* Get rid of HAVE_CONFIG_H, it is always defined; idea from libnbcompat.Ingo Schwarze2014-08-101-3/+1
| | | | | | 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.
* Bring the handling of defective prologues even closer to groff,Ingo Schwarze2014-08-061-2/+6
| | | | | | | | | | | | in particular relaxing the distinction between prologue and body and further improving messages. * The last .Dd wins and the last .Os wins, even in the body. * The last .Dt before the first body macro wins. * Missing title in .Dt defaults to UNTITLED. Warn about it. * Missing section in .Dt does not default to 1. But warn about it. * Do not warn multiple times about the same mdoc(7) prologue macro. * Warn about missing .Os. * Incomplete .TH defaults to empty strings. Warn about it.
* Get rid of the useless FATAL error "child violates parent syntax".Ingo Schwarze2014-07-301-2/+5
| | | | | When finding items outside lists, simply skip them and throw an ERROR. Handle subsections before the first section instead of bailing out.
* Various improvements related to .Ex and .Rv:Ingo Schwarze2014-07-301-22/+31
| | | | | | | | | | * let .Nm fall back to the empty string, not to UNKNOWN * never let .Rv copy an argument from .Nm * avoid spurious \fR after empty .Nm in -Tman * correct handling of .Ex and .Rv in -Tman * correct the wording of the output for .Rv without arguments * use non-breaking spaces in .Ex and .Rv output where required * split MANDOCERR_NONAME into a warning for .Ex and an error for .Nm
* Partial implementation of .Bd -centered.Ingo Schwarze2014-07-291-3/+14
| | | | | | | | | In groff, .Bd -centered operates in fill mode, which is relatively hard to implement, while this implementation operates in non-fill mode so far. As long as you pay attention that your lines do not overflow, it works. To make sure that rendering is the same for mandoc and groff, it is recommended to insert .br between lines for now. This implementation will need improvement later.
* no need to skip content before first section headerIngo Schwarze2014-07-071-2/+5
|
* Fix formatting of empty .Bl -inset item heads.Ingo Schwarze2014-07-031-2/+2
| | | | | | Downgrade empty item heads from ERROR to WARNING. Show the list type in the error message. Choose better variable names for nodes in post_it().