diff options
| author | 2010-07-25 18:05:54 +0000 | |
|---|---|---|
| committer | 2010-07-25 18:05:54 +0000 | |
| commit | ddce0b0ca1b3ae66643ffdf36394eda67117ca14 (patch) | |
| tree | a6d88f26f28f3fc7273e7a3f88d4648f6eec6e06 /usr.bin/mandoc/mdoc_validate.c | |
| parent | Missing SCSI_DATA_IN flag in dvd_read_copyright() caused (diff) | |
| download | wireguard-openbsd-ddce0b0ca1b3ae66643ffdf36394eda67117ca14.tar.xz wireguard-openbsd-ddce0b0ca1b3ae66643ffdf36394eda67117ca14.zip | |
Sync to bsd.lv; in particular, pull in lots of bug fixes.
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
Diffstat (limited to 'usr.bin/mandoc/mdoc_validate.c')
| -rw-r--r-- | usr.bin/mandoc/mdoc_validate.c | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c index 2b1fc088bf7..9cffeaae31d 100644 --- a/usr.bin/mandoc/mdoc_validate.c +++ b/usr.bin/mandoc/mdoc_validate.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_validate.c,v 1.65 2010/07/13 01:09:13 schwarze Exp $ */ +/* $Id: mdoc_validate.c,v 1.66 2010/07/25 18:05:54 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -28,7 +28,6 @@ #include "libmandoc.h" /* FIXME: .Bl -diag can't have non-text children in HEAD. */ -/* TODO: ignoring Pp (it's superfluous in some invocations). */ #define PRE_ARGS struct mdoc *mdoc, struct mdoc_node *n #define POST_ARGS struct mdoc *mdoc @@ -450,26 +449,29 @@ check_argv(struct mdoc *m, struct mdoc_node *n, struct mdoc_argv *v) static int -check_text(struct mdoc *mdoc, int line, int pos, char *p) +check_text(struct mdoc *m, int ln, int pos, char *p) { int c; - - /* - * FIXME: we absolutely cannot let \b get through or it will - * destroy some assumptions in terms of format. - */ + size_t sz; for ( ; *p; p++, pos++) { + sz = strcspn(p, "\t\\"); + p += (int)sz; + + if ('\0' == *p) + break; + + pos += (int)sz; + if ('\t' == *p) { - if ( ! (MDOC_LITERAL & mdoc->flags)) - if ( ! mdoc_pmsg(mdoc, line, pos, MANDOCERR_BADCHAR)) - return(0); - } else if ( ! isprint((u_char)*p) && ASCII_HYPH != *p) - if ( ! mdoc_pmsg(mdoc, line, pos, MANDOCERR_BADCHAR)) - return(0); + if (MDOC_LITERAL & m->flags) + continue; + if (mdoc_pmsg(m, ln, pos, MANDOCERR_BADTAB)) + continue; + return(0); + } - if ('\\' != *p) - continue; + /* Check the special character. */ c = mandoc_special(p); if (c) { @@ -478,8 +480,8 @@ check_text(struct mdoc *mdoc, int line, int pos, char *p) continue; } - c = mdoc_pmsg(mdoc, line, pos, MANDOCERR_BADESCAPE); - if ( ! (MDOC_IGN_ESCAPE & mdoc->pflags) && ! c) + c = mdoc_pmsg(m, ln, pos, MANDOCERR_BADESCAPE); + if ( ! (MDOC_IGN_ESCAPE & m->pflags) && ! c) return(c); } @@ -487,8 +489,6 @@ check_text(struct mdoc *mdoc, int line, int pos, char *p) } - - static int check_parent(PRE_ARGS, enum mdoct tok, enum mdoc_type t) { @@ -506,7 +506,6 @@ check_parent(PRE_ARGS, enum mdoct tok, enum mdoc_type t) } - static int pre_display(PRE_ARGS) { @@ -621,6 +620,8 @@ pre_bl(PRE_ARGS) if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_IGNARGV)) return(0); break; + default: + continue; } /* Check: duplicate auxiliary arguments. */ @@ -943,7 +944,7 @@ static int post_bf(POST_ARGS) { struct mdoc_node *np; - int arg; + enum mdocargt arg; /* * Unlike other data pointers, these are "housed" by the HEAD |
