aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_validate.c
Commit message (Collapse)AuthorAgeFilesLines
* One of the WARNING messages has to use the word "section" twice in twoIngo Schwarze2013-09-161-2/+3
| | | | | | | | | | different meanings, that cannot be helped. But we can make this less confusing by stating that the second instance refers to stuff like (2), (3), and (9), and by adding the sections header the first instance refers to, for example ERRORS or RETURN VALUES. Source for confusion noticed by Jan Stary <hans at stare dot cz>, better wording suggested by jmc@, tweaked by me.
* Put .%C before .%D in .Rs outputIngo Schwarze2013-08-051-3/+3
| | | | | | | because that's the usual order in formal citations. My patch that was accepted into groff by Werner Lemberg uses the same order, so keep groff and mandoc consistent.
* Cleanup naming of local variables to make the code easier on the eye:Ingo Schwarze2012-11-171-17/+17
| | | | | | | | 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
* Warn about unknown volume or arch in Dt macro arguments;Ingo Schwarze2012-11-161-2/+2
| | | | patch written by Nicolas Joly <njoly at pasteur dot fr>.
* Fix handling of paragraph macros inside lists:Ingo Schwarze2012-07-181-5/+34
| | | | | | | * When they are trailing the last item, move them outside the list. * When they are trailing any other none-compact item, drop them. OpenBSD rev. mdoc_validate.c 1.107, mdoc.c 1.91
* Several -mdoc parser improvements related to vertical spacing:Ingo Schwarze2012-07-161-7/+37
| | | | | | | | | | * So far, .Pp and .Lp were removed before paragraph type blocks. * Now also remove .br before paragraph type blocks. * Treat .Lp as a paragraph like .Pp, so remove .Pp, .Lp, .br before it. * Do not treat .sp as a paragraph, don't remove anything before it. * After .Sh, .Ss, .Pp, and .Lp, remove .Pp, .Lp, .sp, .br, and blank lines. * After .sp and .br, remove .br. OpenBSD rev. mdoc.c 1.89 and mdoc_validate.c 1.106
* The post_nm() validation function crashed when the first .Nm child nodeIngo Schwarze2012-07-121-13/+18
| | | | | | | | | | was a non-text node. Fix this by rewriting post_nm() to always set the meta name to UNKNOWN when the name is missing or unusable. While here, make MANDOCERR_NONAME an ERROR, as it usually renders the page content unintelligible. Bug reported by Maxim <Belooussov at gmail dot com>, thanks. OpenBSD rev. 1.105
* fix position and formatting of %U;Ingo Schwarze2012-07-111-3/+3
| | | | OpenBSD rev. 1.104 and 1.145, respectively
* * implement -Tman .Bl -item -inset -diag -ohang -dash -hyphen -enum .ItIngo Schwarze2012-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 theIngo Schwarze2012-05-271-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. "Please check them in and I'll look into them later!" kristaps@
* update Copyright years according to the CVS logs; no code changeIngo Schwarze2012-05-271-2/+2
|
* Make the `-width' field to `Bl' not puke if it doesn't have an argument.Kristaps Dzonsons2012-03-231-3/+8
| | | | This makes mandoc work much, much nicer with Mac OSX manpages.
* When processing .Sh HEAD, as soon as we know which section this is,Ingo Schwarze2011-12-031-1/+16
| | | | | | | | | | | 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). OK and comment requested by kristaps@.
* In man(7), when no explicit volume name is given, use the defaultIngo Schwarze2011-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
* Improve misleading comment:Ingo Schwarze2011-11-191-2/+6
| | | | | | | | * Not sure there were any text nodes, might have been other stuff instead. * Not sure it was just one node, maybe several were deleted. * No problem if some nodes were deleted, as long as some valid ones are left. * We do not leave early, but after cleaning out all the crap. * We are not "bailing", but we consider the block valid after cleanup.
* Bail out explicitly on invalid .Rs content like:Joerg Sonnenberger2011-11-181-1/+5
| | | | | | | | .Rs plain text .Re This avoids a crash on invalid.
* 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@.
* Make -man check for tabs correctly print the column.VERSION_1_11_7Kristaps Dzonsons2011-09-021-2/+2
|
* Avoid incorrect casting by using an implicit cast. Reported by ThomasKristaps Dzonsons2011-08-191-3/+3
| | | | Klausner.
* Fixed mingw compatibility where the "z" printf() modifier isn'tKristaps Dzonsons2011-08-161-3/+3
| | | | | recognised. It's easier to make these u_int than to jump through hoops for a special formatter.
* Allow `Sx' and `Ss' to have child nodes. Fixes manuals in NetBSD.Kristaps Dzonsons2011-08-101-35/+42
| | | | | | Originally pointed out by joerg@ then again by Thomas Klausner by way of Nicolas Joy. Note: don't use these constructions as you can't link to the sections with `Sx'.
* Move checking of escapes into roff.c, where we're already steppingKristaps Dzonsons2011-07-261-32/+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-2/+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 `struct roff' be passed into libmdoc and libman upon creation.Kristaps Dzonsons2011-07-181-2/+2
| | | | | This is required for supporting in-line equations. While here, push registers properly into roff and add an set/get/mod interface.
* No code change: fixing spelling errors. From a patch by uqs@. Thanks!Kristaps Dzonsons2011-04-301-2/+2
|
* Remove the warning for empty bodies of `Sh', `Ss', `SH', and `SS'. ThisKristaps Dzonsons2011-04-131-3/+3
| | | | | | | | | | | 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-12/+20
| | | | | | | | | | | | | | | | | | 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 uname have its return value checked for -1 (POSIX style), notKristaps Dzonsons2011-04-031-2/+2
| | | | non-zero. From a PR by Yuri Pankov, ok schwarze@.
* libmdoc.h and libman.h were including mdoc.h and man.h, respectively.Kristaps Dzonsons2011-03-221-1/+2
| | | | | Don't have them do that (includes in header files = faugh), and have individual files directly include these files.
* Consolidate messages. Have all parse-time messages (in libmdoc,Kristaps Dzonsons2011-03-201-11/+11
| | | | | | | | | libroff, etc., etc.) route into mandoc_msg() and mandoc_vmsg(), for the time being in libmandoc.h. This requires struct mparse to be passed into the allocation routines instead of mandocmsg and a void pointer. Then, move some of the functionality of the old mmsg() into read.c's mparse_mmsg() (check against wlevel and setting of file_status) and use main.c's mmsg() as simply a printing tool.
* Note that mdoc_valids[] is static.Kristaps Dzonsons2011-03-171-2/+2
|
* Clean-up in libmdoc: fix last checks for mdoc_*msg return value, thenKristaps Dzonsons2011-03-171-8/+7
| | | | | make mdoc_vmsg not return an int. libmdoc is now completely clean of return-value checks from the message subsystem.
* Move mdoc_macro2len() into mdoc_validate.c as macro2len(), as that's theKristaps Dzonsons2011-03-171-4/+97
| | | | only place that it's being used.
* Move mdoc_str2sec() into mdoc_validate.c as a2sec(), as that's the onlyKristaps Dzonsons2011-03-171-2/+39
| | | | place that it's being used.
* Make lint shut up a little bit.Kristaps Dzonsons2011-03-151-2/+3
|
* Clean up date handling,Ingo Schwarze2011-03-071-15/+13
| | | | | | | | | | | | 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@
* Allow -man to process EQN as well. Also fix a segfault in missing caseKristaps Dzonsons2011-02-091-1/+3
| | | | statements in the post-handler for EQN in -mdoc and -man.
* Add initial libmdoc and libman top-most machinery for accepting TBLKristaps Dzonsons2011-02-061-1/+3
| | | | | directives. For now this will just ignore them (except for -Ttree, which just notes that an EQN's been accepted).
* If `Ns' is specified on its own line, it should be ignored. This isKristaps Dzonsons2011-02-021-2/+13
| | | | | shitty groff behaviour. Do the same, but raise a warning to this effect. This from a TODO noted by schwarze@.
* Push capitalisation of `Bx' second argument into validator, where it belongs.Kristaps Dzonsons2011-01-251-2/+22
|
* If %B is specified, quote %T. Noted by schwarze@ in the TODO.Kristaps Dzonsons2011-01-251-3/+3
|
* Check argument count validation for all in_line() macros.Ingo 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@
* Partial cleanup of argument count validation in mdoc(7):Ingo Schwarze2011-01-031-66/+68
| | | | | | | | | | | | * 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.
* Add table processing structures to -mdoc. This consists of anKristaps Dzonsons2011-01-011-4/+17
| | | | | | external-facing function mdoc_addspan(), then various bits to prohibit printing and scanning (this requires some if's to be converted into switch's).
* Implement schwarze@'s much more elegant version of my %T/%J fix.Kristaps Dzonsons2010-12-251-17/+4
|
* Specifying both %T and %J in an `Rs' block causes the title to be quotedKristaps Dzonsons2010-12-251-2/+17
| | | | | instead of underlined. This only happens in -Tascii, as -T[x]html both underlines and italicises.
* As per schwarze@'s suggestions, roll back the refcount structure inKristaps Dzonsons2010-12-241-79/+59
| | | | | | | | favour of a simpler shim for normalised data in the node allocation and free routines. This removes the need to bump and copy references within validator handlers, removes a pointer redirect, and also kills the refcount structure itself. Data is assumed to "live" either in a MDOC_BLOCK or MDOC_ELEM and is copied accordingly.
* At the beginning of .Bl, .Sm is allowed,Ingo Schwarze2010-12-221-4/+6
| | | | | and .Lp should cause a warning, not an error. "I don't suppose I mind this." kristaps@
* Implement reference-counted version of original union mdoc_data. ThisKristaps Dzonsons2010-12-221-75/+77
| | | | | | | simplifies clean-up and allows for more types without extra hassle. Also made in-line literal types in -T[x]html use CODE instead of SPAN to match how literal blocks use PRE.
* Migrate `An' to use a pointer in its data, like everybody else. This isKristaps Dzonsons2010-12-161-5/+8
| | | | | the first step to having a simpler ref-counted system for "data" associated with a node.