diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2010-05-31 23:40:25 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2010-05-31 23:40:25 +0000 |
commit | cf92b022147d19cfe09cf470b887681b4174ff0e (patch) | |
tree | feab9337392e6811c2492f8e5ebd071c53cf597f | |
parent | 5790a921156fab714a8d9a5804ad1603664e8c80 (diff) | |
download | mandoc-cf92b022147d19cfe09cf470b887681b4174ff0e.tar.gz mandoc-cf92b022147d19cfe09cf470b887681b4174ff0e.tar.zst mandoc-cf92b022147d19cfe09cf470b887681b4174ff0e.zip |
Cleanup post_bl_head() to use enum mdoc_list (avoid traversing that
list).
Reverted MANDOC_COLUMNS to be a bad-bad syntax error: we don't, and
apparently never have, allowed mixing of -column syntaxes. This would
have segfaulted if encountered.
-rw-r--r-- | TODO | 2 | ||||
-rw-r--r-- | main.c | 4 | ||||
-rw-r--r-- | mandoc.h | 4 | ||||
-rw-r--r-- | mdoc_validate.c | 25 |
4 files changed, 20 insertions, 15 deletions
@@ -59,6 +59,8 @@ flags defined for struct mdoc_macro - set a meaningful default if no `Bl' list type is assigned + +- have a blank `It' head for `Bl -tag' not puke ************************************************************************ * formatting issues: ugly output @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.79 2010/05/17 22:11:42 kristaps Exp $ */ +/* $Id: main.c,v 1.80 2010/05/31 23:40:25 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -102,7 +102,6 @@ static const char * const mandocerrs[MANDOCERR_MAX] = { "out of order prologue", "repeated prologue entry", "list type must come first", - "column syntax is inconsistent", "bad standard", "bad library", "bad escape sequence", @@ -144,6 +143,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = { "no title in document", "line argument(s) will be lost", "body argument(s) will be lost", + "column syntax is inconsistent", "missing font type", "missing display type", "missing list type", @@ -1,4 +1,4 @@ -/* $Id: mandoc.h,v 1.7 2010/05/25 12:37:20 kristaps Exp $ */ +/* $Id: mandoc.h,v 1.8 2010/05/31 23:40:25 kristaps Exp $ */ /* * Copyright (c) 2010 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -31,7 +31,6 @@ enum mandocerr { MANDOCERR_PROLOGOOO, /* out of order prologue */ MANDOCERR_PROLOGREP, /* repeated prologue entry */ MANDOCERR_LISTFIRST, /* list type must come first */ - MANDOCERR_COLUMNS, /* column syntax is inconsistent */ MANDOCERR_BADSTANDARD, /* bad standard */ MANDOCERR_BADLIB, /* bad library */ MANDOCERR_BADESCAPE, /* bad escape sequence */ @@ -78,6 +77,7 @@ enum mandocerr { MANDOCERR_BODYLOST, /* body argument(s) will be lost */ #define MANDOCERR_ERROR MANDOCERR_BODYLOST + MANDOCERR_COLUMNS, /* column syntax is inconsistent */ /* FIXME: this should be a MANDOCERR_ERROR */ MANDOCERR_FONTTYPE, /* missing font type */ /* FIXME: this should be a MANDOCERR_ERROR */ diff --git a/mdoc_validate.c b/mdoc_validate.c index fd9af9cd..48e000c7 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_validate.c,v 1.89 2010/05/31 23:10:51 kristaps Exp $ */ +/* $Id: mdoc_validate.c,v 1.90 2010/05/31 23:40:25 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -1024,20 +1024,23 @@ post_it(POST_ARGS) static int post_bl_head(POST_ARGS) { - int i; - const struct mdoc_node *n; - const struct mdoc_argv *a; + int i; + struct mdoc_node *n; + assert(mdoc->last->parent); n = mdoc->last->parent; - assert(n->args); - for (i = 0; i < (int)n->args->argc; i++) { - a = &n->args->argv[i]; - if (a->arg == MDOC_Column) { - if (a->sz && mdoc->last->nchild) - return(mdoc_nmsg(mdoc, n, MANDOCERR_COLUMNS)); - return(1); + if (LIST_column == n->data.list) { + for (i = 0; i < (int)n->args->argc; i++) + if (MDOC_Column == n->args->argv[i].arg) + break; + assert(i < (int)n->args->argc); + + if (n->args->argv[i].sz && mdoc->last->nchild) { + mdoc_nmsg(mdoc, n, MANDOCERR_COLUMNS); + return(0); } + return(1); } if (0 == (i = mdoc->last->nchild)) |