summaryrefslogtreecommitdiffstats
path: root/usr.bin/mandoc/mdoc_validate.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* Get rid of the useless FATAL error "child violates parent syntax".schwarze2014-08-081-54/+4
| | | | | When finding items outside lists, simply skip them and throw an ERROR. Handle subsections before the first section instead of bailing out.
* Remove two useless FATAL errors.schwarze2014-08-081-8/+16
| | | | | When a file contains neither text nor macros, treat it as an empty document. When the mdoc(7) document prologue is incomplete, use some default values.
* better name and wording for the last two non-generic errorsschwarze2014-08-081-2/+3
|
* Various improvements related to .Ex and .Rv:schwarze2014-08-081-26/+17
| | | | | | | | | | * let .Nm fall back to the empty string, not to UNKNOWN * never let .Rv copy an argument from .Nm * avoid spurious \fR after empty .Nm in -Tman * correct handling of .Ex and .Rv in -Tman * correct the wording of the output for .Rv without arguments * use non-breaking spaces in .Ex and .Rv output where required * split MANDOCERR_NONAME into a warning for .Ex and an error for .Nm
* Partial implementation of .Bd -centered.schwarze2014-08-081-2/+2
| | | | | | | | | In groff, .Bd -centered operates in fill mode, which is relatively hard to implement, while this implementation operates in non-fill mode so far. As long as you pay attention that your lines do not overflow, it works. To make sure that rendering is the same for mandoc and groff, it is recommended to insert .br between lines for now. This implementation will need improvement later.
* no need to delete any content from .Rs blocks,schwarze2014-07-071-35/+12
| | | | and downgrade the related message from ERROR to WARNING
* Clean up messages related to plain text and to escape sequences.schwarze2014-07-061-2/+3
| | | | | * Mention invalid escape sequences and string names, and fallbacks. * Hierarchical naming.
* Cleanup with respect to bad macro arguments.schwarze2014-07-051-57/+62
| | | | | | | | * Fix .Sm with invalid arg: move arg out and toggle mode. * Promote "unknown standard" from WARNING to ERROR, it loses information. * Delete MANDOCERR_BADWIDTH, it would only indicate a mandoc(1) bug. * Do not report MANDOCERR_BL_LATETYPE when there is no type at all. * Mention macro names, arguments and fallbacks.
* Cleanup regarding -offset and -width:schwarze2014-07-051-56/+52
| | | | | | | * Bugfix: Last one wins, not first one. * Fix .Bl -width without argument: it means 0n, so do not ignore it. * Report macro names, argument names and fallbacks in related messages. * Simplify: Garbage collect auxiliary variables in pre_bd() and pre_bl().
* Clean up messages regarding excess arguments:schwarze2014-07-041-24/+27
| | | | | | | * Downgrade ".Bf -emphasis Em" from FATAL to WARNING. * Mention the macros, the arguments, and the fallbacks. * Hierarchical naming. Also fix the handling of excess .It head arguments in -Tman.
* Clean up messages related to missing arguments.schwarze2014-07-041-17/+13
| | | | | | | | | * Do not warn about empty -column cells, they seem valid to me. * Downgrade empty item and missing -std from ERROR to WARNING. * Hierarchical naming. * Descriptive, not imperative style. * Mention macro names, argument names, and fallbacks. * Garbage collect some unreachable code in post_it().
* Fix formatting of empty .Bl -inset item heads.schwarze2014-07-031-25/+23
| | | | | | Downgrade empty item heads from ERROR to WARNING. Show the list type in the error message. Choose better variable names for nodes in post_it().
* Improve and test the messages about empty macros,schwarze2014-07-021-2/+4
| | | | in particular reporting the macro names involved.
* When .Sm is called without an argument, groff toggles the spacing mode,schwarze2014-07-021-4/+5
| | | | | so let us do the same for compatibility. Using this feature is of course not recommended except in manual page obfuscation contests.
* Disentangle the MANDOCERR_CHILD message, which reported threeschwarze2014-07-021-4/+8
| | | | | completely different things, into three distinct messages. Also mention the macro names we are talking about.
* Clean up warnings related to macros and nesting.schwarze2014-07-021-3/+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.
* Improve "skipping paragraph macro" messages,schwarze2014-07-021-14/+30
| | | | showing which macro was skipped and before or after what.
* Implement the obsolete macros .En .Es .Fr .Ot for backward compatibility,schwarze2014-07-021-5/+38
| | | | | since this is hardly more complicated than explicitly ignoring them as we did in the past. Of course, do not use them!
* Clean up the warnings related to document structure.schwarze2014-07-011-27/+48
| | | | | | | | | * Hierarchical naming of the related enum mandocerr items. * Mention the offending macro, section title, or string. While here, improve some wordings: * Descriptive instead of imperative style. * Uniform style for "missing" and "skipping". * Where applicable, mention the fallback used.
* As suggested by jmc@, only include line and column numbers into messagesschwarze2014-06-201-14/+10
| | | | | | | | | | | | | | when they are meaningful, to avoid confusing stuff like this: $ mandoc /dev/null mandoc: /dev/null:0:1: FATAL: not a manual Instead, just say: mandoc: /dev/null: FATAL: not a manual Another example this applies to is documents having a prologue, but lacking a body. Do not throw a FATAL error for these; instead, issue a warning and show the empty document, in the man(7) case with the same amount of blank lines as groff does. Also downgrade mdoc(7) documents having content before the first .Sh from FATAL to WARNING.
* Start systematic improvements of error reporting.schwarze2014-06-201-10/+10
| | | | | | | | | | | So far, this covers all WARNINGs related to the prologue. 1) hierarchical naming of MANDOCERR_* constants 2) mention the macro name in messages where that adds clarity 3) add one missing MANDOCERR_DATE_MISSING msg 4) fix the wording of one message related to the man(7) prologue Started on the plane back from Ottawa.
* Audit malloc(3)/calloc(3)/realloc(3) usage.schwarze2014-04-231-5/+5
| | | | | | | * Change eight reallocs to reallocarray to be safe from overflows. * Change one malloc to reallocarray to be safe from overflows. * Change one calloc to reallocarray, no zeroing needed. * Change the order of arguments of three callocs (aesthetical).
* Audit strlcpy(3)/strlcat(3) usage.schwarze2014-04-231-21/+12
| | | | | | | | | | | | | * Repair three instances of silent truncation, use asprintf(3). * Change two instances of strlen(3)+malloc(3)+strlcpy(3)+strlcat(3)+... to use asprintf(3) instead to make them less error prone. * Cast the return value of four instances where the destination buffer is known to be large enough to (void). * Completely remove three useless instances of strlcpy(3)/strlcat(3). * Mark two places in -Thtml with XXX that can cause information loss and crashes but are not easy to fix, requiring design changes of some internal interfaces. * The file mandocdb.c remains to be audited.
* strlen+malloc+snprintf is error prone;schwarze2014-04-201-23/+14
| | | | rewrite post_lb() to use asprintf(3) instead
* make sure static buffers for snprintf(3) are large enoughschwarze2014-04-201-7/+5
| | | | and cast snprintf return value to (void) where they are
* KNF: case (FOO): -> case FOO, remove /* LINTED */ and /* ARGSUSED */,schwarze2014-04-201-254/+240
| | | | | remove trailing whitespace and blanks before tabs, improve some indenting; no functional change
* Using macros in .Sh header lines, or having .Sm off or .Bk -words openschwarze2014-04-151-12/+8
| | | | | | | | | while processing .Sh, is not at all recommended, but it's not strictly a syntax violation either, and in any case, mandoc must not die in an assertion. I broke this in rev. 1.124. Crash found while trying to read the (rather broken) original 4.3BSD-Reno od(1) manual page.
* recognise the CONTEXT section. we consider it only applicable todlg2014-03-311-1/+4
| | | | | | | | section 9 manpages for now. requested by schwartz@ pre 5.5 tweaks by jmc@ schwartz@ ok schwartz@
* 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.
* Retire the old concat() function.schwarze2014-03-231-78/+27
| | | | | | | | For .Sh, i wasn't even needed at all. For .Dd, .Nm, and .Os, use the new mdoc_deroff() instead. This gets rid of the last limited-size static buffers in this file, hence eliminates the last explicit MANDOCERR_MEM throwers here, and it shortens the code by 50 lines.
* avoid repetitive code for asprintf error handlingschwarze2014-03-211-6/+4
|
* The files mandoc.c and mandoc.h contained both specialised low-levelschwarze2014-03-211-1/+2
| | | | | | | functions used for multiple languages (mdoc, man, roff), for example mandoc_escape(), mandoc_getarg(), mandoc_eos(), and generic auxiliary functions. Split the auxiliaries out into their own file and header. While here, do some #include cleanup.
* After Werner Lemberg accepted and committed some updates to the manualschwarze2014-02-161-3/+5
| | | | | | page template contained in groff_mdoc(7), catch up with our own stuff. In particular, allow ERRORS in section 4 and DIAGNOSTICS in section 9. ok jmc@
* Remove useless use of strnlen(3).schwarze2014-01-111-2/+2
| | | | Yuckiness pointed out by deraadt@.
* Cache the result of uname(3) such that we don't need to call itschwarze2014-01-071-30/+23
| | | | | over and over again for each manual; found with gprof(1). Speeds up mandocdb(8) -Q by 3%, now at 39.5% of makewhatis(8).
* Another 18% speedup for mandocdb(8) -Q, found by gprof(1).schwarze2014-01-061-6/+6
| | | | | | | In -Q mode, refrain form validating and normalizing the format of the date given in .Dd or .TH, as it won't be used anyway. For /usr/share/man, mandocdb -Q now takes 45% of the time of makewhatis(8).
* Joerg Sonnenberger contributed copyrightable amounts of text toschwarze2014-01-061-1/+2
| | | | | | some files. To make it clear that he also put his contributions under the ISC license, with his explicit permission, add his Copyright notice to the relevant files. No code change.
* The "value" argument to the roff(7) .nr requests ends right beforeschwarze2013-12-151-3/+3
| | | | | | | | the first non-digit character. While here, implement and document an optional sign, requesting increment or decrement, as documented in the Ossanna/Kernighan/Ritter troff manual and supported by groff. Reported by bentley@ on discuss at mdocml.
* There are three kinds of input lines: text lines, macros takingschwarze2013-10-211-3/+9
| | | | | | | | | | | | | | 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.
* We don't do hyphenation, but we allow breaking the line at hyphens that areschwarze2013-10-061-20/+62
| | | | | | | | | | | | already there in the middle of words. So far, we only allowed this on text lines. Now it turns out some macros allow this for their arguments, too, in particular .Nd and most of the .%? citation macros. Issue found by Franco Fichtner <franco at lastsummer dot de> while doing systematic groff-mandoc comparisons in the DragonFly base system, THANKS! While here, garbage collect two empty prevalidator function pointer lists and sort a couple of function declarations.
* If there is random stuff inside a .Bl block body before the first .It,schwarze2013-10-061-20/+59
| | | | | | | | | | | do not throw a FATAL error and do not die, but just throw a WARNING and move the stuff out of the .Bl block. This bug felt completely 2008-ish; meanwhile, such bugs from the Kristaps-doesnt-like-syntax-errors-so-lets-just-give-up--Era are becoming rare, but this was one of the last survivors. Thanks to bentley@ for reminding me to finally fix this.
* Support setting arbitrary roff(7) number registers,schwarze2013-10-031-6/+7
| | | | | | | | | | | | | | | preserving read support for the ".nr nS" SYNOPSIS state register; read support for arbitrary registers is still not available. Inspired by NetBSD roff.c rev. 1.18 (Christos Zoulas, March 21, 2013), but implemented differently. I don't want to have yet another different implementation of a hash table in mandoc - it would be the second one in roff.c alone and the fifth one in mandoc grand total. Instead, i designed and implemented roff_setreg() and roff_getreg() to be similar to roff_setstrn() and roff_getstrn(). Once we feel the need to optimize, we can introduce one common hash table implementation for everything in mandoc.
* One of the WARNING messages has to use the word "section" twice in twoschwarze2013-09-161-2/+3
| | | | | | | | | | different meanings, that cannot be helped. But we can make this less confusing by stating that the second instance refers to stuff like (2), (3), and (9), and by adding the sections header the first instance refers to, for example ERRORS or RETURN VALUES. Source for confusion noticed by Jan Stary <hans at stare dot cz>, better wording suggested by jmc@, tweaked by me.
* Put .%C before .%D in .Rs outputschwarze2013-08-051-3/+3
| | | | | | | | | | because that's the usual order in formal citations. My patch that was accepted into groff by Werner Lemberg uses the same order, so keep groff and mandoc consistent. Committing now because jmc@ already starts to rely on the .%C macro, see for example /usr/src/usr.bin/bdes/bdes.1 rev. 1.11.
* Cleanup naming of local variables to make the code easier on the eye:schwarze2012-11-171-17/+17
| | | | | | | | 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
* Warn about unknown volume or arch in Dt macro arguments;schwarze2012-11-161-2/+2
| | | | patch written by Nicolas Joly <njoly at pasteur dot fr>.
* Fix handling of paragraph macros inside lists:schwarze2012-07-181-5/+34
| | | | | | | | * When they are trailing the last item, move them outside the list. * When they are trailing any other none-compact item, drop them. Improves formatting of 40 pages, e.g. grep(1), ksh(1), netstat(1), ath(4), bsd.port.mk(5), pf.conf(5), mount(8), crypto(9).
* Several -mdoc parser improvements related to vertical spacing:schwarze2012-07-161-7/+37
| | | | | | | | | * So far, .Pp and .Lp were removed before paragraph type blocks. * Now also remove .br before paragraph type blocks. * Treat .Lp as a paragraph like .Pp, so remove .Pp, .Lp, .br before it. * Do not treat .sp as a paragraph, don't remove anything before it. * After .Sh, .Ss, .Pp, and .Lp, remove .Pp, .Lp, .sp, .br, and blank lines. * After .sp and .br, remove .br.
* The post_nm() validation function crashed when the first .Nm child nodeschwarze2012-07-121-13/+18
| | | | | | | | | was a non-text node. Fix this by rewriting post_nm() to always set the meta name to UNKNOWN when the name is missing or unusable. While here, make MANDOCERR_NONAME an ERROR, as it usually renders the page content unintelligible. Bug reported by Maxim <Belooussov at gmail dot com>, thanks.
* fix position and formatting of %Uschwarze2012-07-111-3/+3
|