summaryrefslogtreecommitdiffstats
path: root/usr.bin/mandoc/mdoc_validate.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* * implement -Tman .Bl -item -inset -diag -ohang -dash -hyphen -enum .Itschwarze2012-07-101-5/+17
| | | | | | | | | | * fix -Tman .Bl -bullet .It * adjust the -Tascii .Bl -bullet -dash -hyphen .It default and minimum width to new groff standards, it changed from 4n (in groff 1.15) to 2n (in groff 1.21) * same for -Tascii -enum, it changed from 5n to 2n * use -hang formatting for -Tascii -enum -width 2n * for -Tascii -enum, the default is -width 3n
* Support -Ios='OpenBSD 5.1' to override uname(3) as the source of theschwarze2012-05-241-12/+13
| | | | | | | | default value for the mdoc(7) .Os macro. Needed for man.cgi on the OpenBSD website. Problem with man.cgi first noticed by deraadt@; beck@ and deraadt@ agree with the way to solve the issue.
* Two bugfixes regarding the -width and -offset macro arguments:schwarze2012-04-151-4/+9
| | | | | | | | | | | | 1) They consume the next argument even if it starts with a dash. 2) When -width is the last argument on the line such that the actual width argument is missing, downgrade from a fatal to a non-fatal error, just like for -offset. The formatting still doesn't agree with groff, but at least we don't die any longer. Item 2 was observed and that part of the patch coded by kristaps@, who found lots of instances of this particular formatting error in Mac OSX manuals.
* remove useless "#ifdef __linux__" that crept in,schwarze2011-12-031-1/+11
| | | | and trivial sync to bsd.lv (two new comments)
* In man(7), when no explicit volume name is given, use the defaultschwarze2011-12-021-2/+2
| | | | | | | | | | | | 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
* Avoid a NULL pointer access if an .Rs block body contains nothingschwarze2011-11-191-1/+9
| | | | | | but invalid nodes. Output still differs a lot from groff, but at least let's not crash. Problem found and patch provided by joerg@, thanks!
* When processing .Sh HEAD, as soon as we know which section this is,schwarze2011-11-161-1/+6
| | | | | | | | | | fix up the section attributes of the HEAD, it's parent BLOCK, and all its (text) children. This is required because the section attributes get set when each node is allocated, i.e. before processing the content of the node itself. Thus, the listed nodes got the section attribute of the preceding section. No need to fix up the BODY, all is fine there already. Found while implementing TYPE_Sh for mandocdb(8).
* Remove a bunch of useless assignments,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@.
* sync to version 1.11.7 from kristaps@schwarze2011-09-181-71/+52
| | | | | | | | 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
* sync to version 1.11.5:schwarze2011-09-181-2/+2
| | | | | | | | adding an implementation of the eqn(7) language by kristaps@ So far, only .EQ/.EN blocks are handled, in-line equations are not, and rendering is not yet very pretty, but the parser is fairly complete.
* Merge release 1.11.3, almost all code by kristaps@:schwarze2011-05-291-14/+22
| | | | | | | | | * 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.
* Merge version 1.11.1:schwarze2011-04-241-14/+15
| | | | | | | | | | | | | | 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.
* Merge version 1.10.10:schwarze2011-04-211-13/+143
| | | | | | | | | | 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
* Import the foundation for eqn(7) support.schwarze2011-03-201-1/+5
| | | | | | | | 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.
* Clean up date handling,schwarze2011-03-071-15/+14
| | | | | | | | | | | | 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@
* If .Ns is specified on its own line, ignore it, like groff does;schwarze2011-02-061-2/+13
| | | | from kristaps@.
* Make .Bx accept not more than two arguments.schwarze2011-01-301-2/+22
| | | | | | | Convert the first character of the second argument to uppercase. Append the second argument with a hyphen. Improves chpass(1), column(1), fstat(1), ... from kristaps@
* Like in groff, if .%B is specified, quote .%T; from kristaps@.schwarze2011-01-301-3/+3
|
* Check argument count validation for all in_line() macros.schwarze2011-01-221-37/+21
| | | | | | | | Most empty in_line() macros are already removed by the parser, so there is no need to check again in mdoc_validate.c. This also downgrades almost all remaining argument count issues from ERROR to WARNING. ok kristaps@
* Merge kristaps@' cleaner tbl integration, removing mine;schwarze2011-01-041-23/+18
| | | | there are still a few bugs, but fixing these will be easier in tree.
* Partial cleanup of argument count validation in mdoc(7):schwarze2011-01-031-65/+66
| | | | | | | | | | | | * Do not segfault on empty .Db, .Rs, .Sm, and .St. * Let check_count() really throw the requested level, not always ERROR. * Downgrade most bad argument counts from ERROR to WARNING. * And some related internal cleanup. Looks fine to kristaps@. Note that the macros using eerr_ge1() still need to be checked at a later time; but as all the others are done, let's use what we already have.
* Reorg by Kristaps: In libmdoc, replace the union of pointers to structsschwarze2010-12-291-93/+62
| | | | | | | of macro-specific data by a pointer to a union of structs, which makes the code simpler and more robust at the expense of a small memory overhead. Merging was somewhat difficult because we mustn't break tbl(1) support which the bsd.lv version does not yet have.
* Behave more like groff (both old and new): Specifying both .%T and .%J inschwarze2010-12-261-2/+17
| | | | | | an .Rs block causes the title to be quoted instead of underlined, such that journal title and article title appear visually different. Original diff from kristaps@, simplified by me, tweaked again by kristaps@.
* Migrate .An to use a pointer to its data, like everybody else.schwarze2010-12-211-5/+8
| | | | | In preparation for a simpler ref-counted system for node data. From kristaps@.
* Vertical spacing improvements from kristaps@, small tweaks by me:schwarze2010-12-211-21/+45
| | | | | | | Add a "last child" member to struct mdoc_node. Remove .Pp or .Lp if it is the first or last child of an .Sh or .Ss body. Thus, no need to do the same in the front-ends any longer. Tolerate some cases of .Pp inside .Bl.
* Allow quote macros (`Op', `Aq', `Bq', `Dq', `Pq', `Ql', `Qq', `Sq', andschwarze2010-12-091-10/+10
| | | | | | | | | `Brq') to have zero arguments without warning. This makes sense because the multi-line quote macros (`Oo/Oc' etc.) allow zero children anyway. Furthermore, the documentation doesn't state that they're required to have children. Reported by Alex Kozlov, patch from kristaps@.
* Complete the merge of bsd.lv version 1.10.7:schwarze2010-12-071-3/+3
| | | | No more functional changes, just sync ordering, comments and white space.
* Merge mdoc_action.c into mdoc_validate.c, because having two places to doschwarze2010-12-011-295/+995
| | | | | | basically the same things just causes code duplication and confusion. Work by kristaps@, including a few bugfixes he found during the merge, and reapplying OpenBSD changes on top.
* Downgrade nearly 20 ERRORS to WARNINGS.schwarze2010-10-261-6/+4
| | | | | | | | All these indicate problems in the mdoc(7) or man(7) source code, but they can't cause relevant information loss or clobbered formatting. While here, error message improve wording and make it more uniform, don't throw MANDOCERR_NOWIDTHARG twice when there is one single issue, and consolidate MANDOCERR_WIDTHARG into MANDOCERR_IGNARGV.
* Do not throw FATAL errors when there is no need to:schwarze2010-10-241-8/+4
| | | | | | | | - when encountering nested displays (.Bd containing .Bd, .D1, .D1) - when a block end macro was forgotten - when ending a block that was never started - when the uname(3) system call failed along with a little related cleanup
* use proper message in case of multiple arguments to .Anschwarze2010-10-231-5/+6
| | | | from kristaps@
* cleanup mdoc(7) validation code: use real functions, not macrosschwarze2010-10-231-82/+124
| | | | from kristaps@
* Support tbl(1) code embedded into mdoc(7) input files.schwarze2010-10-161-1/+3
| | | | | | Very similar to what i have done in man(7) yesterday. Allows to build cpu(4) on HPPA, wi(4), and phantasia(6). Now we are able to build all tbl code in base.
* Merge the last bits of 1.10.6 (released today), most were already in:schwarze2010-09-271-5/+30
| | | | | | | | | | | | * ignore double-.Pp * ignore .Pp before .Bd and .Bl (unless -compact in specified) * avoid double blank line upon .Pp, .br and friends in literal context * cast enums to int when passing them to exit(3) to please lint(1) While merging, fix a regression introduced by kristaps@: Outside literal mode, double blank lines must both be printed. To achieve this again after kristaps@ improvements in 1.10.6, treat such blank lines as .sp (instead of .Pp as in 1.10.5) and drop .Pp before .sp just like dropping .Pp before .Pp.
* Make .Pp .Lp .br not FATAL when having arguments;schwarze2010-09-201-4/+4
| | | | From kristaps@
* Implement a simple, consistent user interface for error handling.schwarze2010-08-201-7/+3
| | | | | | | | | | | | | | | | | 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.
* Merge bsd.lv version 1.10.5: last larger batch of bug fixes before release.schwarze2010-07-311-2/+2
| | | | | | | | | | | | | NOT including Kristaps' .Bd -literal changes which cause regressions. Features: * -Tpdf now fully working Bugfixes: * proper handling of quoted strings by .ds in roff(7) * allow empty .Dd * make .Sm start no-spacing after the first output word * underline .Ad * minor fixes in -Thtml and some optimisations in terminal output.
* Sync to bsd.lv; in particular, pull in lots of bug fixes.schwarze2010-07-251-22/+23
| | | | | | | | | | | | | | | | | | | | | 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
* Merge release 1.10.4 (all code by kristaps@), providing four new features:schwarze2010-07-131-101/+159
| | | | | | | | | | 1) Proper .Bk support: allow output line breaks at input line breaks, but keep input lines together in the output, finally fixing synopses like aucat(1), mail(1) and tmux(1). 2) Mostly finished -Tps (PostScript) output. 3) Implement -Thtml output for .Nm blocks and .Bk -words. 4) Allow iterative interpolation of user-defined roff(7) strings. Also contains some minor bugfixes and some performance improvements.
* Not only for -tag lists, but for -hang, -ohang, -inset, -diag,schwarze2010-07-021-7/+4
| | | | | | | and -item list as well, empty bodies are OK, they do not even warrant a warning, much less the error they were throwing. According to kristaps, joerg@ also brought this up some time ago. ok kristaps@ jmc@
* Full .nr nS support, unbreaking the kernel manuals.schwarze2010-06-271-1/+3
| | | | | | | | | Kristaps coded this from scratch after reading my .nr patch; it is simpler and more powerful. Registers live in struct regset in regs.h, struct man and struct mdoc contain pointers to it. The nS register is cleared when parsing .Sh. Frontends respect the MDOC_SYNPRETTY flag set in mdoc node_alloc.
* minor .Bk fixes:schwarze2010-06-271-4/+4
| | | | | | | | * do not print invalid arguments verbatim (no groffs prints them, either) * do not trigger TERMP_PREKEEP twice * do not die from invlid arguments (groff won't die, either) * continue to ignore even valid arguments (just like groff) ok kristaps@ on the previous version, before removing my last bug ;)
* merge release 1.10.2schwarze2010-06-261-60/+124
| | | | | | | | | | | | * 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
* Merge bsd.lv version 1.10.1 (to be released soon).schwarze2010-06-061-153/+188
| | | | | | | | | | | | | | | | | | | | The main step forward is that this now has *much* better .Bl -column support, now supporting many manuals that previously errored out without producing any output. Other fixes include: * do not die from multiple list types, use the first and warn * in .Bl without a type, default to -item * various tweaks to .Dt * fix .In, .Fd, .Ft, .Fn and .Fo formatting * some documentation fixes and additions * and fix a couple of bugs reported by Ulrich Spoerlein: * better support for roff block-end "\}" without a preceding dot * .In must not break the line outside SYNOPSIS * spelling in some error messages While merging, fix one regression in .In spacing that needs to go to bsd.lv, too.
* Merge bsd.lv release 1.10.0,schwarze2010-06-061-8/+18
| | | | | | | | | | | | | | | | which is mostly the post-hackathon release, bringing in the OpenBSD changes to bsd.lv, but which also has a few additional minor fixes: * .Lb is an in-line macro, not in_line_eoln * .Bt, .Ud now warn when discarding arguments * allow bad -man dates to flow verbatim into the front-ends - so far all reported by Ulrich Spoerlein * .Ar, .Fl and .Li starting with closing punctuation emit an empty element * empty .Li macros print nothing, but may cause spacing * proper EOS handling for .Bt, .Ex, .Rv, and .Ud. * cleanup: collapse posts_xr into posts_wtext (which is the same) * efficiency: very simple table lookup for roff.c
* When a word does not fully fit onto the output line, but it containsschwarze2010-05-261-2/+2
| | | | | | | | | | | | | | | | | | | | | | | 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.
* lift 64-byte max width for Sh (now BUFSIZ); from kristaps@schwarze2010-05-241-4/+5
|
* Increase performance by saving the list type in struct mdoc_node.schwarze2010-05-241-20/+12
| | | | | | | | | | | This will eventually be used so that mdoc_macro can know whether to dump list line arguments into the body (`Bl -column' overflowing). Remove a2list() and arg_listtype() because of this. From kristaps@. While merging, fix a regression in mdoc_term.c, print_bvspace(): The bsd.lv version of this broke vertical spacing in .Bl -column.
* Unified error and warning message system for all of mandoc,schwarze2010-05-231-99/+149
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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@.
* allow non-numeric manual sections in -mdoc;schwarze2010-05-151-10/+9
| | | | | while here, allow LIBRARY in section 9; by kristaps@