summaryrefslogtreecommitdiffstats
path: root/man_macro.c
Commit message (Collapse)AuthorAgeFilesLines
* Delete the redundant "nchild" member of struct roff_node, replacingIngo Schwarze2016-01-081-1/+1
| | | | | | | | 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.
* move man(7) validation into the dedicated validation phase, tooIngo Schwarze2015-10-221-18/+4
|
* modernize style: "return" is not a functionIngo Schwarze2015-10-061-2/+2
|
* /* NOTREACHED */ after abort() is silly, delete itIngo Schwarze2015-09-261-1/+0
|
* Fill mode changes don't break next-line scope in all cases,Ingo Schwarze2015-09-041-2/+2
| | | | | | in particular not for tagged paragraphs. Issue found by Christian Neukirchen <chneukirchen at gmail dot com> in the exiv2(1) manual page.
* Get rid of two empty wrapper functions. No functional change.Ingo Schwarze2015-04-231-2/+1
|
* Unify trickier node handling functions.Ingo Schwarze2015-04-191-4/+3
| | | | | | | * man_elem_alloc() -> roff_elem_alloc() * man_block_alloc() -> roff_block_alloc() The functions mdoc_elem_alloc() and mdoc_block_alloc() remain for now because they need to do mdoc(7)-specific argument processing.
* Unify some node handling functions that use TOKEN_NONE.Ingo Schwarze2015-04-191-4/+4
| | | | | | | | * mdoc_word_alloc(), man_word_alloc() -> roff_word_alloc() * mdoc_word_append(), man_word_append() -> roff_word_append() * mdoc_addspan(), man_addspan() -> roff_addtbl() * mdoc_addeqn(), man_addeqn() -> roff_addeqn() Minus 50 lines of code, no functional change.
* Unify node handling functions:Ingo Schwarze2015-04-191-6/+8
| | | | | | | | | | | * node_alloc() for mdoc and man_node_alloc() -> roff_node_alloc() * node_append() for mdoc and man_node_append() -> roff_node_append() * mdoc_head_alloc() and man_head_alloc() -> roff_head_alloc() * mdoc_body_alloc() and man_body_alloc() -> roff_body_alloc() * mdoc_node_unlink() and man_node_unlink() -> roff_node_unlink() * mdoc_node_free() and man_node_free() -> roff_node_free() * mdoc_node_delete() and man_node_delete() -> roff_node_delete() Minus 130 lines of code, no functional change.
* Replace the structs mdoc and man by a unified struct roff_man.Ingo Schwarze2015-04-181-8/+8
| | | | | Almost completely mechanical, no functional change. Written on the train from Exeter to London returning from p2k15.
* Vastly simplify man(7) block unwinding, similar to mdoc_macro.c 1.171.Ingo Schwarze2015-04-031-118/+33
| | | | | Drop one enum type, two static functions, 70 lines of code. Also fixes the mpeg_encode(1) manual reported broken by naddy@.
* It turns out the man(7) parser suffers from unintelligible handlingIngo Schwarze2015-04-031-1/+1
| | | | | | | | of block rewinding, just like then mdoc(7) parser did. First step in getting rid of rew_scope(): Replace the only call where the target block is known. This commit is analogous to mdoc_macro.c rev. 1.167. One down, three to go.
* Second step towards parser unification:Ingo Schwarze2015-04-021-17/+16
| | | | | | | | | 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-28/+29
| | | | | | 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.
* The .PD macro can occur in next-line scope. Fixes zshmisc(1).Ingo Schwarze2015-03-201-1/+1
| | | | Issue reported by Christian Neukirchen <chneukirchen at gmail dot com>.
* Simplify by almost halving the number of macro flags:Ingo Schwarze2015-03-201-15/+17
| | | | | | | 1. MAN_EXPLICIT was used iff fp == blk_exp, so just test fp. 2. MAN_FSCOPED was used only for TP, so just test for TP. 3. MAN_NOCLOSE was completely unused. No functional change.
* better error reporting regarding .OP .RS .UR .TH argumentsIngo Schwarze2015-02-061-16/+10
|
* better diagnostics about excess arguments to .PD .ft .spIngo Schwarze2015-02-061-0/+7
|
* better error reporting for .br .fi .nf with argumentsIngo Schwarze2015-02-061-0/+7
|
* preserve .PP before .RE; effect found in audio/pms(1)Ingo Schwarze2015-01-241-1/+12
|
* Strangely, ignoring the roff(7) .na request was implemented in the man(7)Ingo Schwarze2015-01-241-1/+0
| | | | | parser. Simplify the code by moving it into the roff(7) parser, also making it work for mdoc(7).
* Support .RE with an argument; needed for audio/pms(1).Ingo Schwarze2015-01-241-2/+22
|
* Explicit block closure macros clobber next-line block head scope,Ingo Schwarze2014-12-161-2/+2
| | | | | just like explicit block macros themselves. Fixing an assertion failure jsg@ found with afl.
* Simplify by making many functions in the man(7) parser void,Ingo Schwarze2014-11-281-86/+53
| | | | and some cleanup; no functional change, minus 70 lines.
* Allow the five man(7) font macros to concatenate their line arguments,Ingo Schwarze2014-11-031-7/+10
| | | | | | | the same way the mdoc(7) macros marked MDOC_JOIN do it. In -Thtml, this removes bogus <br/> when the font macros are used in no-fill mode; issue found by jsg@ in the Xcursor(3) SYNOPSIS. As a bonus, this slightly reduces the size of the syntax tree.
* When the first child of the node being validated gets deleted duringIngo Schwarze2014-08-181-1/+12
| | | | | | | | | | | | | | | validation, man_node_unlink() switches to MAN_NEXT_CHILD. After that, we have to switch back to MAN_NEXT_SIBLING after completing validation, or subsequent parsing would add content into an already closed node, clobbering potentially existing children, causing information loss and a memory leak. Bug found by kristaps@ with valgrind in groff(7) on Mac OS X. Note that the switch back must be conditional, for if the node being validated itself gets deleted, we must *not* go to MAN_NEXT_SIBLING, which would not only yield wrong results in general but also crash in malformed manuals having an empty paragraph before the first .SH, for example OpenBSD c++filt(1).
* Get rid of HAVE_CONFIG_H, it is always defined; idea from libnbcompat.Ingo Schwarze2014-08-101-2/+2
| | | | | | 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.
* Improve handling of next-line scope broken by end of file.Ingo Schwarze2014-07-301-7/+29
| | | | | | Detect the condition earlier, report in the error message which block is broken, and delete the broken block. Consequently, empty section headers can no longer happen.
* garbage collect three unused global flags; no functional changeIngo Schwarze2014-07-301-7/+0
|
* delete forgotten, obsolete rew_warn() prototypeIngo Schwarze2014-07-091-2/+0
|
* Clean up ERROR messages related to document structure and macros:Ingo Schwarze2014-07-071-2/+3
| | | | Hierarchical naming and mention macro names in messages.
* Simplify man_unscope(), removing 18 lines of code, that is,Ingo Schwarze2014-07-071-45/+21
| | | | | | removing one function argument, one function definition, three function invocations and two pointless assert()s. No functional change.
* KNF: case (FOO): -> case FOO:, remove /* LINTED */ and /* ARGSUSED */,Ingo Schwarze2014-04-201-36/+22
| | | | | remove trailing whitespace and blanks before tabs, improve some indenting; no functional change
* Implement the roff(7) .ll (line length) request.Ingo Schwarze2014-03-301-0/+1
| | | | | Found by naddy@ in the textproc/enchant(1) port. Of course, do not use this in new manuals.
* Simplify: Remove an unused argument from the mandoc_eos() function.Ingo Schwarze2013-12-311-1/+1
| | | | No functional change.
* s/[Nn]ull/NUL/ in comments where appropriate;Ingo Schwarze2013-12-251-0/+1
| | | | suggested by Thomas Klausner <wiz @ NetBSD dot org>.
* Implement end-of-sentence spacing at the end of man(7) macro lines.Ingo Schwarze2013-12-221-0/+9
| | | | Patch from Franco Fichtner <franco at lastsummer dot de> (DragonFly).
* In the parser, when closing an explicit block that is not open,Ingo Schwarze2013-11-111-4/+6
| | | | | | | | close below-subsection implicit scopes that may still be open. In the formatter, make sure indentation is reset when leaving a scope, not only when entering the next one. Improves the formatting of gpg(1); issue reported by jca on ports.
* Implement the .UR/.UE block (uniform resource identifier) introduced in theIngo Schwarze2013-10-171-0/+5
| | | | | | | | man-ext macros by Eric S. Raymond, enabled by default in groff_man(7). Usual disclaimer: You don't write new man(7) code, so you are not going to use these, either. Improves e.g. the bzr(1) and etherape(1) manuals. Thanks to naddy@ for bringing these to my attention.
* Cleanup naming of local variables to make the code easier on the eye:Ingo Schwarze2012-11-171-60/+60
| | | | | | | | Settle for "struct man *man", "struct mdoc *mdoc", "struct meta *meta" and avoid the confusing "*m" which was sometimes this, sometimes that. No functional change. ok kristaps@ some time ago
* Fix an assert() raised by `RS' when following `TP'.Kristaps Dzonsons2012-06-121-1/+1
| | | | | | The reason was that `RS' wasn't BSCOPE'd, so the next-line (BLINE) scope opened by `TP' would still be in the HEAD macro. This was from joerg@'s archive of failures.
* Close a preceding implicit block before opening an explicit block.Ingo Schwarze2012-06-031-16/+28
| | | | | | | | To allow doing so, no longer abuse rew_scope() to unwind explicit blocks; explicitly call man_unscope() instead. Fixing the indentation of slapd.conf(5) in the OpenLDAP port; thanks to guenther@ for the report.
* Minimal implementation of .EX and .EE for GNU compatibility.Ingo Schwarze2012-06-021-0/+2
| | | | | Do not use this, it is not portable and only defined in esr's man-ext. For example, sox(1) wants these macros.
* Add support for `OP', one of the extended man macros. This also requiresKristaps Dzonsons2012-01-031-0/+1
| | | | some man(7) changes to accomodate for the an-ext compatibility.
* Jumping out of man_unscope() for the root node is a bad ideaIngo Schwarze2011-12-041-2/+0
| | | | | | | | because that will skip root node validation, potentially entering rendering modules will NULL pointers lurking in the meta data. Instead, always validate the root node and (as suggested by joerg@) assert validity of the meta data before using it in the renderers. ok joerg@
* Fix condition. Not enough tea.Joerg Sonnenberger2011-11-181-1/+1
|
* Slightly adjust last: return successful as some times the correct errorJoerg Sonnenberger2011-11-181-1/+1
| | | | is raised later.
* Convert an assert into an explicit check. man_unscope can be triggeredJoerg Sonnenberger2011-11-181-1/+2
| | | | on unknown macros.
* When the HEAD scope of .TP is broken by another block macro,Ingo Schwarze2011-11-071-11/+11
| | | | | | | | do not abort with a FATAL error, but report a report a WARNING, remove the broken .TP from the syntax tree, and prod on. Reported repeatedly by ports people, at least by brad@ and jeremy@. Also fixes rendition(4) in Xenocara. ok kristaps@
* forgotten Copyright bumps; no code changeIngo Schwarze2011-09-181-1/+1
| | | | found while syncing to OpenBSD