[BACK]Return to tbl_term.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Annotation of mandoc/tbl_term.c, Revision 1.10

1.10    ! kristaps    1: /*     $Id: tbl_term.c,v 1.9 2011/01/04 13:21:45 kristaps Exp $ */
1.1       kristaps    2: /*
                      3:  * Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
                      4:  *
                      5:  * Permission to use, copy, modify, and distribute this software for any
                      6:  * purpose with or without fee is hereby granted, provided that the above
                      7:  * copyright notice and this permission notice appear in all copies.
                      8:  *
                      9:  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
                     10:  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
                     11:  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
                     12:  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
                     13:  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
                     14:  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
                     15:  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
                     16:  */
                     17: #ifdef HAVE_CONFIG_H
                     18: #include "config.h"
                     19: #endif
                     20:
                     21: #include <assert.h>
                     22: #include <stdio.h>
                     23: #include <stdlib.h>
                     24: #include <string.h>
                     25:
                     26: #include "mandoc.h"
                     27: #include "out.h"
                     28: #include "term.h"
                     29:
                     30: /* FIXME: `n' modifier doesn't always do the right thing. */
                     31: /* FIXME: `n' modifier doesn't use the cell-spacing buffer. */
                     32:
                     33: static inline void      tbl_char(struct termp *, char, int);
                     34: static void             tbl_hframe(struct termp *,
                     35:                                const struct tbl_span *);
                     36: static void             tbl_data_number(struct termp *,
                     37:                                const struct tbl *,
1.2       kristaps   38:                                const struct tbl_dat *,
                     39:                                const struct termp_tbl *);
1.1       kristaps   40: static void             tbl_data_literal(struct termp *,
1.2       kristaps   41:                                const struct tbl_dat *,
                     42:                                const struct termp_tbl *);
1.1       kristaps   43: static void             tbl_data(struct termp *, const struct tbl *,
1.2       kristaps   44:                                const struct tbl_dat *,
                     45:                                const struct termp_tbl *);
1.1       kristaps   46: static void             tbl_spanner(struct termp *,
                     47:                                const struct tbl_head *);
                     48: static void             tbl_hrule(struct termp *,
                     49:                                const struct tbl_span *);
1.2       kristaps   50: static void             tbl_vframe(struct termp *,
                     51:                                const struct tbl *);
1.3       kristaps   52: static void             tbl_calc(struct termp *,
                     53:                                const struct tbl_span *);
                     54: static void             tbl_calc_data(struct termp *,
                     55:                                const struct tbl *,
                     56:                                const struct tbl_dat *,
1.2       kristaps   57:                                struct termp_tbl *);
1.3       kristaps   58: static void             tbl_calc_data_literal(struct termp *,
1.2       kristaps   59:                                const struct tbl_dat *,
                     60:                                struct termp_tbl *);
1.3       kristaps   61: static void             tbl_calc_data_number(struct termp *,
                     62:                                const struct tbl *,
1.2       kristaps   63:                                const struct tbl_dat *,
                     64:                                struct termp_tbl *);
1.1       kristaps   65:
                     66: void
                     67: term_tbl(struct termp *tp, const struct tbl_span *sp)
                     68: {
                     69:        const struct tbl_head *hp;
                     70:        const struct tbl_dat *dp;
                     71:
1.4       kristaps   72:        /* Inhibit printing of spaces: we do padding ourselves. */
                     73:
                     74:        tp->flags |= TERMP_NONOSPACE;
                     75:        tp->flags |= TERMP_NOSPACE;
                     76:
                     77:        /*
                     78:         * The first time we're invoked for a given table block, create
                     79:         * the termp_tbl structure.  This contains the column
                     80:         * configuration for the entire table, e.g., table-wide column
                     81:         * width, decimal point, etc.
                     82:         */
                     83:
1.2       kristaps   84:        if (TBL_SPAN_FIRST & sp->flags) {
                     85:                assert(NULL == tp->tbl);
                     86:                tp->tbl = calloc
                     87:                        (sp->tbl->cols, sizeof(struct termp_tbl));
                     88:                if (NULL == tp->tbl) {
                     89:                        perror(NULL);
                     90:                        exit(EXIT_FAILURE);
                     91:                }
1.3       kristaps   92:                tbl_calc(tp, sp);
1.4       kristaps   93:
                     94:                /* Flush out any preceding data. */
1.1       kristaps   95:                term_flushln(tp);
1.2       kristaps   96:        }
1.1       kristaps   97:
1.4       kristaps   98:        /* Horizontal frame at the start of boxed tables. */
                     99:
1.1       kristaps  100:        if (TBL_SPAN_FIRST & sp->flags)
                    101:                tbl_hframe(tp, sp);
                    102:
1.4       kristaps  103:        /* Vertical frame at the start of each row. */
1.1       kristaps  104:
                    105:        tbl_vframe(tp, sp->tbl);
                    106:
1.4       kristaps  107:        /*
                    108:         * Now print the actual data itself depending on the span type.
                    109:         * Spanner spans get a horizontal rule; data spanners have their
                    110:         * data printed by matching data to header.
                    111:         */
                    112:
1.1       kristaps  113:        switch (sp->pos) {
                    114:        case (TBL_SPAN_HORIZ):
                    115:                /* FALLTHROUGH */
                    116:        case (TBL_SPAN_DHORIZ):
                    117:                tbl_hrule(tp, sp);
                    118:                break;
1.4       kristaps  119:        case (TBL_SPAN_DATA):
                    120:                /* Iterate over template headers. */
                    121:                dp = sp->first;
                    122:                for (hp = sp->head; hp; hp = hp->next) {
                    123:                        switch (hp->pos) {
                    124:                        case (TBL_HEAD_VERT):
                    125:                                /* FALLTHROUGH */
                    126:                        case (TBL_HEAD_DVERT):
                    127:                                tbl_spanner(tp, hp);
                    128:                                continue;
                    129:                        case (TBL_HEAD_DATA):
                    130:                                break;
                    131:                        }
                    132:                        tbl_data(tp, sp->tbl, dp,
                    133:                                &tp->tbl[hp->ident]);
1.1       kristaps  134:
1.4       kristaps  135:                        /* Go to the next data cell. */
1.1       kristaps  136:                        if (dp)
                    137:                                dp = dp->next;
                    138:                }
1.4       kristaps  139:                break;
1.1       kristaps  140:        }
                    141:
                    142:        tbl_vframe(tp, sp->tbl);
                    143:        term_flushln(tp);
                    144:
1.4       kristaps  145:        /*
                    146:         * If we're the last row, clean up after ourselves: clear the
                    147:         * existing table configuration and set it to NULL.
                    148:         */
                    149:
1.2       kristaps  150:        if (TBL_SPAN_LAST & sp->flags) {
1.1       kristaps  151:                tbl_hframe(tp, sp);
1.2       kristaps  152:                assert(tp->tbl);
                    153:                free(tp->tbl);
                    154:                tp->tbl = NULL;
                    155:        }
1.1       kristaps  156:
                    157:        tp->flags &= ~TERMP_NONOSPACE;
                    158:
                    159: }
                    160:
                    161: static void
                    162: tbl_hrule(struct termp *tp, const struct tbl_span *sp)
                    163: {
                    164:        const struct tbl_head *hp;
                    165:        char             c;
1.2       kristaps  166:        int              width;
1.1       kristaps  167:
                    168:        /*
                    169:         * An hrule extends across the entire table and is demarked by a
                    170:         * standalone `_' or whatnot in lieu of a table row.  Spanning
                    171:         * headers are marked by a `+', as are table boundaries.
                    172:         */
                    173:
                    174:        c = '-';
                    175:        if (TBL_SPAN_DHORIZ == sp->pos)
                    176:                c = '=';
                    177:
                    178:        /* FIXME: don't use `+' between data and a spanner! */
                    179:
                    180:        for (hp = sp->head; hp; hp = hp->next) {
1.2       kristaps  181:                width = tp->tbl[hp->ident].width;
1.1       kristaps  182:                switch (hp->pos) {
                    183:                case (TBL_HEAD_DATA):
1.2       kristaps  184:                        tbl_char(tp, c, width);
1.1       kristaps  185:                        break;
                    186:                case (TBL_HEAD_DVERT):
1.2       kristaps  187:                        tbl_char(tp, '+', width);
1.1       kristaps  188:                        /* FALLTHROUGH */
                    189:                case (TBL_HEAD_VERT):
1.2       kristaps  190:                        tbl_char(tp, '+', width);
1.1       kristaps  191:                        break;
                    192:                default:
                    193:                        abort();
                    194:                        /* NOTREACHED */
                    195:                }
                    196:        }
                    197: }
                    198:
                    199: static void
                    200: tbl_hframe(struct termp *tp, const struct tbl_span *sp)
                    201: {
                    202:        const struct tbl_head *hp;
1.2       kristaps  203:        int              width;
1.1       kristaps  204:
                    205:        if ( ! (TBL_OPT_BOX & sp->tbl->opts ||
                    206:                        TBL_OPT_DBOX & sp->tbl->opts))
                    207:                return;
                    208:
                    209:        /*
                    210:         * Print out the horizontal part of a frame or double frame.  A
                    211:         * double frame has an unbroken `-' outer line the width of the
                    212:         * table, bordered by `+'.  The frame (or inner frame, in the
                    213:         * case of the double frame) is a `-' bordered by `+' and broken
                    214:         * by `+' whenever a span is encountered.
                    215:         */
                    216:
                    217:        if (TBL_OPT_DBOX & sp->tbl->opts) {
                    218:                term_word(tp, "+");
1.2       kristaps  219:                for (hp = sp->head; hp; hp = hp->next) {
                    220:                        width = tp->tbl[hp->ident].width;
                    221:                        tbl_char(tp, '-', width);
                    222:                }
1.1       kristaps  223:                term_word(tp, "+");
                    224:                term_flushln(tp);
                    225:        }
                    226:
                    227:        term_word(tp, "+");
                    228:        for (hp = sp->head; hp; hp = hp->next) {
1.2       kristaps  229:                width = tp->tbl[hp->ident].width;
1.1       kristaps  230:                switch (hp->pos) {
                    231:                case (TBL_HEAD_DATA):
1.2       kristaps  232:                        tbl_char(tp, '-', width);
1.1       kristaps  233:                        break;
                    234:                default:
1.2       kristaps  235:                        tbl_char(tp, '+', width);
1.1       kristaps  236:                        break;
                    237:                }
                    238:        }
                    239:        term_word(tp, "+");
                    240:        term_flushln(tp);
                    241: }
                    242:
                    243: static void
                    244: tbl_data(struct termp *tp, const struct tbl *tbl,
1.2       kristaps  245:                const struct tbl_dat *dp,
                    246:                const struct termp_tbl *tbp)
1.1       kristaps  247: {
                    248:        enum tbl_cellt   pos;
                    249:
                    250:        if (NULL == dp) {
1.2       kristaps  251:                tbl_char(tp, ASCII_NBRSP, tbp->width);
1.1       kristaps  252:                return;
                    253:        }
                    254:
                    255:        switch (dp->pos) {
1.10    ! kristaps  256:        case (TBL_DATA_NONE):
        !           257:                tbl_char(tp, ASCII_NBRSP, tbp->width);
        !           258:                return;
1.1       kristaps  259:        case (TBL_DATA_HORIZ):
                    260:                /* FALLTHROUGH */
1.7       kristaps  261:        case (TBL_DATA_NHORIZ):
                    262:                tbl_char(tp, '-', tbp->width);
                    263:                return;
                    264:        case (TBL_DATA_NDHORIZ):
                    265:                /* FALLTHROUGH */
1.1       kristaps  266:        case (TBL_DATA_DHORIZ):
1.7       kristaps  267:                tbl_char(tp, '=', tbp->width);
1.1       kristaps  268:                return;
                    269:        default:
                    270:                break;
                    271:        }
                    272:
                    273:        pos = dp->layout ? dp->layout->pos : TBL_CELL_LEFT;
                    274:
                    275:        switch (pos) {
                    276:        case (TBL_CELL_HORIZ):
1.7       kristaps  277:                tbl_char(tp, '-', tbp->width);
                    278:                break;
1.1       kristaps  279:        case (TBL_CELL_DHORIZ):
1.7       kristaps  280:                tbl_char(tp, '=', tbp->width);
1.1       kristaps  281:                break;
                    282:        case (TBL_CELL_LONG):
                    283:                /* FALLTHROUGH */
                    284:        case (TBL_CELL_CENTRE):
                    285:                /* FALLTHROUGH */
                    286:        case (TBL_CELL_LEFT):
                    287:                /* FALLTHROUGH */
                    288:        case (TBL_CELL_RIGHT):
1.2       kristaps  289:                tbl_data_literal(tp, dp, tbp);
1.1       kristaps  290:                break;
                    291:        case (TBL_CELL_NUMBER):
1.2       kristaps  292:                tbl_data_number(tp, tbl, dp, tbp);
1.1       kristaps  293:                break;
                    294:        default:
                    295:                abort();
                    296:                /* NOTREACHED */
                    297:        }
                    298: }
                    299: static void
                    300: tbl_spanner(struct termp *tp, const struct tbl_head *hp)
                    301: {
                    302:
                    303:        switch (hp->pos) {
                    304:        case (TBL_HEAD_VERT):
                    305:                term_word(tp, "|");
                    306:                break;
                    307:        case (TBL_HEAD_DVERT):
                    308:                term_word(tp, "||");
                    309:                break;
                    310:        default:
                    311:                break;
                    312:        }
                    313: }
                    314:
                    315: static void
                    316: tbl_vframe(struct termp *tp, const struct tbl *tbl)
                    317: {
                    318:        /* Always just a single vertical line. */
                    319:
                    320:        if (TBL_OPT_BOX & tbl->opts || TBL_OPT_DBOX & tbl->opts)
                    321:                term_word(tp, "|");
                    322: }
                    323:
                    324: static inline void
                    325: tbl_char(struct termp *tp, char c, int len)
                    326: {
1.3       kristaps  327:        int             i, sz;
1.1       kristaps  328:        char            cp[2];
                    329:
                    330:        cp[0] = c;
                    331:        cp[1] = '\0';
                    332:
1.3       kristaps  333:        sz = term_strlen(tp, cp);
                    334:
                    335:        for (i = 0; i < len; i += sz)
1.1       kristaps  336:                term_word(tp, cp);
                    337: }
                    338:
                    339: static void
1.2       kristaps  340: tbl_data_literal(struct termp *tp,
                    341:                const struct tbl_dat *dp,
                    342:                const struct termp_tbl *tblp)
1.1       kristaps  343: {
1.3       kristaps  344:        int              padl, padr, ssz;
1.1       kristaps  345:        enum tbl_cellt   pos;
                    346:
                    347:        padl = padr = 0;
                    348:
                    349:        pos = dp->layout ? dp->layout->pos : TBL_CELL_LEFT;
1.3       kristaps  350:        ssz = term_len(tp, 1);
1.1       kristaps  351:
                    352:        switch (pos) {
                    353:        case (TBL_CELL_LONG):
1.3       kristaps  354:                padl = ssz;
                    355:                padr = tblp->width - term_strlen(tp, dp->string) - ssz;
1.1       kristaps  356:                break;
                    357:        case (TBL_CELL_CENTRE):
1.3       kristaps  358:                padl = tblp->width - term_strlen(tp, dp->string);
1.1       kristaps  359:                if (padl % 2)
                    360:                        padr++;
                    361:                padl /= 2;
                    362:                padr += padl;
                    363:                break;
                    364:        case (TBL_CELL_RIGHT):
1.3       kristaps  365:                padl = tblp->width - term_strlen(tp, dp->string);
1.1       kristaps  366:                break;
                    367:        default:
1.3       kristaps  368:                padr = tblp->width - term_strlen(tp, dp->string);
1.1       kristaps  369:                break;
                    370:        }
                    371:
                    372:        tbl_char(tp, ASCII_NBRSP, padl);
                    373:        term_word(tp, dp->string);
                    374:        tbl_char(tp, ASCII_NBRSP, padr);
                    375: }
                    376:
                    377: static void
                    378: tbl_data_number(struct termp *tp, const struct tbl *tbl,
1.2       kristaps  379:                const struct tbl_dat *dp,
                    380:                const struct termp_tbl *tblp)
1.1       kristaps  381: {
1.5       kristaps  382:        char            *decp, buf[2];
                    383:        int              d, padl, sz, psz, ssz, i;
1.1       kristaps  384:
                    385:        /*
                    386:         * See calc_data_number().  Left-pad by taking the offset of our
                    387:         * and the maximum decimal; right-pad by the remaining amount.
                    388:         */
                    389:
1.5       kristaps  390:        sz = term_strlen(tp, dp->string);
                    391:        psz = term_strlen(tp, ".");
1.1       kristaps  392:
1.5       kristaps  393:        if (NULL != (decp = strchr(dp->string, tbl->decimal))) {
                    394:                buf[1] = '\0';
                    395:                for (ssz = i = 0; decp != &dp->string[i]; i++) {
                    396:                        buf[0] = dp->string[i];
                    397:                        ssz += term_strlen(tp, buf);
                    398:                }
                    399:                d = ssz + psz;
                    400:        } else
                    401:                d = sz + psz;
1.1       kristaps  402:
1.2       kristaps  403:        assert(d <= tblp->decimal);
                    404:        assert(sz - d <= tblp->width - tblp->decimal);
1.1       kristaps  405:
1.5       kristaps  406:        padl = tblp->decimal - d + term_len(tp, 1);
1.2       kristaps  407:        assert(tblp->width - sz - padl);
1.1       kristaps  408:
                    409:        tbl_char(tp, ASCII_NBRSP, padl);
                    410:        term_word(tp, dp->string);
1.2       kristaps  411:        tbl_char(tp, ASCII_NBRSP, tblp->width - sz - padl);
                    412: }
                    413:
                    414: static void
1.3       kristaps  415: tbl_calc(struct termp *tp, const struct tbl_span *sp)
1.2       kristaps  416: {
                    417:        const struct tbl_dat *dp;
                    418:        const struct tbl_head *hp;
                    419:        struct termp_tbl *p;
                    420:
                    421:        /* Calculate width as the max of column cells' widths. */
                    422:
                    423:        hp = sp->head;
                    424:
                    425:        for ( ; sp; sp = sp->next) {
1.10    ! kristaps  426:                if (TBL_SPAN_DATA != sp->pos)
1.2       kristaps  427:                        continue;
1.10    ! kristaps  428:
1.2       kristaps  429:                for (dp = sp->first; dp; dp = dp->next) {
                    430:                        if (NULL == dp->layout)
                    431:                                continue;
1.3       kristaps  432:                        p = &tp->tbl[dp->layout->head->ident];
                    433:                        tbl_calc_data(tp, sp->tbl, dp, p);
1.2       kristaps  434:                }
                    435:        }
                    436:
                    437:        /* Calculate width as the simple spanner value. */
                    438:
                    439:        for ( ; hp; hp = hp->next)
                    440:                switch (hp->pos) {
                    441:                case (TBL_HEAD_VERT):
1.3       kristaps  442:                        tp->tbl[hp->ident].width = term_len(tp, 1);
1.2       kristaps  443:                        break;
                    444:                case (TBL_HEAD_DVERT):
1.3       kristaps  445:                        tp->tbl[hp->ident].width = term_len(tp, 2);
1.2       kristaps  446:                        break;
                    447:                default:
                    448:                        break;
                    449:                }
                    450: }
                    451:
                    452: static void
1.3       kristaps  453: tbl_calc_data(struct termp *tp, const struct tbl *tbl,
                    454:                const struct tbl_dat *dp, struct termp_tbl *tblp)
1.2       kristaps  455: {
1.9       kristaps  456:        int              sz;
1.2       kristaps  457:
                    458:        /* Branch down into data sub-types. */
                    459:
                    460:        switch (dp->layout->pos) {
                    461:        case (TBL_CELL_HORIZ):
                    462:                /* FALLTHROUGH */
                    463:        case (TBL_CELL_DHORIZ):
1.9       kristaps  464:                sz = term_len(tp, 1);
                    465:                if (tblp->width < sz)
                    466:                        tblp->width = sz;
1.2       kristaps  467:                break;
                    468:        case (TBL_CELL_LONG):
                    469:                /* FALLTHROUGH */
                    470:        case (TBL_CELL_CENTRE):
                    471:                /* FALLTHROUGH */
                    472:        case (TBL_CELL_LEFT):
                    473:                /* FALLTHROUGH */
                    474:        case (TBL_CELL_RIGHT):
1.3       kristaps  475:                tbl_calc_data_literal(tp, dp, tblp);
1.2       kristaps  476:                break;
                    477:        case (TBL_CELL_NUMBER):
1.3       kristaps  478:                tbl_calc_data_number(tp, tbl, dp, tblp);
1.2       kristaps  479:                break;
                    480:        default:
                    481:                abort();
                    482:                /* NOTREACHED */
                    483:        }
                    484: }
                    485:
                    486: static void
1.3       kristaps  487: tbl_calc_data_number(struct termp *tp, const struct tbl *tbl,
1.2       kristaps  488:                const struct tbl_dat *dp, struct termp_tbl *tblp)
                    489: {
1.5       kristaps  490:        int              sz, d, psz, i, ssz;
                    491:        char            *cp, buf[2];
1.2       kristaps  492:
                    493:        /*
                    494:         * First calculate number width and decimal place (last + 1 for
                    495:         * no-decimal numbers).  If the stored decimal is subsequent
                    496:         * ours, make our size longer by that difference
                    497:         * (right-"shifting"); similarly, if ours is subsequent the
                    498:         * stored, then extend the stored size by the difference.
                    499:         * Finally, re-assign the stored values.
                    500:         */
                    501:
                    502:        /* TODO: use spacing modifier. */
                    503:
                    504:        assert(dp->string);
1.5       kristaps  505:        sz = term_strlen(tp, dp->string);
                    506:        psz = term_strlen(tp, ".");
1.2       kristaps  507:
1.5       kristaps  508:        if (NULL != (cp = strchr(dp->string, tbl->decimal))) {
                    509:                buf[1] = '\0';
                    510:                for (ssz = i = 0; cp != &dp->string[i]; i++) {
                    511:                        buf[0] = dp->string[i];
                    512:                        ssz += term_strlen(tp, buf);
                    513:                }
                    514:                d = ssz + psz;
                    515:        } else
                    516:                d = sz + psz;
1.2       kristaps  517:
1.5       kristaps  518:        sz += term_len(tp, 2);
1.2       kristaps  519:
                    520:        if (tblp->decimal > d) {
                    521:                sz += tblp->decimal - d;
                    522:                d = tblp->decimal;
                    523:        } else
                    524:                tblp->width += d - tblp->decimal;
                    525:
                    526:        if (sz > tblp->width)
                    527:                tblp->width = sz;
                    528:        if (d > tblp->decimal)
                    529:                tblp->decimal = d;
                    530: }
                    531:
                    532: static void
1.3       kristaps  533: tbl_calc_data_literal(struct termp *tp,
                    534:                const struct tbl_dat *dp,
                    535:                struct termp_tbl *tblp)
1.2       kristaps  536: {
1.8       kristaps  537:        int              sz, bufsz, spsz;
1.2       kristaps  538:
                    539:        /*
                    540:         * Calculate our width and use the spacing, with a minimum
                    541:         * spacing dictated by position (centre, e.g,. gets a space on
                    542:         * either side, while right/left get a single adjacent space).
                    543:         */
                    544:
                    545:        assert(dp->string);
1.3       kristaps  546:        sz = term_strlen(tp, dp->string);
1.2       kristaps  547:
                    548:        switch (dp->layout->pos) {
                    549:        case (TBL_CELL_LONG):
                    550:                /* FALLTHROUGH */
                    551:        case (TBL_CELL_CENTRE):
1.8       kristaps  552:                bufsz = term_len(tp, 2);
1.2       kristaps  553:                break;
                    554:        default:
1.8       kristaps  555:                bufsz = term_len(tp, 1);
1.2       kristaps  556:                break;
                    557:        }
                    558:
1.8       kristaps  559:        spsz = 0;
1.2       kristaps  560:        if (dp->layout->spacing)
1.8       kristaps  561:                spsz = term_len(tp, dp->layout->spacing);
                    562:
                    563:        if (spsz)
                    564:                bufsz = bufsz > spsz ?  bufsz : spsz;
1.2       kristaps  565:
                    566:        sz += bufsz;
                    567:        if (tblp->width < sz)
                    568:                tblp->width = sz;
1.1       kristaps  569: }

CVSweb