-/* $Id: mdoc_validate.c,v 1.84 2010/05/26 10:39:35 kristaps Exp $ */
+/* $Id: mdoc_validate.c,v 1.88 2010/05/31 10:28:04 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
static int post_bf(POST_ARGS);
static int post_bl(POST_ARGS);
static int post_bl_head(POST_ARGS);
+static int post_dt(POST_ARGS);
static int post_it(POST_ARGS);
static int post_lb(POST_ARGS);
static int post_nm(POST_ARGS);
static v_post posts_bl[] = { bwarn_ge1, post_bl, NULL };
static v_post posts_bool[] = { eerr_eq1, ebool, NULL };
static v_post posts_eoln[] = { post_eoln, NULL };
+static v_post posts_dt[] = { post_dt, NULL };
static v_post posts_fo[] = { hwarn_eq1, bwarn_ge1, NULL };
static v_post posts_it[] = { post_it, NULL };
static v_post posts_lb[] = { eerr_eq1, post_lb, NULL };
const struct valids mdoc_valids[MDOC_MAX] = {
{ NULL, NULL }, /* Ap */
{ pres_dd, posts_text }, /* Dd */
- { pres_dt, NULL }, /* Dt */
+ { pres_dt, posts_dt }, /* Dt */
{ pres_os, NULL }, /* Os */
{ pres_sh, posts_sh }, /* Sh */
{ pres_ss, posts_ss }, /* Ss */
{ NULL, posts_notext }, /* br */
{ NULL, posts_sp }, /* sp */
{ NULL, posts_text1 }, /* %U */
+ { NULL, NULL }, /* Ta */
};
static int
-pre_dt(PRE_ARGS)
+post_dt(POST_ARGS)
{
+ const struct mdoc_node *nn;
+ const char *p;
+
+ if (NULL != (nn = mdoc->last->child))
+ for (p = nn->string; *p; p++) {
+ if (toupper((u_char)*p) == *p)
+ continue;
+ if ( ! mdoc_nmsg(mdoc, nn, MANDOCERR_UPPERCASE))
+ return(0);
+ break;
+ }
+
+ return(1);
+}
- /* FIXME: make sure is capitalised. */
+
+static int
+pre_dt(PRE_ARGS)
+{
if (0 == mdoc->meta.date || mdoc->meta.os)
if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_PROLOGOOO))
static int
post_it(POST_ARGS)
{
+ /* FIXME: use mdoc_list! */
int type, i, cols;
struct mdoc_node *n, *c;
return(0);
break;
case (MDOC_Column):
- if (NULL == mdoc->last->head->child)
- if ( ! mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NOARGS))
- return(0);
- if (mdoc->last->body->child)
- if ( ! mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_BODYLOST))
+ assert(NULL == mdoc->last->head->child);
+ if (NULL == mdoc->last->body->child)
+ if ( ! mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NOBODY))
return(0);
+
+ /* Count up the number of columns. */
c = mdoc->last->child;
- for (i = 0; c && MDOC_HEAD == c->type; c = c->next)
- i++;
+ for (i = 0; c; c = c->next)
+ if (MDOC_BODY == c->type)
+ i++;
if (i < cols) {
if ( ! mdoc_vmsg(mdoc, MANDOCERR_ARGCOUNT,