-/* $Id: validate.c,v 1.46 2009/01/21 11:35:26 kristaps Exp $ */
+/* $Id: validate.c,v 1.49 2009/02/21 15:34:46 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
{ pres_prologue, posts_text }, /* Dd */
{ pres_prologue, NULL }, /* Dt */
{ pres_prologue, NULL }, /* Os */
- /* FIXME: NAME section internal ordering. */
{ pres_sh, posts_sh }, /* Sh */
{ pres_ss, posts_ss }, /* Ss */
{ NULL, posts_pp }, /* Pp */
pre_it(struct mdoc *mdoc, struct mdoc_node *node)
{
+ /* TODO: -width attribute must be specified for -tag. */
+ /* TODO: children too big for -width? */
+
if (MDOC_BLOCK != node->type)
return(1);
return(pre_check_parent(mdoc, node, MDOC_Bl, MDOC_BODY));
#define TYPE_NONE (0)
#define TYPE_BODY (1)
#define TYPE_HEAD (2)
+#define TYPE_OHEAD (3)
size_t i, argc;
struct mdoc_node *n;
case (MDOC_Hyphen):
/* FALLTHROUGH */
case (MDOC_Item):
- /* FALLTHROUGH */
- case (MDOC_Column):
type = TYPE_BODY;
sv = n->data.block.argv[(int)i].arg;
break;
+ case (MDOC_Column):
+ type = TYPE_OHEAD;
+ sv = n->data.block.argv[(int)i].arg;
+ break;
default:
break;
}
assert(TYPE_NONE != type);
+ n = mdoc->last->data.block.head;
+ assert(n);
+
if (TYPE_HEAD == type) {
- n = mdoc->last->data.block.head;
- assert(n);
if (NULL == n->child)
if ( ! mdoc_warn(mdoc, WARN_SYNTAX, "macro suggests line parameters"))
return(0);
if ( ! mdoc_warn(mdoc, WARN_SYNTAX, "macro suggests body children"))
return(0);
- return(1);
+ } else if (TYPE_BODY == type) {
+ if (n->child)
+ if ( ! mdoc_warn(mdoc, WARN_SYNTAX, "macro suggests no line parameters"))
+ return(0);
+
+ n = mdoc->last->data.block.body;
+ assert(n);
+ if (NULL == n->child)
+ if ( ! mdoc_warn(mdoc, WARN_SYNTAX, "macro suggests body children"))
+ return(0);
+ } else {
+ if (NULL == n->child)
+ if ( ! mdoc_warn(mdoc, WARN_SYNTAX, "macro suggests line parameters"))
+ return(0);
+
+ n = mdoc->last->data.block.body;
+ assert(n);
+ if (n->child)
+ if ( ! mdoc_warn(mdoc, WARN_SYNTAX, "macro suggests no body children"))
+ return(0);
}
- assert(TYPE_BODY == type);
- assert(mdoc->last->data.block.head);
-
- n = mdoc->last->data.block.head;
- assert(n);
- if (n->child)
- if ( ! mdoc_warn(mdoc, WARN_SYNTAX, "macro suggests no line parameters"))
- return(0);
-
- n = mdoc->last->data.block.body;
- assert(n);
- if (NULL == n->child)
- if ( ! mdoc_warn(mdoc, WARN_SYNTAX, "macro suggests body children"))
- return(0);
-
- assert(-1 != sv);
- if (MDOC_Column != sv)
+ if (MDOC_Column != sv)
return(1);
/* Make sure the number of columns is sane. */
#undef TYPE_NONE
#undef TYPE_BODY
#undef TYPE_HEAD
+#undef TYPE_OHEAD
}