summaryrefslogtreecommitdiffstats
path: root/mdoc_macro.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Multiple fixes with respect to .Pf:Ingo Schwarze2014-11-301-6/+16
| | | | | | | * 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-8/+16
| | | | inspired by a similar warning in the groff_mdoc(7) macros
* Reduce code duplication by reusing the same argument parserIngo Schwarze2014-11-291-18/+20
| | | | | 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-115/+62
| | | | | | | | | | 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-46/+4
| | | | | | 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-198/+116
| | | | no functional change, minus 50 lines of code.
* Simplify the code by making various mdoc parser helper functions void.Ingo Schwarze2014-11-281-375/+233
| | | | No functional change, minus 130 lines of code.
* Simplify code by making mdoc validation handlers void.Ingo Schwarze2014-11-281-52/+44
| | | | No functional change, minus 90 lines of code.
* Multiple fixes with respect to .Eo:Ingo Schwarze2014-11-271-7/+27
| | | | | | | | 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-1/+1
| | | | 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-1/+3
| | | | | 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-1/+4
| | | | | 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-24/+50
| | | | | | | | | | * .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-2/+2
|
* Right after .Fl, a middle delimiter triggers an empty scope,Ingo Schwarze2014-08-211-13/+12
| | | | | | | | | | | | 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-1/+2
| | | | | | | 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-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.
* mention requests and macros in more messagesIngo Schwarze2014-08-011-1/+1
|
* Get rid of the useless FATAL error "child violates parent syntax".Ingo Schwarze2014-07-301-0/+18
| | | | | 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-5/+9
| | | | Hierarchical naming and mention macro names in messages.
* Clean up messages regarding excess arguments:Ingo Schwarze2014-07-041-5/+6
| | | | | | * 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-3/+5
| | | | in particular reporting the macro names involved.
* Clean up warnings related to macros and nesting.Ingo Schwarze2014-07-021-13/+4
| | | | | | | * 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-2/+2
| | | | | 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-13/+6
| | | | | 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-152/+129
| | | | | 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.
* Treat the line after .Cd as a single argument.Ingo Schwarze2014-01-211-1/+1
| | | | | 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-1/+1
| | | | | 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-1/+1
| | | | No functional change.
* Do not trigger end-of-sentence spacing by trailing punctuationIngo Schwarze2013-12-311-19/+0
| | | | | | | | | | | | | | | | | | | | 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-2/+1
| | | | | | 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-0/+5
| | | | | | | | 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-98/+139
| | | | | | | | | | | | | | | 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.
* Block closing macros do not allocate a new node but finish an existingIngo Schwarze2013-09-151-0/+3
| | | | | | | | | | one, so they miss the clearing of MDOC_NEWLINE in mdoc.c, node_alloc(). Consequently, MDOC_NEWLINE must be cleared before processing the next macro on the same line. This fixes horizontal spacing for input lines beginning like .Oc Ns ... Issue found by Franco Fichtner <franco at lastsummer dot de> while working on DragonFly mandoc integration.
* Do not crash on stray .Ta macros found outside column lists.Ingo Schwarze2012-11-191-4/+10
| | | | Problem reported by jmc@, thanks.
* Fix four small whitespace issues related to trailing punctuationIngo Schwarze2012-11-181-1/+2
| | | | | | | | | reported by Nicolas Joly <njoly at pasteur dot fr>: - add EOS spacing after trailing punctuation after .Cd, .Fc, and .Lb - suppress spacing before trailing punctuation after .Fd Add the remaining issues from the same report to the TODO file.
* Cleanup naming of local variables to make the code easier on the eye:Ingo Schwarze2012-11-171-175/+180
| | | | | | | | 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 a crash triggered by .Bl -tag .It Xo .El .Sh found by florian@.Ingo Schwarze2012-11-161-1/+1
| | | | | | | | | | | | | | | * When allocating a body end marker, copy the pointer to the normalized block information from the body block, avoiding the risk of subsequent null pointer derefence. * When inserting the body end marker into the syntax tree, do not try to copy that pointer from the parent block, because not being a direkt child of the block it belongs to is the whole point of a body end marker. * Even non-callable blocks (like Bd and Bl) can break other blocks; when this happens, postpone closing them out in the usual way. Completed and tested at the OpenBSD impromptu Coimbra hackathon (c2k12). Thanks to Pedro Almeida and the Laborat'orio de Computa,c~ao Avan,cada da Universidade de Coimbra (http://www.uc.pt/lca) for their hospitality!
* Let a trailing .Ns macro take effectIngo Schwarze2012-07-181-1/+8
| | | | | | | | even on an input line containing a partial implicit macro. Fixes horizontal spacing in vi(1), ddb(4), and ppp(8). OpenBSD rev. 1.74.
* update Copyright years according to the CVS logs; no code changeIngo Schwarze2012-05-271-1/+1
|
* Fix previous such that all .It HEADs are unparsed,Ingo Schwarze2012-01-051-10/+8
| | | | | | | not just the first one in each -diag list. While here, drop the needless if-statement and choose a more precise wording for the comment. ok kristaps@
* `-diag' lists aren't parsed, unlike other list types. This fixes a TODOKristaps Dzonsons2012-01-021-3/+13
| | | | entry raised by deraadt@.
* Remove an OpenBSD-specific tweak regarding .Xr spacing and make itIngo Schwarze2011-12-031-16/+0
| | | | | | | compatible with groff-1.21. This tweak was originally added for compatibility with groff-1.15, which is no longer needed. ok jmc@ kristaps@
* Remove a bunch of useless assignments,Ingo Schwarze2011-10-161-4/+1
| | | | | | | and assert that print_bvspace cannot be called on NULL pointers. No change in behaviour, none of these were bugs, but the code becomes easier to understand. Based on a clang report posted by joerg@; ok kristaps@.
* forgotten Copyright bumps; no code changeIngo Schwarze2011-09-181-1/+1
| | | | found while syncing to OpenBSD
* Allow `Sx' and `Ss' to have child nodes. Fixes manuals in NetBSD.Kristaps Dzonsons2011-08-101-2/+2
| | | | | | Originally pointed out by joerg@ then again by Thomas Klausner by way of Nicolas Joy. Note: don't use these constructions as you can't link to the sections with `Sx'.
* No code change: fixing spelling errors. From a patch by uqs@. Thanks!Kristaps Dzonsons2011-04-301-4/+4
|
* Closing delimiters only suppress spacing when they follow something.Ingo Schwarze2011-04-251-1/+13
| | | | | Fixing a regression introduced in rev. 1.105. ok and prodding for comments kristaps@.
* Clean up parsing of delimiters in -mdoc. First, remove the "dowarn"Kristaps Dzonsons2011-04-191-3/+3
| | | | | | | | variable from mandoc_getarg() so that it prints the warning every time. Then, remove the warning from args_checkpunct(). This way, warnings are being posted at the correct time. This makes the flag argument to mdoc_zargs() superfluous, so make it be zero when it's invoked. Finally, move the args() flags into mdoc_argv.c and make them enums.