summaryrefslogtreecommitdiffstats
path: root/man_validate.c
Commit message (Collapse)AuthorAgeFilesLines
* Third step towards parser unification:Ingo Schwarze2015-04-021-13/+13
| | | | | Replace struct mdoc_meta and struct man_meta by a unified struct roff_meta. Written of the train from London to Exeter on the way to p2k15.
* Second step towards parser unification:Ingo Schwarze2015-04-021-4/+4
| | | | | | | | | Replace struct mdoc_node and struct man_node by a unified struct roff_node. To be able to use the tok member for both mdoc(7) and man(7) without defining all the macros in roff.h, sacrifice a tiny bit of type safety and make tok an int rather than an enum. Almost mechanical, no functional change. Written on the Eurostar from Bruxelles to London on the way to p2k15.
* First step towards parser unification:Ingo Schwarze2015-04-021-19/+22
| | | | | | Replace enum mdoc_type and enum man_type by a unified enum roff_type. Almost mechanical, no functional change. Written on the ICE train from Frankfurt to Bruxelles on the way to p2k15.
* better error reporting regarding .OP .RS .UR .TH argumentsIngo Schwarze2015-02-061-21/+22
|
* better diagnostics about excess arguments to .PD .ft .spIngo Schwarze2015-02-061-10/+1
|
* better error reporting for .br .fi .nf with argumentsIngo Schwarze2015-02-061-10/+2
|
* Delete the legacy generic warning type MANDOCERR_ARGCWARN,Ingo Schwarze2015-02-061-3/+3
| | | | | replacing the last instances by more specific warnings. Improved functionality, minus 50 lines of code.
* Strangely, ignoring the roff(7) .na request was implemented in the man(7)Ingo Schwarze2015-01-241-1/+0
| | | | | parser. Simplify the code by moving it into the roff(7) parser, also making it work for mdoc(7).
* mdoc(7) already uses the mandoc(1) -Ios argument in the footer lineIngo Schwarze2014-12-281-0/+2
| | | | | | 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>.
* Simplify by making many functions in the man(7) parser void,Ingo Schwarze2014-11-281-65/+50
| | | | and some cleanup; no functional change, minus 70 lines.
* Get rid of HAVE_CONFIG_H, it is always defined; idea from libnbcompat.Ingo Schwarze2014-08-101-2/+0
| | | | | | 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-8/+11
| | | | | | | | | | | | 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 man(7) validation:Ingo Schwarze2014-08-011-120/+69
| | | | | | | | | 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.
* demacrify: get rid of man_nmsg(), man_pmsg(), mdoc_nmsg(), mdoc_pmsg()Ingo Schwarze2014-08-011-2/+4
|
* mention requests and macros in more messagesIngo Schwarze2014-08-011-5/+9
|
* Improve handling of next-line scope broken by end of file.Ingo Schwarze2014-07-301-21/+3
| | | | | | 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.
* Clean up ERROR messages related to document structure and macros:Ingo Schwarze2014-07-071-4/+3
| | | | Hierarchical naming and mention macro names in messages.
* Clean up messages related to plain text and to escape sequences.Ingo Schwarze2014-07-061-1/+2
| | | | | * Mention invalid escape sequences and string names, and fallbacks. * Hierarchical naming.
* Cleanup with respect to bad macro arguments.Ingo Schwarze2014-07-051-2/+2
| | | | | | | | * 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.
* Clean up messages regarding excess arguments:Ingo Schwarze2014-07-041-1/+5
| | | | | | * Downgrade ".Bf -emphasis Em" from FATAL to WARNING. * Mention the macros, the arguments, and the fallbacks. * Hierarchical naming.
* Clean up warnings related to macros and nesting.Ingo Schwarze2014-07-021-2/+2
| | | | | | | * 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-3/+9
| | | | showing which macro was skipped and before or after what.
* Clean up the warnings related to document structure.Ingo Schwarze2014-07-011-1/+4
| | | | | | | | | * 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-4/+6
| | | | | | | | | | | | | | 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-3/+8
| | | | | | | | | | | 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.
* KNF: case (FOO): -> case FOO:, remove /* LINTED */ and /* ARGSUSED */,Ingo Schwarze2014-04-201-47/+41
| | | | | 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.
* The files mandoc.c and mandoc.h contained both specialised low-levelIngo Schwarze2014-03-231-0/+1
| | | | | | | 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.
* Another 18% speedup for mandocdb(8) -Q, found by gprof(1).Ingo Schwarze2014-01-061-5/+7
| | | | | | | 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).
* remove assignments that will be overwritten right afterwards,Ingo Schwarze2013-12-311-5/+1
| | | | | and remove pointless local variables; found in a clang output from Ulrich Spoerlein <uqs at FreeBSD>
* Implement the .UR/.UE block (uniform resource identifier) introduced in theIngo Schwarze2013-10-171-1/+16
| | | | | | | | 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.
* Cleanup naming of local variables to make the code easier on the eye:Ingo Schwarze2012-11-171-80/+71
| | | | | | | | 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
* Implement .PD for -Tascii.Ingo Schwarze2012-07-291-1/+2
| | | | | | Reminded about the missing feature by millert@. This reduces mandoc/groff differences in OpenBSD base by 25%. ok millert@
* Drop empty .IP such that is does not cause additional vertical spacing.Ingo Schwarze2012-07-181-1/+21
| | | | | Issue first reported by naddy@ in rsync(1). OpenBSD rev. 1.55.
* Drop .sp and .br right after .SH and .SS.Ingo Schwarze2012-07-181-6/+19
| | | | | | | Fixes vertical spacing after "OPTIONS" in gcc(1). Issue first reported by naddy@ in rsync(1). OpenBSD rev. 1.54.
* Minimal implementation of .EX and .EE for GNU compatibility.Ingo Schwarze2012-06-021-0/+2
| | | | | Do not use this, it is not portable and only defined in esr's man-ext. For example, sox(1) wants these macros.
* Add support for `OP', one of the extended man macros. This also requiresKristaps Dzonsons2012-01-031-2/+6
| | | | some man(7) changes to accomodate for the an-ext compatibility.
* In man(7), when no explicit volume name is given, use the defaultIngo Schwarze2011-12-021-0/+4
| | | | | | | | | | | | 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
* When the HEAD scope of .TP is broken by another block macro,Ingo Schwarze2011-11-071-25/+10
| | | | | | | | do not abort with a FATAL error, but report a report a WARNING, 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. ok kristaps@
* When .TH sets no data, leave the date field in the page footer blank,Ingo Schwarze2011-11-031-3/+5
| | | | | | do not use the current date. This removes a gratuitous output difference with respect to groff. ok kristaps@
* Remove a bunch of useless assignments,Ingo Schwarze2011-10-161-6/+5
| | | | | | | 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@.
* Revert removal of tab warning, suggested by schwarze@.Kristaps Dzonsons2011-09-061-2/+17
|
* Remove check for tab. man(7) says tab is Ok.Kristaps Dzonsons2011-09-041-17/+2
|
* Teach -man that a literal context should be closed by SS/SH in theKristaps Dzonsons2011-09-041-9/+19
| | | | | backend (the front-end already accomodated for this). Found indirectly from a question by Brad Smith.
* Move checking of escapes into roff.c, where we're already steppingKristaps Dzonsons2011-07-261-36/+6
| | | | | through looking for user-defined escapes. This clears up a nice bit of validation code.
* Scary-looking but otherwise harmless changes allow me to build for Windows.Kristaps Dzonsons2011-07-241-1/+2
| | | | | | | | | | | | That is to say, with mingw32. This amounts to the following: (1) break compat.c into compat_strlcpy.c and compat_strlcat.c (2) add compat_getsubopt.c (from OpenBSD) and test-getsubopt.c (3) add test-strptime.c for HAVE_STRPTIME (4) add ifdef bits here and there, where necessary (5) remove some harmless unportable stuff (u_char, localtime_r) I've added the appropriate mdocml.zip target to the Makefile, too.
* Make sure that `br' and `sp' don't emit space before the initial `SH' inKristaps Dzonsons2011-07-081-4/+19
| | | | | | -man. This actually seems to be what groff does. Sort-of. Anyway, it's required to get perlpod pages rendered nicely, so until perlpod stops producing shit, do it. Ok schwarze@.
* Remove the warning for empty bodies of `Sh', `Ss', `SH', and `SS'. ThisKristaps Dzonsons2011-04-131-7/+4
| | | | | | | | | | | prompted by a TODO by schwarze@, originally from Gleydson Soares, that an empty `SS' was raising an error (it hasn't for some time). It makes sense these shouldn't warn, as omitting their contents doesn't change anything in the structure of the document (groff and mandoc specifically account for the whitespace between empty sections). This doesn't change any manuals, which only refer to the line arguments (or possibly next-line, in the case of man(7) syntax).
* Remove a2roffdeco() and mandoc_special() functions and replace them withKristaps Dzonsons2011-04-091-24/+30
| | | | | | | | | | | | | | | | | | a public (mandoc.h) function mandoc_escape(), which merges the functionality of both prior functions. Reason: code duplication. The a2roffdeco() and mandoc_special() functions were pretty much the same thing and both quite complex. This allows one function to receive improvements in (e.g.) subexpression handling and performance, instead of having to replicate functionality. As such, the mandoc_escape() function already handles a superset of the escapes handled in previous versions and has improvements in performance (using strcspn(), for example) and reliable handling of subexpressions. This code Works For Me, but may need work to catch any regressions. Since the benefits are great (leaner code, simpler API), I'd rather have it in-tree than floating as a patch.
* Make empty sections and parts (SH, SS, RS) only produce a warning if itKristaps Dzonsons2011-03-221-2/+4
| | | | has no children. Noted by Brad, added to TODO by schwarze@.