aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_macro.c
Commit message (Collapse)AuthorAgeFilesLines
* Avoid closing out an explicit block twice when broken by .ItIngo Schwarze2015-02-031-1/+2
| | | | (assertion failure); regression found in jsg@'s afl test case 847.
* Finally delete the kitchensink functions rew_sub() and rew_dohalt().Ingo Schwarze2015-02-031-160/+75
| | | | | | | They were a maintenance and auditing nightmare because if you changed one bit in there, stuff tended to break at seemingly unrelated places. No functional change except getting rid of one bogus error message, but minus 80 lines of code.
* Bring .Pp/.Lp handling inside .Nm blocks closer to groff;Ingo Schwarze2015-02-031-4/+11
| | | | as a bonus, get rid of another call to rew_sub().
* Simplify and reindent make_pending(). No functional changeIngo Schwarze2015-02-021-57/+50
| | | | | | except that some error messages become less confusing. Now the function is almost readable (but still requires nineteen lines of comments for fourteen lines of code).
* Simplify: Do not call rew_dohalt() from make_pending(),Ingo Schwarze2015-02-021-31/+21
| | | | | the calling macro handler already found the breaking block. No functional change except tiny variations in error messages.
* Get rid of all remaining calls to rew_sub() where the target blockIngo Schwarze2015-02-021-66/+37
| | | | | is known. This only leaves three that do actual searching. No functional change, minus 30 lines of code.
* Get rid of all calls to rew_sub() in blk_exp_close(); only ten callsIngo Schwarze2015-02-021-65/+67
| | | | | | remain in other functions. As a bonus, this fixes an assertion failure jsg@ found some time ago with afl (test case 982) and improves minor details in error reporting.
* When a full block macro gets closed out by a mismatchingIngo Schwarze2015-02-021-4/+7
| | | | | | | | | block closure macro it calls, do not attempt to open its body. This can for example happen for (nonsensical) constructions like .Fo .Nm Fc in the SYNOPSIS. Fixing an assertion failure jsg@ found with afl some time ago (test case number 731).
* get rid of rew_sub() in blk_part_imp(); no functional changeIngo Schwarze2015-02-011-3/+14
|
* Simplify blk_part_exp(), no functional change.Ingo Schwarze2015-02-011-24/+8
| | | | | | * Replace calls to rew_sub() with rew_last() - two less out of 18. * No need to keep track of the body, it's always opened right after the head and never used for anything in this function.
* The function rew_sub() tries to rewind any all all kinds of blocksIngo Schwarze2015-02-011-5/+4
| | | | | | | | | | and elements under any and all circumstances, even handling some bad block nesting now and then. Little surprisingly, this ends up in excessive complexity and has caused many bugs in the past. Start to slowly disentangle this mess by replacing calls to rew_sub() immediately following mdoc_head_alloc() by the much simpler rew_last(). Gets rid of the first two rew_sub() calls out of twenty. No functional change.
* The code already pays attention not to close the same block twice.Ingo Schwarze2014-12-221-3/+3
| | | | | | | Similarly, avoid having the same block break two other blocks. In some situations, this could lead to an endless loop in rew_sub() found by jsg@ with afl. Minimal example: .Po Ao Pc Bo Pc Ac Bc
* Fix two issues causing a class of assertion failures found by jsg@ with afl.Ingo Schwarze2014-12-201-9/+20
| | | | | | | | 1) rew_sub(): Make sure REWIND_MORE is acted upon even when followed by REWIND_NONE. This prevents .It from ending up inside other children of .Bl. 2) blk_exp_close(): Only allow extension of .Bl when it has at least one .It. Otherwise, a broken child block could be moved in front of the .Bl, effectively resulting in a .Bl that ended before it began.
* Don't let .Ta creep into an already-closed list; same as for .It.Ingo Schwarze2014-12-181-2/+3
| | | | Fixes an assertion found by jsg@ with afl.
* The code is already careful to not add items to lists that wereIngo Schwarze2014-12-181-21/+32
| | | | | | | already closed. In this respect, also consider lists closed that have broken another block, their closure pending until the end of the broken block. This avoids syntax tree corruption leading to a NULL pointer access found by jsg@ with afl.
* Fix a regression found by Carsten dot Kunze at arcor dot de:Ingo Schwarze2014-12-131-5/+3
| | | | Do not show bogus quotes when .Bl -column phrases are quoted.
* Multiple fixes with respect to .Pf:Ingo Schwarze2014-11-301-7/+17
| | | | | | | * 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.
* warn about attempts to call non-callable macros;Ingo Schwarze2014-11-301-9/+17
| | | | inspired by a similar warning in the groff_mdoc(7) macros
* Reduce code duplication by reusing the same argument parserIngo Schwarze2014-11-291-19/+21
| | | | | for in_line_eoln() macros and .Bl -column phrases. No functional change.
* Provide a helper function macro_or_word() and use it to prune theIngo Schwarze2014-11-291-116/+63
| | | | | | | | | | same chunk of argument parsing code out of five of the eight callback functions. The other three have too much special handling to participate. As a bonus, let lookup() and mdoc_args() deal with line macros and retire the lookup_raw() helper and the mdoc_zargs() internal interface function. No functional change, minus 40 lines of code.
* Fold the loop around mdoc_argv() into the function itself,Ingo Schwarze2014-11-281-47/+5
| | | | | | it was the same in all four cases. As a bonus, get rid of one enum type that was used for internal communication. No functional change, minus 40 lines of code.
* Simplify by making the mdoc parser callbacks void, and some cleanup;Ingo Schwarze2014-11-281-199/+117
| | | | no functional change, minus 50 lines of code.
* Simplify the code by making various mdoc parser helper functions void.Ingo Schwarze2014-11-281-376/+234
| | | | No functional change, minus 130 lines of code.
* Simplify code by making mdoc validation handlers void.Ingo Schwarze2014-11-281-53/+45
| | | | No functional change, minus 90 lines of code.
* Multiple fixes with respect to .Eo:Ingo Schwarze2014-11-271-8/+28
| | | | | | | | 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.
* The .Sm macro accepts at most one argument;Ingo Schwarze2014-11-261-2/+2
| | | | fixing an assertion failure found by jsg@ with afl.
* Do not access a NULL pointer when a section has no body,Ingo Schwarze2014-11-251-2/+4
| | | | | which can for example happen for .Sh Xo .Sh without .Xc. Crash found by jsg@ with afl.
* Fix two minibugs reported by Thomas Klausner <wiz at NetBSD>:Ingo Schwarze2014-11-201-2/+5
| | | | | 1. The first argument of .Fn is not supposed to be parsed. 2. The .Fn macro is not supposed to reopen its scope after punctuation.
* Multiple fixes with respect to in-line macros:Ingo Schwarze2014-11-171-25/+51
| | | | | | | | | | * .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@.
* Allow .ll in the prologue; Daniel Levai reports Slackware Linux uses this.Ingo Schwarze2014-09-071-3/+3
|
* Right after .Fl, a middle delimiter triggers an empty scope,Ingo Schwarze2014-08-211-14/+13
| | | | | | | | | | | | 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@.
* If a stray .It follows .El, we are no longer in the list,Ingo Schwarze2014-08-161-2/+3
| | | | | | | even though the list is still the last processed macro. This fixes a regression introduced in mdoc_macro.c rev. 1.138: Ulrich Spoerlein <uqs at FreeBSD> reports that various of their kernel manuals trigger assertions.
* Get rid of HAVE_CONFIG_H, it is always defined; idea from libnbcompat.Ingo Schwarze2014-08-101-3/+3
| | | | | | 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.
* mention requests and macros in more messagesIngo Schwarze2014-08-011-2/+2
|
* Get rid of the useless FATAL error "child violates parent syntax".Ingo Schwarze2014-07-301-1/+19
| | | | | When finding items outside lists, simply skip them and throw an ERROR. Handle subsections before the first section instead of bailing out.
* Clean up ERROR messages related to document structure and macros:Ingo Schwarze2014-07-071-6/+10
| | | | Hierarchical naming and mention macro names in messages.
* Clean up messages regarding excess arguments:Ingo Schwarze2014-07-041-6/+7
| | | | | | * Downgrade ".Bf -emphasis Em" from FATAL to WARNING. * Mention the macros, the arguments, and the fallbacks. * Hierarchical naming.
* Improve and test the messages about empty macros,Ingo Schwarze2014-07-021-4/+6
| | | | in particular reporting the macro names involved.
* Clean up warnings related to macros and nesting.Ingo Schwarze2014-07-021-14/+5
| | | | | | | * Hierarchical naming of enum mandocerr items. * Improve the wording to make it comprehensible. * Mention the offending macro. * Garbage collect one chunk of ancient, long unreachable code.
* Fix the column numbers associated with in_line_argn() macros;Ingo Schwarze2014-07-021-3/+3
| | | | | this bug is more than four years old, introduced by kristaps@ in mdocml.bsd.lv rev. 1.46, March 30, 2010.
* Implement the obsolete macros .En .Es .Fr .Ot for backward compatibility,Ingo Schwarze2014-07-021-14/+7
| | | | | since this is hardly more complicated than explicitly ignoring them as we did in the past. Of course, do not use them!
* KNF: case (FOO): -> case FOO:, remove /* LINTED */ and /* ARGSUSED */,Ingo Schwarze2014-04-201-153/+130
| | | | | 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-1/+2
| | | | | Found by naddy@ in the textproc/enchant(1) port. Of course, do not use this in new manuals.
* Treat the line after .Cd as a single argument.Ingo Schwarze2014-01-211-2/+2
| | | | | This doesn't hurt normal manual display and makes the mandocdb(8) database more useful.
* Keep words after .Ic together in a single argument.Ingo Schwarze2014-01-201-2/+2
| | | | | This doesn't hurt normal manual display and makes the mandocdb(8) database more useful.
* Simplify: Remove an unused argument from the mandoc_eos() function.Ingo Schwarze2013-12-311-2/+2
| | | | No functional change.
* Do not trigger end-of-sentence spacing by trailing punctuationIngo Schwarze2013-12-311-20/+1
| | | | | | | | | | | | | | | | | | | | at the end of partial implicit macros. Prodded by jmc@. Actually, this is a revert of rev. 1.64 Fri May 14 14:09:13 2010 UTC by kristaps@, with this original commit message: "Block-implicit macros now up-propogate end-of-sentence spacing. NOTE: GROFF IS NOT SMART ENOUGH TO DO THIS." Please speak after me: Then why the hell should we? We already weakened this in rev. 1.93 Sun Jul 18 17:00:26 2010 UTC, but that weakening was insufficient. Let's take it out completely. Admittedly, there are two places in OpenBSD base where what Kristaps did make the output nicer, in calloc(3) and in fish(6). But both are atypical. There are 18 other places where this revert makes the output nicer, the typical case being: "Mail status is shown as ``No Mail.'' if there is no mail." You do *not* want the EOS spacing after ``No Mail.'' in that sentence.
* It turns out SYNOPSIS mode does not imply .Bk in general,Ingo Schwarze2013-12-241-3/+2
| | | | | | but only within .Nm blocks. Simplify the code accordingly. Triggered by research done by Franco Fichtner.
* When deciding whether two consecutive macros are on the same input line,Ingo Schwarze2013-12-241-1/+6
| | | | | | | | we have to compare the line where the first one *ends* (not where it begins) to the line where the second one starts. This fixes the bug that .Bk allowed output line breaks right after block macros spanning more than one input line, even when the next macro follows on the same line.
* There are three kinds of input lines: text lines, macros takingIngo Schwarze2013-10-211-99/+140
| | | | | | | | | | | | | | | positional arguments (like Dt Fn Xr) and macros taking text as arguments (like Nd Sh Em %T An). In the past, even the latter put each word of their arguments into its own MDOC_TEXT node; instead, concatenate arguments unless delimiters, keeps or spacing mode prevent that. Regarding mandoc(1), this is internal refactoring, no output change intended. Regarding mandocdb(8), this fixes yet another regression introduced when switching from DB to SQLite: The ability to search for strings crossing word boundaries was lost and is hereby restored. At the same time, database sizes and build times are both reduced by a bit more than 5% each.