summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/man_validate.c
AgeCommit message (Collapse)Author
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@
2010-08-20Implement a simple, consistent user interface for error handling.Ingo Schwarze
We now have sufficient practical experience to know what we want, so this is intended to be final: - provide -Wlevel (warning, error or fatal) to select what you care about - provide -Wstop to stop after parsing a file with warnings you care about - provide consistent exit status codes for those warnings you care about - fully document what warnings, errors and fatal errors mean - remove all other cruft from the user interface, less is more: - remove all -f knobs along with the whole -f option - remove the old -Werror because calling warnings "fatal" is silly - always finish parsing each file, unless fatal errors prevent that This commit also includes a couple of related simplifications behind the scenes regarding error handling. Feedback and OK kristaps@; Joerg Sonnenberger (NetBSD) and Sascha Wildner (DragonFly BSD) agree with the general direction.
2010-07-25Sync to bsd.lv; in particular, pull in lots of bug fixes.Ingo Schwarze
new features: * support the .in macro in man(7) * support minimal PDF output * support .Sm in mdoc(7) HTML output * support .Vb and .nf in man(7) HTML output * complete the mdoc(7) manual bug fixes: * do not let mdoc(7) .Pp produce a newline before/after .Sh; reported by jmc@ * avoid double blank lines related to man(7) .sp and .br * let man(7) .nf and .fi flush the line; reported by jsg@ and naddy@ * let "\ " produce a non-breaking space; reported by deraadt@ * discard \m colour escape sequences; reported by J.C. Roberts * map undefined 1-character-escapes to the literal character itself maintenance: * express mdoc(7) arguments in terms of an enum for additional type-safety * simplify mandoc_special() and a2roffdeco() * use strcspn in term_word() in place of a manual loop * minor optimisations in the -Tps and -Thtml formatting frontends
2010-06-26merge release 1.10.2Ingo Schwarze
* bug fixes: - interaction of ASCII_HYPH with special chars (found by Ulrich Spoerlein) - handling of roff conditionals (found by Ulrich Spoerlein) - .Bd -offset will no more default to 6n * maintenance: - more caching of .Bd and .Bl arguments for efficiency - deconstify man(7) validation routines - add FreeBSD library names (provided by Ulrich Spoerlein) * start PostScript font-switching
2010-05-26When a word does not fully fit onto the output line, but it containsIngo Schwarze
at least one hyphen, we already had support for breaking the line a the last fitting hyphen. This patch improves this functionality by only breaking at hyphens in free-form text, and by not breaking at hyphens * at the beginning or end of a word or * immediately preceded or followed by another hyphen or * escaped by a preceding backslash. Before this patch, differences in break-at-hyphen support were one of the major sources of noise in automatic comparisons to mdoc(7) groff output. Now, the remaining differences are hard to find among the noise coming from other sources. Where there are still differences, what we do seems to be better than what groff does, see e.g. the chio(1) exchange and position commands for one of the now rare examples. idea and coding by kristaps@ Besides, this was the last substantial code difference left between bsd.lv and openbsd.org. We are now in full sync.
2010-05-23Unified error and warning message system for all of mandoc,Ingo Schwarze
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@.
2010-05-23implement .AT and .UC; from Joerg SonnenbergerIngo Schwarze
2010-05-20Support nested roff instructions:Ingo Schwarze
* allow roff_parseln() to be re-run * allow roff_parseln() to manipulate the line buffer offset * support the offset in the man and mdoc libraries * adapt .if, .ie, .el, .ig, .am* and .de* support * interpret some instructions even in conditional-negative context Coded by kristaps during the last day of the mandoc hackathon. To avoid regressions in the OpenBSD tree, commit this together with some small local additions: * detect roff block end "\}" even on macro lines * actually implement the ".if n" conditional * ignore .ds, .rm and .tr in libroff Also back my old .if/.ie/.el-handling out of libman, reverting: man.h 1.15 man.c 1.25 man_macro.c 1.15 man_validate.c 1.19 man_action.c 1.15 man_term.c 1.28 man_html.c 1.9.
2010-05-16In theory, Kristaps never intended to write a roff parser,Ingo Schwarze
but in practice, most real legacy man(7)uals are using so much low level roff that we can't really get away without at least partially handling some roff instructions. As doing this in man(7) only has become messy and as even some mdoc(7) pages need it, start a minimal partial roff preprocessor. As a first step, move handling of .am[i], .de[i] and .ig there. Do not use the roff preprocessor for new manuals! Now that we have three main parser libraries - roff, man and mdoc - each one having its own error handling is becoming messy, too. Thus, start unifying message handling in one central place, introducing a new generic function mmsg(). coded by kristaps@
2010-05-15removed restriction on integer manual sections in -man;Ingo Schwarze
by kristaps@
2010-05-13Remove the command line option -fno-ign-chars.Ingo Schwarze
This option was not useful, you never want mandoc to die just because there is an invalid character in the input file, neither in production nor when linting: a warning is sufficient. This was particularly annoying because it was part of -fstrict and could not be switched off. "less is more" kristaps@
2010-04-25Implement roff conditional instructions .if .ie .el, in man(7) only for now;Ingo Schwarze
fixing OpenBSD::PackageName(3p) and friends for espie@.
2010-04-07Merge the good parts of 1.9.23,Ingo Schwarze
avoid the bad parts of 1.9.23, and keep local patches. Input in general: * Basic handling of roff-style font escapes \f, \F. * Quoted punctuation does not count as punctuation. mdoc(7) parser: * Make .Pf callable; noted by Claus Assmann. * Let .Bd and .Bl ignore unknown arguments; noted by deraadt@. * Do not warn when .Er is used outside certain sections. * Replace mdoc_node_free[list] by mdoc_node_delete. * Replace #define by enum for rew*() return values. man(7) parser: * When .TH is missing, use default section and date. Output in general: * Curly braces do not count as punctuation. * No space after .Fl w/o args when a macro follows on the same line. HTML output: * Unify PAIR_*_INIT macros, introduce new PAIR_ID_INIT(). * Print whitespace after, not before .Vt .Fn .Ft .Fo. Checked that all manuals in base still build.
2010-04-03When we have no title in man(7), just use "unknown". No need to bail.Ingo Schwarze
ok deraadt@
2010-04-02merge 1.9.20, keeping local patchesIngo Schwarze
* prevent roff instructions in man(7) from clobbering scopes and line modes (noted by Sascha Wildner) * handle leading punctuation in mdoc(7) blocks and line macros (looks good in principle, but is causing some fallout in OpenBSD, so i will disable it locally for now with the next commit)
2010-03-29merge 1.9.19, keeping local patchesIngo Schwarze
* scoping fixes for roff instructions * accept apostroph in place of dot as a macro control character * accept tabs between the control character and the macro name * check that man(7) .TH titles use capital letters
2010-03-26merge 1.9.17, keeping local patchesIngo Schwarze
* much improved pod2man support and low-level roff robustness * have -Tlint imply -Wall and -fstrict * use fewer macros and more enum in libman * and various bug fixes
2010-03-02Accept the non-standard macros .Sp (similar to .sp)Ingo Schwarze
and .Vb/.Ve (similar to .nf/.fi) in man(7) mode. These are not intended to be used manually, but they allow us to properly render man(7) code autogenerated by pod2man(1), making Perl and OpenSSL happy in our tree.
2010-02-26The groff_man(7) manual says "the first line of text following" .TP isIngo Schwarze
used as a label, not "the first line following", so allow (some kinds of) intervening macros - some people actually put macros in between. On the other hand, when there is no text line before the next block macro, that is, when the .TP block ends without any text line, then something *is* broken, so still error out in that case.