From: schwarze Date: Fri, 8 Aug 2014 15:42:39 +0000 (+0000) Subject: In .Bl -column, if some of the column width declarations are given X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=f51747437197391f60e17078dadeb31193283a1b;p=openbsd In .Bl -column, if some of the column width declarations are given right after the -column argument and some at the very end of the argument list, after some other arguments like -compact, concatenate the column lists. This gets rid of one of the last useless FATAL errors and actually shortens the code by a few lines. This fixes an issue introduced more than five years ago, at first causing an assert() since bsd.lv mdoc_action.c rev. 1.14 (June 17, 2009), then later a FATAL error since mdoc_validate rev. 1.130 (Nov. 30, 2010), and marked as "TODO" ever since. --- diff --git a/usr.bin/mandoc/mandoc.h b/usr.bin/mandoc/mandoc.h index bf6cfb5022d..c98d5c2593e 100644 --- a/usr.bin/mandoc/mandoc.h +++ b/usr.bin/mandoc/mandoc.h @@ -1,4 +1,4 @@ -/* $Id: mandoc.h,v 1.91 2014/08/08 15:38:46 schwarze Exp $ */ +/* $Id: mandoc.h,v 1.92 2014/08/08 15:42:39 schwarze Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010-2014 Ingo Schwarze @@ -161,7 +161,6 @@ enum mandocerr { MANDOCERR_FATAL, /* ===== start of fatal errors ===== */ MANDOCERR_TOOLARGE, /* input too large */ - MANDOCERR_COLUMNS, /* column syntax is inconsistent */ MANDOCERR_BADDISP, /* NOT IMPLEMENTED: .Bd -file */ MANDOCERR_SO_PATH, /* NOT IMPLEMENTED: .so with absolute path or ".." */ MANDOCERR_SO_FAIL, /* .so request failed */ diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c index 21a6ebbd26f..02fedf691ad 100644 --- a/usr.bin/mandoc/mdoc_validate.c +++ b/usr.bin/mandoc/mdoc_validate.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_validate.c,v 1.154 2014/08/08 15:38:46 schwarze Exp $ */ +/* $Id: mdoc_validate.c,v 1.155 2014/08/08 15:42:39 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010-2014 Ingo Schwarze @@ -1447,6 +1447,7 @@ static int post_bl_head(POST_ARGS) { struct mdoc_node *np, *nn, *nnp; + struct mdoc_argv *argv; int i, j; if (LIST_column != mdoc->last->norm->Bl.type) @@ -1454,22 +1455,12 @@ post_bl_head(POST_ARGS) return(hwarn_eq0(mdoc)); /* - * Convert old-style lists, where the column width specifiers + * Append old-style lists, where the column width specifiers * trail as macro parameters, to the new-style ("normal-form") * lists where they're argument values following -column. */ - /* First, disallow both types and allow normal-form. */ - - /* - * TODO: technically, we can accept both and just merge the two - * lists, but I'll leave that for another day. - */ - - if (mdoc->last->norm->Bl.ncols && mdoc->last->nchild) { - mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_COLUMNS); - return(0); - } else if (NULL == mdoc->last->child) + if (mdoc->last->child == NULL) return(1); np = mdoc->last->parent; @@ -1480,7 +1471,6 @@ post_bl_head(POST_ARGS) break; assert(j < (int)np->args->argc); - assert(0 == np->args->argv[j].sz); /* * Accommodate for new-style groff column syntax. Shuffle the @@ -1488,15 +1478,17 @@ post_bl_head(POST_ARGS) * column field. Then, delete the head children. */ - np->args->argv[j].sz = (size_t)mdoc->last->nchild; - np->args->argv[j].value = mandoc_reallocarray(NULL, - (size_t)mdoc->last->nchild, sizeof(char *)); + argv = np->args->argv + j; + i = argv->sz; + argv->sz += mdoc->last->nchild; + argv->value = mandoc_reallocarray(argv->value, + argv->sz, sizeof(char *)); - mdoc->last->norm->Bl.ncols = np->args->argv[j].sz; - mdoc->last->norm->Bl.cols = (void *)np->args->argv[j].value; + mdoc->last->norm->Bl.ncols = argv->sz; + mdoc->last->norm->Bl.cols = (void *)argv->value; - for (i = 0, nn = mdoc->last->child; nn; i++) { - np->args->argv[j].value[i] = nn->string; + for (nn = mdoc->last->child; nn; i++) { + argv->value[i] = nn->string; nn->string = NULL; nnp = nn; nn = nn->next; diff --git a/usr.bin/mandoc/read.c b/usr.bin/mandoc/read.c index bad2eec70a7..5b57b500de5 100644 --- a/usr.bin/mandoc/read.c +++ b/usr.bin/mandoc/read.c @@ -1,4 +1,4 @@ -/* $Id: read.c,v 1.52 2014/08/08 15:38:46 schwarze Exp $ */ +/* $Id: read.c,v 1.53 2014/08/08 15:42:39 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010-2014 Ingo Schwarze @@ -197,7 +197,6 @@ static const char * const mandocerrs[MANDOCERR_MAX] = { "generic fatal error", "input too large", - "column syntax is inconsistent", "NOT IMPLEMENTED: .Bd -file", "NOT IMPLEMENTED: .so with absolute path or \"..\"", ".so request failed",