aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_validate.c
Commit message (Collapse)AuthorAgeFilesLines
* Multiple fixes with respect to .Pf:Ingo Schwarze2014-11-301-2/+2
| | | | | | | * 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.
* Retire support for CSRG supplementary document titles. These areIngo Schwarze2014-11-281-13/+3
| | | | | long obsolete and were never written in mdoc(7) in the first place. Removes 100 lines from source files.
* Drop useless architecture table. Validating architecture namesIngo Schwarze2014-11-281-14/+7
| | | | | | is a job for makewhatis(8)/mandoc.db(5), not for the parser. Removes 150 lines from source files and 4k (1%) from the binary. Bloat found by deraadt@.
* kill a pointless assertIngo Schwarze2014-11-281-4/+1
|
* Simplify code by making mdoc validation handlers void.Ingo Schwarze2014-11-281-323/+222
| | | | No functional change, minus 90 lines of code.
* Downgrade .Bd -file from FATAL to ERROR.Ingo Schwarze2014-11-271-2/+2
| | | | | Since this was the last remaining FATAL error in this area, this change will allow major simplifications in the mdoc(7) parser.
* Fix the obsolete .Db (toggle debug mode) macro to ignore its argumentsIngo Schwarze2014-11-271-18/+13
| | | | | and not trigger an assertion when there is more than one argument; the latter found by jsg@ with afl.
* remove an unreachable warning about .Sm argumentsIngo Schwarze2014-11-261-3/+1
|
* Multiple fixes with respect to in-line macros:Ingo Schwarze2014-11-171-6/+16
| | | | | | | | | | * .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@.
* Major bugsquashing with respect to -offset and -width:Ingo Schwarze2014-10-301-43/+19
| | | | | | | | | 1. Support specifying the .Bd and .Bl -offset as a macro default width; while here, simplify the code handling the same for .Bl -width. 2. Correct handling of .Bl -offset arguments: unlike .Bd -offset, the arguments "left", "indent", and "indent-two" have no special meaning. 3. Fix the scaling of string length -offset and -width arguments in -Thtml. Triggered by an incomplete documentation patch from bentley@.
* sync with OpenBSD:Ingo Schwarze2014-10-131-2/+3
| | | | | check sorting of .Xr's case-insensitively; no idea why this was different here
* Do not warn about declarations of functions returning function pointers,Ingo Schwarze2014-10-131-4/+6
| | | | getting rid of a false positive noticed by bentley@.
* oops, don't crash when .Fo has no argumentIngo Schwarze2014-10-111-2/+2
|
* warn about parentheses in function names after .Fn and .Fo;Ingo Schwarze2014-10-111-2/+29
| | | | | particularly useful when converting from other languages to mdoc(7); feature suggested by bentley@
* warn about commas in function arguments; inspired by mdoclint(1)Ingo Schwarze2014-09-121-3/+26
|
* warn about botched .Xr ordering and punctuation below SEE ALSO;Ingo Schwarze2014-09-111-1/+66
| | | | inspired by mdoclint(1)
* warn about AUTHORS sections without .An macros, inspired by mdoclint(1)Ingo Schwarze2014-09-071-9/+40
|
* Allow .ll in the prologue; Daniel Levai reports Slackware Linux uses this.Ingo Schwarze2014-09-071-10/+9
|
* Do not dereference a NULL pointer if a .Bl macro hasIngo Schwarze2014-08-191-2/+2
| | | | | no -type, -width, -offset or -compact arguments whatsoever; this got broken in rev. 1.238.
* Get rid of HAVE_CONFIG_H, it is always defined; idea from libnbcompat.Ingo Schwarze2014-08-101-5/+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.
* Bring the handling of defective prologues even closer to groff,Ingo Schwarze2014-08-061-81/+73
| | | | | | | | | | | | in particular relaxing the distinction between prologue and body and further improving messages. * The last .Dd wins and the last .Os wins, even in the body. * The last .Dt before the first body macro wins. * Missing title in .Dt defaults to UNTITLED. Warn about it. * Missing section in .Dt does not default to 1. But warn about it. * Do not warn multiple times about the same mdoc(7) prologue macro. * Warn about missing .Os. * Incomplete .TH defaults to empty strings. Warn about it.
* Simplify by allowing only one post-handler.Ingo Schwarze2014-08-021-128/+150
| | | | | | Saves 36 static arrays and 10 lines of code at the expense of only five new trivial static functions. No functional change.
* Simplify by allowing only one pre-handler.Ingo Schwarze2014-08-011-47/+29
| | | | | Saves 12 static arrays and 19 lines of code. No functional change.
* demacrify: get rid of man_nmsg(), man_pmsg(), mdoc_nmsg(), mdoc_pmsg()Ingo Schwarze2014-08-011-3/+5
|
* mention requests and macros in more messagesIngo Schwarze2014-08-011-33/+45
|
* Split MANDOCERR_IGNARGV into one message for .An and one for .BlIngo Schwarze2014-07-311-10/+22
| | | | and report the macro name and argument.
* In .Bl -column, if some of the column width declarations are givenIngo Schwarze2014-07-311-21/+13
| | | | | | | | | | | | | right after the -column argument and some at the very end of the argument list, after some other arguments like -compact, concatenate the column lists. This gets rid of one of the last useless FATAL errors and actually shortens the code by a few lines. This fixes an issue introduced more than five years ago, at first causing an assert() since mdoc_action.c rev. 1.14 (June 17, 2009), then later a FATAL error since mdoc_validate rev. 1.130 (Nov. 30, 2010), and marked as "TODO" ever since.
* Remove the useless FATAL error "argument count wrong, violates syntax".Ingo Schwarze2014-07-301-12/+6
| | | | | | The last remaining instance was .It in .Bl -column with more than one excessive .Ta. However, simply downgrading from FATAL to ERROR, it just works fine, almost the same way as in groff, without any other changes.
* Get rid of the useless FATAL error "child violates parent syntax".Ingo Schwarze2014-07-301-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.Ingo Schwarze2014-07-301-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 errorsIngo Schwarze2014-07-301-2/+3
|
* Various improvements related to .Ex and .Rv:Ingo Schwarze2014-07-301-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.Ingo Schwarze2014-07-291-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,Ingo 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.Ingo Schwarze2014-07-061-2/+3
| | | | | * Mention invalid escape sequences and string names, and fallbacks. * Hierarchical naming.
* Cleanup with respect to bad macro arguments.Ingo 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:Ingo 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:Ingo Schwarze2014-07-041-24/+27
| | | | | | * Downgrade ".Bf -emphasis Em" from FATAL to WARNING. * Mention the macros, the arguments, and the fallbacks. * Hierarchical naming.
* Clean up messages related to missing arguments.Ingo 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.Ingo 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,Ingo Schwarze2014-07-021-2/+4
| | | | in particular reporting the macro names involved.
* When .Sm is called without an argument, groff toggles the spacing mode,Ingo 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 threeIngo Schwarze2014-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.Ingo 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,Ingo 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,Ingo 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.Ingo 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 messagesIngo Schwarze2014-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.Ingo 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.Ingo 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).