summaryrefslogtreecommitdiffstats
path: root/man_macro.c
Commit message (Collapse)AuthorAgeFilesLines
* Element next-line scopes can nest. Consequently, even when closingIngo Schwarze2020-09-091-5/+7
| | | | | | | | one element next-line scope, the MAN_ELINE flag must not yet be cleared if the parent macro is another element macro having next-line scope, or an assertion failure is caused if all this is wrapped in another macro that has block next-line scope, for example .TP. Bug found in an afl run performed by Jan Schreiber <jes at posteo dot de>.
* In HTML output, man(7) .RS blocks get formatted as <div class="Bd-indent">,Ingo Schwarze2019-01-051-1/+4
| | | | | | | | | and i can see no reasonable alternative: they do indeed represent indented displays. They certainly require flow context and make no sense in phrasing context. Consequently, they have to suspend no-fill mode during their head, in just the same way as other paragraph-type macros do it. This fixes HTML syntax errors that resulted from .nf followed by .RS.
* Some high-level block macros have an effect similar to temporarilyIngo Schwarze2019-01-051-1/+3
| | | | | | | | | | | | suspending no-fill mode during their head. Model this with an additional roff parser state flag ROFF_NONOFILL. That is much simpler than it would be to save and restore the ROFF_NOFILL flag itself, in particular since the latter can be switched (with lasting effect) by the .nf and .fi requests even while its effect is temporarily suspended. This commit does not change formatting yet, but prepares for future formatting simplifications and improvements.
* Cleanup, no functional change:Ingo Schwarze2018-12-311-1/+1
| | | | | | Since the man(7) and roff(7) validators no longer use the parser state flag ROFF_NOFILL, we can finally get rid of the function man_state(), resulting in a better separation of parsing and validation.
* For .EX and .EE, set the fill mode parser state directly in theIngo Schwarze2018-12-311-0/+5
| | | | | | macro parsing function, in the same way as the roff parser already does it for the .nf and .fi requests. This is a preparation for getting rid of the ugly function man_state() later on.
* Move parsing of the .nf and .fi (fill mode) requests from the man(7)Ingo Schwarze2018-12-311-10/+3
| | | | | | parser to the roff(7) parser. As a side effect, .nf and .fi are now also parsed in mdoc(7) input, though the mdoc(7) formatters still ignore most of their effect.
* Cleanup, minus 15 LOC, no functional change:Ingo Schwarze2018-12-311-2/+0
| | | | | | | | | Simplify the way the man(7) and mdoc(7) validators are called. Reset the parser state with a common function before calling them. There is no need to again reset the parser state afterwards, the parsers are no longer used after validation. This allows getting rid of man_node_validate() and mdoc_node_validate() as separate functions.
* Cleanup, no functional change:Ingo Schwarze2018-12-301-1/+1
| | | | | | | | | | | | | | The struct roff_man used to be a bad mixture of internal parser state and public parsing results. Move the public results to the parsing result struct roff_meta, which is already public. Move the rest of struct roff_man to the parser-internal header roff_int.h. Since the validators need access to the parser state, call them from the top level parser during mparse_result() rather than from the main programs, also reducing code duplication. This keeps parser internal state out of thee main programs (five in mandoc portable) and out of eight formatters.
* Rename mandoc_getarg() to roff_getarg() and pass it the roff parserIngo Schwarze2018-12-211-6/+12
| | | | | | | | | | | | | | | | | | struct as an argument such that after copy-in, it can call roff_expand() once again, which used to be called roff_res() before this. This fixes a subtle low-level roff(7) parsing bug reported by Fabio Scotoni <fabio at esse dot ch> in the 4.4BSD-Lite2 mdoc.samples(7) manual page, because that page used an escaped escape sequence in a macro argument. To expand escaped escape sequences in quoted mdoc(7) arguments, too, stop bypassing the call to roff_getarg() in mdoc_argv.c, function args() for this case. This does not solve the case of escaped escape sequences in quoted .Bl -column phrases yet. Because roff_expand() can make the string longer, roff_getarg() can no longer operate in-place but needs to malloc(3) the returned string. In the high-level parsers, free(3) that string after processing it.
* Cleanup, no functional change:Ingo Schwarze2018-12-141-1/+1
| | | | | | | | | | Now that message handling is properly encapsulated, remove struct mparse pointers from four structs (roff, roff_man, tbl_node, eqn_node) and from the argument lists of five functions (roff_alloc, roff_man_alloc, mandoc_getarg, tbl_alloc, eqn_alloc). Except for being passed to the main program as an opaque object, it now only occurs in read.c, as it should, and not across 15 files like in the past.
* Almost mechanical diff to remove the "struct mparse *" argumentIngo Schwarze2018-12-141-16/+14
| | | | | | | | from mandoc_msg(), where it is no longer used. While here, rename mandoc_vmsg() to mandoc_msg() and retire the old version: There is really no point in having another function merely to save "%s" in a few places. Minus 140 lines of code.
* Major cleanup; may imply minor changes in edge cases of error reporting.Ingo Schwarze2018-12-141-0/+1
| | | | | | | | | | | Finally, drop support for the run-time configurable mandocmsg() callback. It was over-engineered from the start, never used for anything in a decade, and repeatedly caused maintenance headaches. Consolidate reporting infrastructure into two files, mandoc.h and mandoc_msg.c, mopping up the bits and pieces that were scattered around main.c, read.c, mandoc_parse.h, libmandoc.h, the prototypes of four parsing-related functions, and both parser structs.
* Support nesting of elements with next-line scope.Ingo Schwarze2018-08-261-31/+36
| | | | For example, ksh93(1) needs this for .B\n.SM.
* paragraphs can contain .MT and .UR blocksIngo Schwarze2018-08-181-1/+2
|
* .RE causes a line break even if .RS is not openIngo Schwarze2018-08-181-0/+6
|
* end of sentence detection after .ME and .UE, useful for some GNU manualsIngo Schwarze2018-08-181-0/+2
|
* Two consecutive .SY blocks only get a blank line in betweenIngo Schwarze2018-08-181-1/+8
| | | | if the first one is explicitly closed with .YS.
* implement the GNU man-ext .SY/.YS (synopsis block) macro in man(7),Ingo Schwarze2018-08-181-0/+5
| | | | used in most manual pages of the groff package
* Remove more pointer arithmetic passing via regions outside the arrayIngo Schwarze2018-08-171-9/+15
| | | | | that is undefined according to the C standard. Robert Elz <kre at munnari dot oz dot au> pointed out i wasn't quite done yet.
* implement the GNU man-ext .TQ macro in man(7),Ingo Schwarze2018-08-161-1/+2
| | | | used for example by groff_diff(7)
* fix incomplete variable renaming in previous;Ingo Schwarze2018-08-151-1/+1
| | | | found by Thomas Klausner <wiz at NetBSD> via a compiler warning
* support tail arguments on the .ME and .UE macros,Ingo Schwarze2018-08-141-16/+23
| | | | used for example in the ditroff(7) manual of the groff package
* add support for the MT and ME mailto macros, used for example in wg(8);Ingo Schwarze2017-06-251-0/+5
| | | | patch from bentley@
* if .in is used inside the .TP head, it's always relativeIngo Schwarze2017-06-171-1/+1
|
* Partial support for the \n[an-margin] number register.Ingo Schwarze2017-06-131-1/+14
| | | | | | | | | | | | | | | Manuals autogenerated from reStructuredText are reckless enough to peek at this non-portable, implementation-dependent, highly groff-specific internal register - for no good reason, because the man(7) language natively provides in a much simpler way what they are trying to emulate here with much fragility. A full implementation would be very hard because it would require access to output-device-specific formatting data at the roff(7) preprocessor stage, which mandoc doesn't support at all. So hardcode a few magic numbers as reStructuredText expects them for terminal output. For other output modes (like HTML), code using this register is utterly broken anyway.
* Move .sp to the roff modules. Enough infrastructure is in placeIngo Schwarze2017-05-051-3/+1
| | | | now that this actually saves code: -70 LOC.
* move .ll to the roff modulesIngo Schwarze2017-05-051-1/+0
|
* Move handling of the roff(7) .ft request from the man(7)Ingo Schwarze2017-05-051-2/+1
| | | | | modules to the new roff(7) modules. As a side effect, mdoc(7) now handles .ft, too. Of course, do not use that.
* Parser reorg:Ingo Schwarze2017-05-041-3/+1
| | | | | Generate the first node on the roff level: .br Fix some column numbers in diagnostic messages while here.
* Continue parser unification:Ingo Schwarze2017-04-241-17/+14
| | | | | | | | * Make enum rofft an internal interface as enum roff_tok in "roff.h". * Represent mdoc and man macros in enum roff_tok. * Make TOKEN_NONE a proper enum value and use it throughout. * Put the prologue macros first in the macro tables. * Unify mdoc_macroname[] and man_macroname[] into roff_name[].
* unify names of AST node flags; no change of cpp outputIngo Schwarze2017-01-101-5/+5
|
* 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
|