=================================================================== RCS file: /cvs/mandoc/out.c,v retrieving revision 1.77 retrieving revision 1.80 diff -u -p -r1.77 -r1.80 --- mandoc/out.c 2018/12/13 11:55:47 1.77 +++ mandoc/out.c 2021/08/10 12:55:03 1.80 @@ -1,4 +1,4 @@ -/* $Id: out.c,v 1.77 2018/12/13 11:55:47 schwarze Exp $ */ +/* $Id: out.c,v 1.80 2021/08/10 12:55:03 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2011,2014,2015,2017,2018 Ingo Schwarze @@ -22,11 +22,13 @@ #include #include #include +#include #include #include #include #include "mandoc_aux.h" +#include "mandoc.h" #include "tbl.h" #include "out.h" @@ -149,7 +151,7 @@ tblcalc(struct rofftbl *tbl, const struct tbl_span *sp gp = &first_group; for (dp = sp->first; dp != NULL; dp = dp->next) { icol = dp->layout->col; - while (icol > maxcol) + while (maxcol < icol + dp->hspans) tbl->cols[++maxcol].spacing = SIZE_MAX; col = tbl->cols + icol; col->flags |= dp->layout->flags; @@ -209,13 +211,25 @@ tblcalc(struct rofftbl *tbl, const struct tbl_span *sp } /* - * Column spacings are needed for span width calculations, - * so set the default values now. + * The minimum width of columns explicitly specified + * in the layout is 1n. */ - for (icol = 0; icol <= maxcol; icol++) - if (tbl->cols[icol].spacing == SIZE_MAX || icol == maxcol) - tbl->cols[icol].spacing = 3; + if (maxcol < sp_first->opts->cols - 1) + maxcol = sp_first->opts->cols - 1; + for (icol = 0; icol <= maxcol; icol++) { + col = tbl->cols + icol; + if (col->width < 1) + col->width = 1; + + /* + * Column spacings are needed for span width + * calculations, so set the default values now. + */ + + if (col->spacing == SIZE_MAX || icol == maxcol) + col->spacing = 3; + } /* * Replace the minimum widths with the missing widths,