diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2009-08-09 20:11:31 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2009-08-09 20:11:31 +0000 |
commit | 91900e50d13a6358e6b5a8f1946cf57b89cc450b (patch) | |
tree | 9c7f992ae12d940a19cc6417c0adf2e8581d87a5 | |
parent | a7c3409c62f87e1b1f48342c5ca71020b8fe76ac (diff) |
sync to 1.8.3: In .Bl -column, handle one column in excess,
but still issue a warning
-rw-r--r-- | usr.bin/mandoc/mdoc_term.c | 24 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_validate.c | 4 |
2 files changed, 22 insertions, 6 deletions
diff --git a/usr.bin/mandoc/mdoc_term.c b/usr.bin/mandoc/mdoc_term.c index 3fa073471c9..6d21416f19c 100644 --- a/usr.bin/mandoc/mdoc_term.c +++ b/usr.bin/mandoc/mdoc_term.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_term.c,v 1.45 2009/08/09 19:28:21 schwarze Exp $ */ +/* $Id: mdoc_term.c,v 1.46 2009/08/09 20:11:30 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -777,11 +777,27 @@ termp_it_pre(DECL_ARGS) case (MDOC_Column): if (MDOC_BODY == node->type) break; - for (i = 0, n = node->prev; n; n = n->prev, i++) + /* + * Work around groff's column handling. The offset is + * equal to the sum of all widths leading to the current + * column (plus the -offset value). If this column + * exceeds the stated number of columns, the width is + * set as 0, else it's the stated column width (later + * the 0 will be adjusted to default 10 or, if in the + * last column case, set to stretch to the margin). + */ + for (i = 0, n = node->prev; n && n && + i < (int)bl->args[vals[2]].argv->sz; + n = n->prev, i++) offset += arg_width (&bl->args->argv[vals[2]], i); - assert(i < (int)bl->args->argv[vals[2]].sz); - width = arg_width(&bl->args->argv[vals[2]], i); + + /* Whether exceeds maximum column. */ + if (i < (int)bl->args[vals[2]].argv->sz) + width = arg_width(&bl->args->argv[vals[2]], i); + else + width = 0; + if (vals[1] >= 0) offset += arg_offset(&bl->args->argv[vals[1]]); break; diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c index 27d553cdfeb..92f793aa4ca 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.32 2009/08/09 17:38:24 schwarze Exp $ */ +/* $Id: mdoc_validate.c,v 1.33 2009/08/09 20:11:30 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -1025,7 +1025,7 @@ post_it(POST_ARGS) for (i = 0; c && MDOC_HEAD == c->type; c = c->next) i++; - if (i < cols) { + if (i < cols || i == (cols + 1)) { if ( ! mdoc_vwarn(mdoc, mdoc->last->line, mdoc->last->pos, "column " "mismatch: have %d, want %d", |