summaryrefslogtreecommitdiffstats
path: root/mdoc_term.c
Commit message (Collapse)AuthorAgeFilesLines
* Use typographic quotes rather than '"' for .Rs %T (no change for -TasciiIngo Schwarze2017-02-171-2/+4
| | | | | output, of course). Patch from bentley@ in November 2014. This can be committed now because groff merged Anthony's patch yesterday.
* Surprisingly, groff does not support scaling units in .Bl -columnIngo Schwarze2017-02-161-4/+10
| | | | | | column width specifiers, so stop supporting them, too. As a side effect, this fixes an assertion failure that tb@ found with afl(1), triggered by: .Bl -column -4n
* Remove the ENDBODY_NOSPACE flag, simplifying the code.Ingo Schwarze2017-02-161-8/+0
| | | | | | | | Comparing to groff output, it appears that all cases where it was used and made a difference actually require the opposite, ENDBODY_SPACE. I have no idea why i added it back in 2010; maybe to compensate for some other bug that has long been fixed.
* The .Nm macro does not only use the default name when it has noIngo Schwarze2017-02-061-3/+1
| | | | | | | | | | argument, but also when the first argument is a child macro. Arcane issue found in the FreeBSD cxgbetool(8) manual that Baptiste Daroussin <bapt at FreeBSD> sent me long ago for a different reason. While solving this, switch to the new technique of doing text production in the validator, reducing code duplication in the formatters, which also makes -Ttree output clearer.
* Do not fix the default indent for all subsequent files; some may useIngo Schwarze2017-02-041-0/+3
| | | | | a different macro language and hence require a different indent. You can see the effect with "man -a 1 host hostname".
* Do text production for .Bt, .Ex, .Rv, .Ud at the validation stageIngo Schwarze2017-01-111-106/+4
| | | | | | | | | rather than in the formatters. Use NODE_NOSRC flag for .Lb and NODE_NOSRC and NODE_NOPRT for .St. Results in a more rigorous syntax tree and in 135 lines less code. This work was triggered by a question from Abhinav Upadhyay <er dot abhinav dot upadhyay at gmail dot com> (NetBSD) on discuss@.
* Use new NODE_NOSRC and NODE_NOPRT flags for .Bx and .At.Ingo Schwarze2017-01-101-25/+1
| | | | More rigorous AST and 40 lines less code.
* For the .Ux/.Ox family of macros, do text production at the validationIngo Schwarze2017-01-101-41/+17
| | | | | stage rather than in each and every individual formatter, using the new NODE_NOSRC flag. More rigorous and also ten lines less code.
* unify names of AST node flags; no change of cpp outputIngo Schwarze2017-01-101-23/+23
|
* Introduce flags NODE_NOSRC and NODE_NOPRT for AST nodes.Ingo Schwarze2017-01-101-1/+12
| | | | | | | | | Use them to mark generated nodes and nodes that shall not produce output. Let -Ttree output mode display these new flags. Use NODE_NOSRC for .Ar, .Mt, and .Pa default arguments. Use NODE_NOPRT for .Dd, .Dt, and .Os. These will help to make handling of text production macros more rigorous.
* use .Fn in custom sections for tagging, in addition to in DESCRIPTION;Ingo Schwarze2016-11-081-1/+1
| | | | written on the TGV Paris-Strassbourg
* tag leading .Dv, .Li, and .No in .It;Ingo Schwarze2016-11-081-0/+1
| | | | written on the TGV Paris-Strassbourg
* implement tag priority 0, which will tag only keys that appear asIngo Schwarze2016-11-081-2/+24
| | | | | tag candidates exactly once, and use it for .Em and .Sy; written on the TGV Toulouse-Paris
* generate two tag entries from list entries of the formIngo Schwarze2016-11-081-1/+3
| | | | | .It Macro tag1 ... | Macro tag2 ... written on the TGV Toulouse-Paris
* Delete complicated code dealing with .Bl -tag without -width,Ingo Schwarze2016-10-091-1/+1
| | | | | | | | | | | | and just let it default to -width 6n, which agrees with the traditional -width Ds that is still in widespread use. I just pushed a patch upstream to GNU roff that does the same for groff_mdoc(7). Before, groff contained code that was even more complicated than mandoc, but both resulted in quite different user-visible output. Now, both agree, and output is nicer for both. Useless complication noticed by Carsten Kunze (Heirloom roff).
* Delete the redundant "nchild" member of struct roff_node, replacingIngo Schwarze2016-01-081-24/+25
| | | | | | | | most uses by one, a few by two pointer checks, and only one by a tiny loop - not only making data smaller, but code shorter as well. This gets rid of an implicit invariant that confused both static analysis tools and human auditors. No functional change.
* Use "-" rather than "\(hy" for the heads of .Bl -dash and -hyphen lists.Ingo Schwarze2015-10-121-1/+1
| | | | | | | In UTF-8 output, that renders as ASCII HYPHEN-MINUS (U+002D) rather than HYPHEN (U+2010), which looks better and matches groff. In ASCII output, it makes no difference. Suggested by naddy@.
* To make the code more readable, delete 283 /* FALLTHROUGH */ commentsIngo Schwarze2015-10-121-54/+3
| | | | | | 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-78/+78
|
* /* NOTREACHED */ after abort() is silly, delete itIngo Schwarze2015-09-261-4/+0
|
* Trailing whitespace is significant when determining the width of a tagIngo Schwarze2015-09-211-2/+2
| | | | | 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@.
* The .Dv macro actually forces normal font.Ingo Schwarze2015-09-141-1/+1
|
* Simplify and make tag_put() more efficient by integrating tag_get()Ingo Schwarze2015-07-251-10/+6
| | | | | into it and by only handling NUL-terminated strings. Minus 25 lines of code, no functional change.
* implement tagging for .ErIngo Schwarze2015-07-251-1/+15
|
* basic tag support for function names; written at YYCIngo Schwarze2015-07-251-2/+17
|
* basic support for tag priorities; written at YYCIngo Schwarze2015-07-251-2/+2
|
* Initial, still somewhat experimental implementation to leverageIngo Schwarze2015-07-171-1/+21
| | | | | | | | | | | | | | | 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@.
* Delete the wrapper functions mdoc_meta(), man_meta(), mdoc_node(),Ingo Schwarze2015-04-181-8/+6
| | | | | | 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-1/+1
| | | | | 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-1/+1
| | | | | | | | | | | | | 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-12/+6
| | | | | 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-13/+13
| | | | | | | | | 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-80/+81
| | | | | | 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-0/+2
| | | | | | 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-3/+6
| | | | Instead, use the same logic as for man(7).
* Render \(lq and \(rq as '"' in -Tascii mode but leave the renderingIngo Schwarze2015-02-171-2/+2
| | | | | | 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-2/+3
| | | | | | | | | | | | | | | | | | | | | | | 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-3/+2
| | | | found by jsg@ with afl, test case #16
* fix handling of empty .An macrosIngo Schwarze2015-02-051-3/+0
|
* Simplify by deleting the "lastline" member of struct mdoc_node.Ingo Schwarze2015-02-051-6/+3
| | | | Minus one struct member, minus 17 lines of code, no functional change.
* fix .Eo/.Ec spacingIngo Schwarze2015-02-011-13/+54
|
* Use relative offsets instead of absolute pointers for the terminalIngo Schwarze2015-01-311-1/+1
| | | | | | 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-3/+4
| | | | | 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-5/+5
| | | | | | 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-49/+56
| | | | | | 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-1/+2
| | | | minus twenty lines of code in spite of enhanced functionality
* some scaling unit fixes:Ingo Schwarze2014-12-231-17/+8
| | | | | - .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-1/+2
| | | | | 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-1/+2
| | | | | | | * 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-8/+2
|