summaryrefslogtreecommitdiffstats
path: root/mdoc_validate.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix handling of paragraph macros inside lists:Ingo Schwarze2012-07-181-4/+33
| | | | | | | * 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-6/+36
| | | | | | | | | | * 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-12/+17
| | | | | | | | | | 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-2/+2
| | | | OpenBSD rev. 1.104 and 1.145, respectively
* * implement -Tman .Bl -item -inset -diag -ohang -dash -hyphen -enum .ItIngo Schwarze2012-07-101-4/+16
| | | | | | | | | | * 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-11/+12
| | | | | | | | | | 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-1/+1
|
* Make the `-width' field to `Bl' not puke if it doesn't have an argument.Kristaps Dzonsons2012-03-231-2/+7
| | | | 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-0/+15
| | | | | | | | | | | 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-1/+1
| | | | | | | | | | | | 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-1/+5
| | | | | | | | * 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-0/+4
| | | | | | | | .Rs plain text .Re This avoids a crash on invalid.
* Remove a bunch of useless assignments,Ingo Schwarze2011-10-161-5/+4
| | | | | | | 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-1/+1
|
* Avoid incorrect casting by using an implicit cast. Reported by ThomasKristaps Dzonsons2011-08-191-2/+2
| | | | Klausner.
* Fixed mingw compatibility where the "z" printf() modifier isn'tKristaps Dzonsons2011-08-161-2/+2
| | | | | 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-34/+41
| | | | | | 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-31/+5
| | | | | 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/+1
| | | | | | | | | | | | 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-1/+1
| | | | | 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-1/+1
|
* Remove the warning for empty bodies of `Sh', `Ss', `SH', and `SS'. ThisKristaps Dzonsons2011-04-131-2/+2
| | | | | | | | | | | 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-11/+19
| | | | | | | | | | | | | | | | | | 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-1/+1
| | | | 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-0/+1
| | | | | 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-10/+10
| | | | | | | | | 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-1/+1
|
* Clean-up in libmdoc: fix last checks for mdoc_*msg return value, thenKristaps Dzonsons2011-03-171-7/+6
| | | | | 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-3/+96
| | | | only place that it's being used.
* Move mdoc_str2sec() into mdoc_validate.c as a2sec(), as that's the onlyKristaps Dzonsons2011-03-171-1/+38
| | | | place that it's being used.
* Make lint shut up a little bit.Kristaps Dzonsons2011-03-151-1/+2
|
* Clean up date handling,Ingo Schwarze2011-03-071-14/+12
| | | | | | | | | | | | 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-0/+2
| | | | 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-0/+2
| | | | | 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-1/+12
| | | | | 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-1/+21
|
* If %B is specified, quote %T. Noted by schwarze@ in the TODO.Kristaps Dzonsons2011-01-251-2/+2
|
* Check argument count validation for all in_line() macros.Ingo Schwarze2011-01-221-36/+20
| | | | | | | | 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-65/+67
| | | | | | | | | | | | * 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-3/+16
| | | | | | 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-16/+3
|
* Specifying both %T and %J in an `Rs' block causes the title to be quotedKristaps Dzonsons2010-12-251-1/+16
| | | | | 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-78/+58
| | | | | | | | 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-3/+5
| | | | | 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-74/+76
| | | | | | | 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-4/+7
| | | | | the first step to having a simpler ref-counted system for "data" associated with a node.
* Back out last: apparently `Bl', `It', and `Pp' need a little bit moreKristaps Dzonsons2010-12-161-17/+2
| | | | study to see exactly what's legal and what's not.
* Allow `It' to have a trailing paragraph if the surrounding list is inKristaps Dzonsons2010-12-161-2/+17
| | | | compact mode.
* First, make `Pp' (next to `Sm') be allowed as the first element of aKristaps Dzonsons2010-12-161-13/+15
| | | | | | | | | | | `Bl' (before any `It' have been invoked). Next, have the existence of either macro raise a warning, as it's technically not legal according to mdoc.7. Second, delete any `Pp' as the first element of a `Bl' (i.e., before an `It') ONLY when -compact has not been specified. This matches with the latest version of groff. This deletion happens prior to the above check, so double-warnings will not be issued.
* Add a "last child" member of struct mdoc_node.Kristaps Dzonsons2010-12-151-6/+26
| | | | | | | Remove `Pp' or `Lp' if it is the FIRST or LAST child of an `Sh' or `Sh' body. Make "skipping paragraph" be an error, not a warning, as information (an invoked macro) is ignored.