summaryrefslogtreecommitdiffstats
path: root/man_validate.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2011-01-17 00:21:29 +0000
committerIngo Schwarze <schwarze@openbsd.org>2011-01-17 00:21:29 +0000
commit1ab2580800b13bb68e001c47a587d8abe1c2559f (patch)
treeb8a567ef09369b86df47032bd56f1bb8286fcf91 /man_validate.c
parent4043e37d694af94a270f16519fc2fec07e918b37 (diff)
downloadmandoc-1ab2580800b13bb68e001c47a587d8abe1c2559f.tar.gz
Refrain from throwing fatal errors for
* .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@, ok kristaps@.
Diffstat (limited to 'man_validate.c')
-rw-r--r--man_validate.c56
1 files changed, 23 insertions, 33 deletions
diff --git a/man_validate.c b/man_validate.c
index ea80cc40..4afaa758 100644
--- a/man_validate.c
+++ b/man_validate.c
@@ -53,7 +53,6 @@ static int check_part(CHKARGS);
static int check_root(CHKARGS);
static int check_sec(CHKARGS);
static int check_text(CHKARGS);
-static int check_title(CHKARGS);
static int post_AT(CHKARGS);
static int post_fi(CHKARGS);
@@ -70,7 +69,7 @@ static v_check posts_nf[] = { check_eq0, post_nf, NULL };
static v_check posts_par[] = { check_par, NULL };
static v_check posts_part[] = { check_part, NULL };
static v_check posts_sec[] = { check_sec, NULL };
-static v_check posts_th[] = { check_ge2, check_le5, check_title, post_TH, NULL };
+static v_check posts_th[] = { check_ge2, check_le5, post_TH, NULL };
static v_check posts_uc[] = { post_UC, NULL };
static v_check pres_bline[] = { check_bline, NULL };
@@ -200,29 +199,6 @@ check_root(CHKARGS)
static int
-check_title(CHKARGS)
-{
- const char *p;
-
- assert(n->child);
- /* FIXME: is this sufficient? */
- if ('\0' == *n->child->string) {
- man_nmsg(m, n, MANDOCERR_SYNTARGCOUNT);
- return(0);
- }
-
- for (p = n->child->string; '\0' != *p; p++)
- /* Only warn about this once... */
- if (isalpha((u_char)*p) && ! isupper((u_char)*p)) {
- man_nmsg(m, n, MANDOCERR_UPPERCASE);
- break;
- }
-
- return(1);
-}
-
-
-static int
check_text(CHKARGS)
{
char *p;
@@ -266,10 +242,10 @@ check_##name(CHKARGS) \
{ \
if (n->nchild ineq (x)) \
return(1); \
- man_vmsg(m, MANDOCERR_SYNTARGCOUNT, n->line, n->pos, \
+ man_vmsg(m, MANDOCERR_ARGCOUNT, n->line, n->pos, \
"line arguments %s %d (have %d)", \
#ineq, (x), n->nchild); \
- return(0); \
+ return(1); \
}
INEQ_DEFINE(0, ==, eq0)
@@ -396,6 +372,7 @@ check_bline(CHKARGS)
static int
post_TH(CHKARGS)
{
+ const char *p;
if (m->meta.title)
free(m->meta.title);
@@ -415,14 +392,26 @@ post_TH(CHKARGS)
/* ->TITLE<- MSEC DATE SOURCE VOL */
n = n->child;
- assert(n);
- m->meta.title = mandoc_strdup(n->string);
+ if (n && n->string) {
+ for (p = n->string; '\0' != *p; p++) {
+ /* Only warn about this once... */
+ if (isalpha((u_char)*p) && ! isupper((u_char)*p)) {
+ man_nmsg(m, n, MANDOCERR_UPPERCASE);
+ break;
+ }
+ }
+ m->meta.title = mandoc_strdup(n->string);
+ } else
+ m->meta.title = mandoc_strdup("");
/* TITLE ->MSEC<- DATE SOURCE VOL */
- n = n->next;
- assert(n);
- m->meta.msec = mandoc_strdup(n->string);
+ if (n)
+ n = n->next;
+ if (n && n->string)
+ m->meta.msec = mandoc_strdup(n->string);
+ else
+ m->meta.msec = mandoc_strdup("");
/* TITLE MSEC ->DATE<- SOURCE VOL */
@@ -433,7 +422,8 @@ post_TH(CHKARGS)
* string, then use the current date.
*/
- n = n->next;
+ if (n)
+ n = n->next;
if (n && n->string && *n->string) {
m->meta.date = mandoc_a2time
(MTIME_ISO_8601, n->string);