=================================================================== RCS file: /cvs/mandoc/mdoc_validate.c,v retrieving revision 1.104 retrieving revision 1.108 diff -u -p -r1.104 -r1.108 --- mandoc/mdoc_validate.c 2010/07/01 22:56:17 1.104 +++ mandoc/mdoc_validate.c 2010/07/02 17:42:23 1.108 @@ -1,4 +1,4 @@ -/* $Id: mdoc_validate.c,v 1.104 2010/07/01 22:56:17 kristaps Exp $ */ +/* $Id: mdoc_validate.c,v 1.108 2010/07/02 17:42:23 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -849,13 +849,20 @@ static int pre_an(PRE_ARGS) { - if (NULL == n->args || 1 == n->args->argc) + if (NULL == n->args) return(1); - mdoc_vmsg(mdoc, MANDOCERR_SYNTARGCOUNT, - n->line, n->pos, - "line arguments == 1 (have %d)", - n->args->argc); - return(0); + if (n->args->argc > 1) + if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_ARGCOUNT)) + return(0); + + if (MDOC_Split == n->args->argv[0].arg) + n->data.An.auth = AUTH_split; + else if (MDOC_Nosplit == n->args->argv[0].arg) + n->data.An.auth = AUTH_nosplit; + else + abort(); + + return(1); } @@ -931,38 +938,74 @@ pre_dd(PRE_ARGS) static int post_bf(POST_ARGS) { - char *p; - struct mdoc_node *head; + struct mdoc_node *np; + int arg; - if (MDOC_BLOCK != mdoc->last->type) - return(1); + /* + * Unlike other data pointers, these are "housed" by the HEAD + * element, which contains the goods. + */ - head = mdoc->last->head; + if (MDOC_HEAD != mdoc->last->type) { + if (ENDBODY_NOT != mdoc->last->end) { + assert(mdoc->last->pending); + np = mdoc->last->pending->parent->head; + } else if (MDOC_BLOCK != mdoc->last->type) { + np = mdoc->last->parent->head; + } else + np = mdoc->last->head; - if (mdoc->last->args && head->child) { - /* FIXME: this should provide a default. */ - mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_SYNTARGVCOUNT); - return(0); - } else if (mdoc->last->args) + assert(np); + assert(MDOC_HEAD == np->type); + assert(MDOC_Bf == np->tok); + assert(np->data.Bf); + mdoc->last->data.Bf = np->data.Bf; return(1); + } - if (NULL == head->child || MDOC_TEXT != head->child->type) { - /* FIXME: this should provide a default. */ - mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_SYNTARGVCOUNT); + np = mdoc->last; + assert(MDOC_BLOCK == np->parent->type); + assert(MDOC_Bf == np->parent->tok); + np->data.Bf = mandoc_calloc(1, sizeof(struct mdoc_bf)); + + /* + * Cannot have both argument and parameter. + * If neither is specified, let it through with a warning. + */ + + if (np->parent->args && np->child) { + mdoc_nmsg(mdoc, np, MANDOCERR_SYNTARGVCOUNT); return(0); + } else if (NULL == np->parent->args && NULL == np->child) + return(mdoc_nmsg(mdoc, np, MANDOCERR_FONTTYPE)); + + /* Extract argument into data. */ + + if (np->parent->args) { + arg = np->parent->args->argv[0].arg; + if (MDOC_Emphasis == arg) + np->data.Bf->font = FONT_Em; + else if (MDOC_Literal == arg) + np->data.Bf->font = FONT_Li; + else if (MDOC_Symbolic == arg) + np->data.Bf->font = FONT_Sy; + else + abort(); + return(1); } - p = head->child->string; + /* Extract parameter into data. */ - if (0 == strcmp(p, "Em")) - return(1); - else if (0 == strcmp(p, "Li")) - return(1); - else if (0 == strcmp(p, "Sy")) - return(1); + if (0 == strcmp(np->child->string, "Em")) + np->data.Bf->font = FONT_Em; + else if (0 == strcmp(np->child->string, "Li")) + np->data.Bf->font = FONT_Li; + else if (0 == strcmp(np->child->string, "Sy")) + np->data.Bf->font = FONT_Sy; + else if ( ! mdoc_nmsg(mdoc, np, MANDOCERR_FONTTYPE)) + return(0); - mdoc_nmsg(mdoc, head, MANDOCERR_FONTTYPE); - return(0); + return(1); } @@ -1040,16 +1083,14 @@ post_at(POST_ARGS) static int post_an(POST_ARGS) { + struct mdoc_node *np; - if (mdoc->last->args) { - if (NULL == mdoc->last->child) - return(1); - return(mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_ARGCOUNT)); - } - - if (mdoc->last->child) + np = mdoc->last; + if (AUTH__NONE != np->data.An.auth && np->child) + return(mdoc_nmsg(mdoc, np, MANDOCERR_ARGCOUNT)); + if (AUTH__NONE != np->data.An.auth || np->child) return(1); - return(mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NOARGS)); + return(mdoc_nmsg(mdoc, np, MANDOCERR_NOARGS)); } @@ -1091,9 +1132,6 @@ post_it(POST_ARGS) if (NULL == mdoc->last->head->child) if ( ! mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NOARGS)) return(0); - if (NULL == mdoc->last->body->child) - if ( ! mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NOBODY)) - return(0); break; case (LIST_bullet): /* FALLTHROUGH */ @@ -1102,13 +1140,13 @@ post_it(POST_ARGS) case (LIST_enum): /* FALLTHROUGH */ case (LIST_hyphen): + if (NULL == mdoc->last->body->child) + if ( ! mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NOBODY)) + return(0); /* FALLTHROUGH */ case (LIST_item): if (mdoc->last->head->child) if ( ! mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_ARGSLOST)) - return(0); - if (NULL == mdoc->last->body->child) - if ( ! mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NOBODY)) return(0); break; case (LIST_column):