-/* $Id: mdoc_validate.c,v 1.76 2010/05/14 17:31:25 kristaps Exp $ */
+/* $Id: mdoc_validate.c,v 1.78 2010/05/15 16:24:38 kristaps Exp $ */
/*
- * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
+ * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
#include <assert.h>
#include <ctype.h>
#include <limits.h>
-#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
};
static int check_parent(PRE_ARGS, enum mdoct, enum mdoc_type);
-static int check_sec(PRE_ARGS, ...);
static int check_stdarg(PRE_ARGS);
static int check_text(struct mdoc *, int, int, const char *);
static int check_argv(struct mdoc *,
static int pre_dd(PRE_ARGS);
static int pre_display(PRE_ARGS);
static int pre_dt(PRE_ARGS);
-static int pre_fd(PRE_ARGS);
static int pre_it(PRE_ARGS);
-static int pre_lb(PRE_ARGS);
static int pre_os(PRE_ARGS);
static int pre_rv(PRE_ARGS);
static int pre_sh(PRE_ARGS);
static v_pre pres_dt[] = { pre_dt, NULL };
static v_pre pres_er[] = { NULL, NULL };
static v_pre pres_ex[] = { NULL, NULL };
-static v_pre pres_fd[] = { pre_fd, NULL };
+static v_pre pres_fd[] = { NULL, NULL };
static v_pre pres_it[] = { pre_it, NULL };
-static v_pre pres_lb[] = { pre_lb, NULL };
+static v_pre pres_lb[] = { NULL, NULL };
static v_pre pres_os[] = { pre_os, NULL };
static v_pre pres_rv[] = { pre_rv, NULL };
static v_pre pres_sh[] = { pre_sh, NULL };
}
-static int
-check_sec(PRE_ARGS, ...)
-{
- enum mdoc_sec sec;
- va_list ap;
-
- va_start(ap, n);
-
- for (;;) {
- /* LINTED */
- sec = (enum mdoc_sec)va_arg(ap, int);
- if (SEC_CUSTOM == sec)
- break;
- if (sec != mdoc->lastsec)
- continue;
- va_end(ap);
- return(1);
- }
-
- va_end(ap);
- return(mdoc_nwarn(mdoc, n, EBADSEC));
-}
-
-
static int
check_args(struct mdoc *m, const struct mdoc_node *n)
{
}
-static int
-pre_lb(PRE_ARGS)
-{
-
- return(check_sec(mdoc, n, SEC_LIBRARY, SEC_CUSTOM));
-}
-
-
static int
pre_rv(PRE_ARGS)
{
/*
* Check particular section/manual conventions. LIBRARY can
- * only occur in msec 2, 3 (TODO: are there more of these?).
+ * only occur in manual section 2, 3, and 9.
*/
switch (sec) {
case (SEC_LIBRARY):
- switch (mdoc->meta.msec) {
- case (2):
- /* FALLTHROUGH */
- case (3):
+ assert(mdoc->meta.msec);
+ if (*mdoc->meta.msec == '2')
break;
- default:
- return(mdoc_nwarn(mdoc, mdoc->last, EWRONGMSEC));
- }
- break;
+ if (*mdoc->meta.msec == '3')
+ break;
+ if (*mdoc->meta.msec == '9')
+ break;
+ return(mdoc_nwarn(mdoc, mdoc->last, EWRONGMSEC));
default:
break;
}
return(1);
}
-
-
-static int
-pre_fd(PRE_ARGS)
-{
-
- return(check_sec(mdoc, n, SEC_SYNOPSIS, SEC_CUSTOM));
-}