summaryrefslogtreecommitdiffstats
path: root/usr.bin/mandoc/mdoc_macro.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* Clean up warnings related to macros and nesting.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;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,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 */,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.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.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.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.schwarze2013-12-301-2/+2
| | | | No functional change.
* Do not trigger end-of-sentence spacing by trailing punctuationschwarze2013-12-301-20/+1
| | | | | | | | | | | | | | | | | | | | | at the end of partial implicit macros. Prodded by jmc@. Actually, this is a revert of rev. 1.39 Sat May 15 09:20:01 2010 UTC, which in turn is mdocml.bsd.lv 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.55 Fri Jul 16 00:34:33 2010 UTC, but that weakening was insufficient. Let's take it out completely. Admittedly, there are two places in base where what Kristaps did made 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,schwarze2013-12-241-3/+2
| | | | | | | but only within .Nm blocks. Simplify the code accordingly. This reduces groff-mandoc differences in base by about 2%. Triggered by research done by Franco Fichtner.
* When deciding whether two consecutive macros are on the same input line,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 takingschwarze2013-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. Once we will switch mandocdb(8) from DB to SQLite in the future, this is going to be required to support search expressions crossing word boundaries, and it will reduce both database sizes and build times by a bit more than 5% each.
* Block closing macros do not allocate a new node but finish an existingschwarze2013-09-151-1/+4
| | | | | | | | | | 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.schwarze2012-11-191-5/+11
| | | | Problem reported by jmc@, thanks.
* Fix four small whitespace issues related to trailing punctuationschwarze2012-11-181-2/+3
| | | | | | | 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
* Cleanup naming of local variables to make the code easier on the eye:schwarze2012-11-171-176/+181
| | | | | | | | 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@.schwarze2012-11-161-2/+2
| | | | | | | | | | | * 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.
* Let a trailing .Ns macro take effectschwarze2012-07-181-3/+10
| | | | | | even on an input line containing a partial implicit macro. Fixes horizontal spacing in vi(1), ddb(4), and ppp(8).
* Heads of .It macros in -diag lists are not parsed,schwarze2012-01-041-4/+12
| | | | | | | even though .It macros in general are parsed. Fixing a bug reported by deraadt@, based on an incomplete fix by kristaps@, and update the test suite to catch this issue.
* Remove an OpenBSD-specific tweak regarding .Xr spacingschwarze2011-12-031-14/+1
| | | | | | | | and make it compatible with bsd.lv mandoc and with groff-1.21. This tweak was originally added for compatibility with groff-1.15, which is no longer needed. ok jmc@ kristaps@
* remove useless "#ifdef __linux__" that crept in,schwarze2011-12-031-1/+12
| | | | and trivial sync to bsd.lv (two new comments)
* Remove a bunch of useless assignments,schwarze2011-10-161-5/+2
| | | | | | | 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@.
* sync to version 1.11.7 from kristaps@schwarze2011-09-181-3/+3
| | | | | | | | main new feature: support the roff(7) .tr request plus various bugfixes and some refactoring regressions are so minor that it's better to get this in and fix them in the tree
* Merge release 1.11.3, almost all code by kristaps@:schwarze2011-05-291-8/+8
| | | | | | | | | * Unicode output support (no Unicode input yet, though). * Refactoring: completely handle predefined strings in roff.c. - New function mandoc_escape() replaces a2roffdeco() and mandoc_special(). - Start using mandoc_getarg() in mdoc_argv.c. - Clean up parsing of delimiters in mdoc(7). * And many minor fixes and lots of cleanup.
* Closing delimiters only suppress spacing when they follow something.schwarze2011-04-241-2/+3
| | | | Fixing a regression introduced in bsd.lv rev. 1.105.
* Merge version 1.11.1:schwarze2011-04-241-32/+57
| | | | | | | | | | | | | | Again lots of cleanup and maintenance work by kristaps@. - simplify error reporting: less function pointers, more mandoc_[v]msg - main: split document parsing out of main.c into read.c - roff, mdoc, man: improved recognition of control characters - roff: better handling of if/else stack overflows - roff: add some predefined strings for backward compatibility - mdoc, man: empty sections are not errors - mdoc: move delimiter handling to libmdoc - some header restructuring and some minor features and fixes This merge causes two minor regressions that i will fix in separate commits right afterwards.
* Merge version 1.10.10:schwarze2011-04-211-18/+17
| | | | | | | | | | lots of cleanup and maintenance work by kristaps@. - move some main.c globals into struct curparse - move mandoc_*alloc to mandoc.h such that all code can use them - make mandoc_isdelim available to formatting frontends - dissolve mdoc_strings.c, move the code where it is used - make all error reporting functions void, their return values were useless - and various minor cleanups and fixes
* Make .Bx accept not more than two arguments.schwarze2011-01-301-2/+4
| | | | | | | Convert the first character of the second argument to uppercase. Append the second argument with a hyphen. Improves chpass(1), column(1), fstat(1), ... from kristaps@
* Some improvements to error handling from kristaps@:schwarze2011-01-161-3/+10
| | | | | | | * Make out-of-context .fi invocations not cause an error, but just a warning. * Downgrade -man message about ignored empty paragraph to MANDOC_IGNPAR. * Avoid syntax tree corruption when removing empty block macros. Triggered by some reports from brad@.
* Merge kristaps@' cleaner tbl integration, removing mine;schwarze2011-01-041-5/+1
| | | | there are still a few bugs, but fixing these will be easier in tree.
* Vertical spacing improvements from kristaps@, small tweaks by me:schwarze2010-12-211-1/+4
| | | | | | | Add a "last child" member to struct mdoc_node. Remove .Pp or .Lp if it is the first or last child of an .Sh or .Ss body. Thus, no need to do the same in the front-ends any longer. Tolerate some cases of .Pp inside .Bl.
* Merge mdoc_action.c into mdoc_validate.c, because having two places to doschwarze2010-12-011-12/+4
| | | | | | basically the same things just causes code duplication and confusion. Work by kristaps@, including a few bugfixes he found during the merge, and reapplying OpenBSD changes on top.
* Do not throw FATAL errors when there is no need to:schwarze2010-10-241-22/+22
| | | | | | | | - when encountering nested displays (.Bd containing .Bd, .D1, .D1) - when a block end macro was forgotten - when ending a block that was never started - when the uname(3) system call failed along with a little related cleanup
* Support tbl(1) code embedded into mdoc(7) input files.schwarze2010-10-161-1/+5
| | | | | | Very similar to what i have done in man(7) yesterday. Allows to build cpu(4) on HPPA, wi(4), and phantasia(6). Now we are able to build all tbl code in base.
* * need a space before .No even if it starts with a closing delimiterschwarze2010-10-011-3/+3
| | | | | | | * slightly simplify .Pf *_IGNDELIM code, and share part of it with .No * do not let opening delimiters fall out of the front of .Ns (from kristaps@) This fixes a few spacing issues in csh(1) and ksh(1). OK kristaps@
* If an explicit scope is still open at the end of an input file,schwarze2010-09-261-9/+5
| | | | | | | | | | | report an ERROR: We can still render the page by just closing the open scope, but it is likely that information will be missing or document structure mangled. Before, man(7) only reported a WARNING (which is dangerous because we cannot be sure rendering is correct) and mdoc(7) ran into FATAL (which is too drastic, there is no reason not to show what we have). While here, add a few explicit casts to appease lint. "looks good" kristaps@
* Text ending in a full stop, exclamation mark or question markschwarze2010-07-161-3/+3
| | | | | | | | | | | | | | | | | | should not flag the end of a sentence if: 1) The punctuation is followed by closing delimiters and not preceded by alphanumeric characters, like in "There is no full stop (.) in this sentence" or 2) The punctuation is a child of a macro and not preceded by alphanumeric characters, like in "There is no full stop .Pq \&. in this sentence" jmc@ and sobrado@ like this
* Merge release 1.10.4 (all code by kristaps@), providing four new features:schwarze2010-07-131-5/+8
| | | | | | | | | | 1) Proper .Bk support: allow output line breaks at input line breaks, but keep input lines together in the output, finally fixing synopses like aucat(1), mail(1) and tmux(1). 2) Mostly finished -Tps (PostScript) output. 3) Implement -Thtml output for .Nm blocks and .Bk -words. 4) Allow iterative interpolation of user-defined roff(7) strings. Also contains some minor bugfixes and some performance improvements.
* In the mdoc(7) parser, inspect roff registers early such that all partsschwarze2010-07-011-2/+5
| | | | | | | | | | | | of the parser can use the resulting cues. In particular, this allows to use .nr nS to force SYNOPSIS-style .Nm indentation outside the SYNOPSIS as needed by ifconfig(8). To actually make this useable, .Pp must rewind .Nm, or the rest of the section would end up indented. Implement a quick hack for now, a generic solution can be designed later. ok kristaps@ sobrado@
* Correct handling of trailing punctuation in MDOC_DELIM blk_full HEADs.schwarze2010-07-011-1/+4
| | | | | | | The bug was uncovered by SYNOPSIS .Nm as this happened to be the first block with this particular combination of properties. Found the hard way by kristaps@ in NetBSD gcc-contrib(1), fix by me.
* Improve .Nm indentation in the SYNOPSIS;schwarze2010-07-011-11/+20
| | | | | | | kristaps@ will do the missing HTML part soon. "looks nicer" jmc@ "seems perfect to me" sobrado@ "slap it in" kristaps@
* Closing of full blocks (Bd Bf Bk Bl It Fo Nd Rs Sh Ss) may never beschwarze2010-06-301-4/+43
| | | | | | | | | | delayed: It must either succeed right away or fail outright. As noticed by Kristaps, neglecting to fail properly when required could make invalid input screw up the syntax tree and ultimately trigger assertions in other, unrelated parts of the program. This fix tested by and OK by kristaps@. While here, comment the rather tricky function rew_dohalt(). This function will probably need more tweaks later on.
* fix a typo in the function declaration;schwarze2010-06-291-2/+2
| | | | | seems like gcc3 didn't catch it :-( thanks to thib@ and kristaps@ for reporting
* Considerably simplify block rewind rules; no functional change intended.schwarze2010-06-291-207/+70
| | | | | | | | | | * Let rew_alt() always succeed, obsoleting tons of case statements. * Merge rew_dobreak() into rew_dohalt(). * Encode all rewinding cases uniformly in terms of "enum rew". Required because i'm too dumb to get SYNOPSIS .Nm rewinding right without cleaning this up first. "get it in" kristaps@
* Support for badly nested blocks, written around the time ofschwarze2010-06-291-71/+195
| | | | | | | | | | | | | | | | | | | | | | | | | the Rostock mandoc hackathon and tested and polished since, supporting constructs like: .Ao Bo Ac Bc (exp breaking exp) .Aq Bo eol Bc (imp breaking exp) .Ao Bq Ac eol (exp breaking imp) .Ao Bo So Bc Ac Sc (double break, inner before outer) .Ao Bo So Ac Bc Sc (double break, outer before inner) .Ao Bo Ac So Bc Sc (broken breaker) .Ao Bo So Bc Do Ac Sc Dc (broken double breaker) There are still two known issues which are tricky: 1) Breaking two identical explicit blocks (Ao Bo Bo Ac or Aq Bo Bo eol) fails outright, triggering a bogus syntax error. 2) Breaking a block by two identical explicit blocks (Ao Ao Bo Ac Ac Bc or Ao Ao Bq Ac Ac eol) still has a minor rendering error left: "<ao1 <ao2 [bo ac2> ac1> bc]>" should not have the final ">". We can fix these later in the tree, let's not grow this diff too large. "get it in" kristaps@
* Merge bsd.lv version 1.10.1 (to be released soon).schwarze2010-06-061-34/+125
| | | | | | | | | | | | | | | | | | | | The main step forward is that this now has *much* better .Bl -column support, now supporting many manuals that previously errored out without producing any output. Other fixes include: * do not die from multiple list types, use the first and warn * in .Bl without a type, default to -item * various tweaks to .Dt * fix .In, .Fd, .Ft, .Fn and .Fo formatting * some documentation fixes and additions * and fix a couple of bugs reported by Ulrich Spoerlein: * better support for roff block-end "\}" without a preceding dot * .In must not break the line outside SYNOPSIS * spelling in some error messages While merging, fix one regression in .In spacing that needs to go to bsd.lv, too.
* Merge bsd.lv release 1.10.0,schwarze2010-06-061-13/+34
| | | | | | | | | | | | | | | | which is mostly the post-hackathon release, bringing in the OpenBSD changes to bsd.lv, but which also has a few additional minor fixes: * .Lb is an in-line macro, not in_line_eoln * .Bt, .Ud now warn when discarding arguments * allow bad -man dates to flow verbatim into the front-ends - so far all reported by Ulrich Spoerlein * .Ar, .Fl and .Li starting with closing punctuation emit an empty element * empty .Li macros print nothing, but may cause spacing * proper EOS handling for .Bt, .Ex, .Rv, and .Ud. * cleanup: collapse posts_xr into posts_wtext (which is the same) * efficiency: very simple table lookup for roff.c
* Unified error and warning message system for all of mandoc,schwarze2010-05-231-15/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | featuring three message levels, as agreed during the mandoc hackathon: * FATAL parser failure, cannot produce any output from this input file: eventually, we hope to convert most of these to ERRORs. * ERROR, meaning mandoc cannot cope fully with the input syntax and will probably lose information or produce structurally garbled output; it will try to produce output anyway but exit non-zero at the end, which is eventually intended to make the ports infrastructure happy. * WARNING, meaning you should clean up the input file, but output is probably mostly OK, so this will not cause error-exit at the end. This commit is mostly just converting the old system to the new one; before the classification will become really reliable, we must check all messages. In particular, * set up a new central message string table in main.c * drop the old message string tables from man.c and mdoc.c * get rid of the piece-meal merr enums in libman and libmdoc * reduce number of error/warning functions from 16 to 6 (still a lot...) While here, handle a few problems more gracefully: * allow .Rv and .Ex to work without a prior .Nm * allow .An to ignore extra arguments * allow undeclared columns in .Bl -column Written by kristaps@.
* merge bsd.lv rev. 1.63:schwarze2010-05-151-5/+10
| | | | remove "1 == ppos" conditions that remained after rev. 1.60
* more end-of-sentence (EOS) handling:schwarze2010-05-151-7/+21
| | | | | | * recognize the end of quoted sentences, and of those in parantheses * detect EOS in append_delims, so it works after all macros by kristaps@