summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/man_validate.c
AgeCommit message (Collapse)Author
2014-12-28mdoc(7) already uses the mandoc(1) -Ios argument in the footer lineIngo Schwarze
when .Os has no argument, so do the same for man(7) when .TH has less than four arguments; there is no reason to treat both differently. Issue found following a question from Thomas Klausner <wiz at NetBSD>.
2014-11-28Simplify by making many functions in the man(7) parser void,Ingo Schwarze
and some cleanup; no functional change, minus 70 lines.
2014-08-08Bring the handling of defective prologues even closer to groff,Ingo Schwarze
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.
2014-08-08Simplify man(7) validation:Ingo Schwarze
Drop pre-handlers, they were almost unused. Drop the needless complexity of allowing more than one post-handler. This saves one internal interface function, one static function, one private struct definition, sixteen static arrays, and 45 lines of code. No functional change.
2014-08-08demacrify: get rid of man_nmsg(), man_pmsg(), mdoc_nmsg(), mdoc_pmsg()Ingo Schwarze
2014-08-08mention requests and macros in more messagesIngo Schwarze
2014-08-08Improve handling of next-line scope broken by end of file.Ingo Schwarze
Detect the condition earlier, report in the error message which block is broken, and delete the broken block. Consequently, empty section headers can no longer happen.
2014-07-07Clean up ERROR messages related to document structure and macros:Ingo Schwarze
Hierarchical naming and mention macro names in messages.
2014-07-06Clean up messages related to plain text and to escape sequences.Ingo Schwarze
* Mention invalid escape sequences and string names, and fallbacks. * Hierarchical naming.
2014-07-05Cleanup with respect to bad macro arguments.Ingo Schwarze
* 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.
2014-07-04Clean up messages regarding excess arguments:Ingo Schwarze
* 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.
2014-07-02Clean up warnings related to macros and nesting.Ingo Schwarze
* 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.
2014-07-02Improve "skipping paragraph macro" messages,Ingo Schwarze
showing which macro was skipped and before or after what.
2014-07-01Clean up the warnings related to document structure.Ingo Schwarze
* 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.
2014-06-20As suggested by jmc@, only include line and column numbers into messagesIngo Schwarze
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.
2014-06-20Start systematic improvements of error reporting.Ingo Schwarze
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.
2014-04-20KNF: case (FOO): -> case FOO, remove /* LINTED */ and /* ARGSUSED */,Ingo Schwarze
remove trailing whitespace and blanks before tabs, improve some indenting; no functional change
2014-03-30Implement the roff(7) .ll (line length) request.Ingo Schwarze
Found by naddy@ in the textproc/enchant(1) port. Of course, do not use this in new manuals.
2014-03-21The files mandoc.c and mandoc.h contained both specialised low-levelIngo Schwarze
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.
2014-01-06Another 18% speedup for mandocdb(8) -Q, found by gprof(1).Ingo Schwarze
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).
2013-12-31remove assignments that will be overwritten right afterwards,Ingo Schwarze
and remove pointless local variables; found in a clang output from Ulrich Spoerlein <uqs at FreeBSD>
2013-10-17Implement the .UR/.UE block (uniform resource identifier) introduced in theIngo Schwarze
man-ext macros by Eric S. Raymond, enabled by default in groff_man(7). Usual disclaimer: You don't write new man(7) code, so you are not going to use these, either. Improves e.g. the bzr(1) and etherape(1) manuals. Thanks to naddy@ for bringing these to my attention.
2012-11-17Cleanup naming of local variables to make the code easier on the eye:Ingo Schwarze
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
2012-07-29Implement .PD for -Tascii.Ingo Schwarze
Reminded about the missing feature by millert@. This reduces mandoc/groff differences in base by 25%. ok millert@
2012-07-18Drop empty .IP such that is does not cause additional vertical spacing.Ingo Schwarze
Issue first reported by naddy@ in rsync(1).
2012-07-18Drop .sp and .br right after .SH and .SS.Ingo Schwarze
Fixes vertical spacing after "OPTIONS" in gcc(1). Issue first reported by naddy@ in rsync(1).
2012-06-02Minimal implementation of .EX and .EE for GNU compatibility.Ingo Schwarze
Do not use this, it is not portable and only defined in esr's man-ext. For example, sox(1) wants these macros.
2012-02-26Support .OP, one of the extended man macros; from kristaps@.Ingo Schwarze
Do not use this GNU extension, we take it for compatibility only.
2011-12-02In man(7), when no explicit volume name is given, use the defaultIngo Schwarze
volume name for the respective manual section, just like in mdoc(7). This gives us nicer page headers for cvs(1), lynx(1), tic(1), mkhybrid(8), and many curses(3) manuals. ok kristaps@ To not break compatibility, i wrote a corresponding patch for GNU troff which Werner Lemberg accepted upstream at rev. 1.65 of: http://cvs.savannah.gnu.org/viewvc/groff/tmac/an-old.tmac?root=groff
2011-11-05When the HEAD scope of .TP is broken by another block macro,Ingo Schwarze
do not abort with a FATAL error, but report a regular ERROR, remove the broken .TP from the syntax tree, and prod on. Reported repeatedly by ports people, at least by brad@ and jeremy@. Also fixes rendition(4) in Xenocara.
2011-11-03When .TH sets no data, leave the date field in the page footer blank,Ingo Schwarze
do not use the current date. This removes a gratuitous output difference with respect to groff. ok kristaps@
2011-10-16Remove a bunch of useless assignments,Ingo Schwarze
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@.
2011-09-18sync to version 1.11.7 from kristaps@Ingo Schwarze
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
2011-07-07Fix a bogus "unknown macro" error reported in the pod2man(1) preamble:Ingo Schwarze
- Actually let roff_parse() recognize ".\}" as a cond block end request. - Do not rewrite "\}" to the zero-width space "\&" because that prevents recognition of immediately preceding macros; use normal blanks instead. - To avoid a vertical spacing regression in pod2man(1) manuals, drop one vertical spacing request just before NAME. From kristaps@.
2011-05-29Merge release 1.11.3, almost all code by kristaps@:Ingo Schwarze
* 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.
2011-04-24Merge version 1.11.1:Ingo Schwarze
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.
2011-04-21Merge version 1.10.10:Ingo Schwarze
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
2011-03-20Import the foundation for eqn(7) support.Ingo Schwarze
Written by kristaps@. For now, i'm adding one line to each of the four frontends to just pass the input text through to the output, not yet interpreting any of then eqn keywords.
2011-03-07Clean up date handling,Ingo Schwarze
as a first step to get rid of the frequent petty warnings in this area: - always store dates as strings, not as seconds since the Epoch - for input, try the three most common formats everywhere - for unrecognized format, just pass the date though verbatim - when there is no date at all, still use the current date Originally triggered by a one-line patch from Tim van der Molen, <tbvdm at xs4all dot nl>, which is included here. Feedback and OK on manual parts from jmc@. "please check this in" kristaps@
2011-01-17Refrain from throwing fatal errors forIngo Schwarze
* .br .sp .nf .fi .na with arguments - just skip the arguments * .TH lacking arguments - use empty strings instead like groff * .TH with excessive arguments - skip those Reminded by Joerg Sonnenberger, ok kristaps@.
2011-01-16Some improvements to error handling from kristaps@:Ingo Schwarze
* 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@.
2011-01-04Merge kristaps@' cleaner tbl integration, removing mine;Ingo Schwarze
there are still a few bugs, but fixing these will be easier in tree.
2010-12-19Remove `i' and `r' macro handlers. These macros, originally part of theIngo Schwarze
me package, aren't recognised by "groff -mandoc" so we don't need to do so either. Besides, they are not used in base or Xenocara, and only at two or three places in one single port, which are probably typos. From kristaps@.
2010-12-07Complete the merge of bsd.lv version 1.10.7:Ingo Schwarze
No more functional changes, just sync ordering, comments and white space.
2010-12-06Do not report the same problems multiple times,Ingo Schwarze
and do not bother checking the return values of calls that always return 1. From kristaps@.
2010-12-01Merge man_action.c into man_validate.c.Ingo Schwarze
Same as for mdoc_action.c, but much simpler. Work by kristaps@, re-applying OpenBSD changes on top.
2010-11-29Now that we have proper .de support in the roff(7) library,Ingo Schwarze
it is time to remove the .Sp, .Vb, and .Ve kludge that was added to the man(7) library to build Perl manuals.
2010-11-29Implement the roff .ft (change font) request for man(7).Ingo Schwarze
Of course, we don't want to encourage low-level physical markup, but pod2man(1) writes such requests, so Perl manuals contain them, and some Xenocara and lots and lots of ports manuals use them as well. In base and Xenocara, this will reduce mandoc -Tlint ERROR noise; in ports, it will improve rendering of many manuals.
2010-10-27The man(7) macros .HP .IP .RS .TP accept *optional* arguments,Ingo Schwarze
so do not throw an ERROR when there are none. Formatting is already correct: With no arguments, use default widths and no tag. Problem reported by naddy@, thanks.
2010-10-15Minimal glue to integrate tbl into the mandoc man(7) parser and formatter.Ingo Schwarze
The output dosn't look nice yet, escape handling is still missing, but will follow soon. "move forward aggressively :-)" deraadt@