version 1.82, 2021/09/07 17:07:58 |
version 1.83, 2021/09/28 17:06:59 |
Line 123 tblcalc(struct rofftbl *tbl, const struct tbl_span *sp |
|
Line 123 tblcalc(struct rofftbl *tbl, const struct tbl_span *sp |
|
const struct tbl_dat *dp; |
const struct tbl_dat *dp; |
struct roffcol *col; |
struct roffcol *col; |
struct tbl_colgroup *first_group, **gp, *g; |
struct tbl_colgroup *first_group, **gp, *g; |
|
size_t *colwidth; |
size_t ewidth, min1, min2, wanted, width, xwidth; |
size_t ewidth, min1, min2, wanted, width, xwidth; |
int done, icol, maxcol, necol, nxcol, quirkcol; |
int done, icol, maxcol, necol, nxcol, quirkcol; |
|
|
Line 256 tblcalc(struct rofftbl *tbl, const struct tbl_span *sp |
|
Line 257 tblcalc(struct rofftbl *tbl, const struct tbl_span *sp |
|
gp = &(*gp)->next; |
gp = &(*gp)->next; |
} |
} |
|
|
|
colwidth = mandoc_reallocarray(NULL, maxcol + 1, sizeof(*colwidth)); |
while (first_group != NULL) { |
while (first_group != NULL) { |
|
|
/* |
/* |
|
* Rebuild the array of the widths of all columns |
|
* participating in spans that require expansion. |
|
*/ |
|
|
|
for (icol = 0; icol <= maxcol; icol++) |
|
colwidth[icol] = SIZE_MAX; |
|
for (g = first_group; g != NULL; g = g->next) |
|
for (icol = g->startcol; icol <= g->endcol; icol++) |
|
colwidth[icol] = tbl->cols[icol].width; |
|
|
|
/* |
* Find the smallest and second smallest column width |
* Find the smallest and second smallest column width |
* among the columns which may need expamsion. |
* among the columns which may need expamsion. |
*/ |
*/ |
|
|
min1 = min2 = SIZE_MAX; |
min1 = min2 = SIZE_MAX; |
for (icol = 0; icol <= maxcol; icol++) { |
for (icol = 0; icol <= maxcol; icol++) { |
width = tbl->cols[icol].width; |
width = colwidth[icol]; |
if (min1 > width) { |
if (min1 > width) { |
min2 = min1; |
min2 = min1; |
min1 = width; |
min1 = width; |
Line 283 tblcalc(struct rofftbl *tbl, const struct tbl_span *sp |
|
Line 296 tblcalc(struct rofftbl *tbl, const struct tbl_span *sp |
|
for (g = first_group; g != NULL; g = g->next) { |
for (g = first_group; g != NULL; g = g->next) { |
necol = 0; |
necol = 0; |
for (icol = g->startcol; icol <= g->endcol; icol++) |
for (icol = g->startcol; icol <= g->endcol; icol++) |
if (tbl->cols[icol].width == min1) |
if (colwidth[icol] == min1) |
necol++; |
necol++; |
if (necol == 0) |
if (necol == 0) |
continue; |
continue; |
Line 300 tblcalc(struct rofftbl *tbl, const struct tbl_span *sp |
|
Line 313 tblcalc(struct rofftbl *tbl, const struct tbl_span *sp |
|
while ((g = *gp) != NULL) { |
while ((g = *gp) != NULL) { |
done = 0; |
done = 0; |
for (icol = g->startcol; icol <= g->endcol; icol++) { |
for (icol = g->startcol; icol <= g->endcol; icol++) { |
if (tbl->cols[icol].width != min1) |
if (colwidth[icol] != min1) |
continue; |
continue; |
if (g->wanted <= wanted - min1) { |
if (g->wanted <= wanted - min1) { |
tbl->cols[icol].width += g->wanted; |
tbl->cols[icol].width += g->wanted; |
Line 317 tblcalc(struct rofftbl *tbl, const struct tbl_span *sp |
|
Line 330 tblcalc(struct rofftbl *tbl, const struct tbl_span *sp |
|
gp = &(*gp)->next; |
gp = &(*gp)->next; |
} |
} |
} |
} |
|
free(colwidth); |
|
|
/* |
/* |
* Align numbers with text. |
* Align numbers with text. |