=================================================================== RCS file: /cvs/mandoc/tbl_term.c,v retrieving revision 1.16 retrieving revision 1.19 diff -u -p -r1.16 -r1.19 --- mandoc/tbl_term.c 2011/01/10 14:40:30 1.16 +++ mandoc/tbl_term.c 2011/01/25 12:07:30 1.19 @@ -1,6 +1,7 @@ -/* $Id: tbl_term.c,v 1.16 2011/01/10 14:40:30 kristaps Exp $ */ +/* $Id: tbl_term.c,v 1.19 2011/01/25 12:07:30 schwarze Exp $ */ /* - * Copyright (c) 2009 Kristaps Dzonsons + * Copyright (c) 2009, 2011 Kristaps Dzonsons + * Copyright (c) 2011 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -197,6 +198,8 @@ tbl_hrule(struct termp *tp, const struct tbl_span *sp) width = tp->tbl.cols[hp->ident].width; switch (hp->pos) { case (TBL_HEAD_DATA): + if (hp->next) + width += 2; tbl_char(tp, c, width); break; case (TBL_HEAD_DVERT): @@ -305,6 +308,9 @@ tbl_data(struct termp *tp, const struct tbl *tbl, case (TBL_CELL_NUMBER): tbl_number(tp, tbl, dp, col); break; + case (TBL_CELL_DOWN): + tbl_char(tp, ASCII_NBRSP, col->width); + break; default: abort(); /* NOTREACHED */ @@ -355,37 +361,36 @@ tbl_literal(struct termp *tp, const struct tbl_dat *dp const struct roffcol *col) { size_t padl, padr, ssz; - const char *str; padl = padr = 0; - str = dp->string ? dp->string : ""; + assert(dp->string); ssz = term_len(tp, 1); switch (dp->layout->pos) { case (TBL_CELL_LONG): padl = ssz; - padr = col->width - term_strlen(tp, str) - ssz; + padr = col->width - term_strlen(tp, dp->string) - ssz; break; case (TBL_CELL_CENTRE): - padl = col->width - term_strlen(tp, str); - if (padl % 2) - padr++; - padl /= 2; - padr += padl; + padr = col->width - term_strlen(tp, dp->string); + if (3 > padr) + break; + padl = (padr - 1) / 2; + padr -= padl; break; case (TBL_CELL_RIGHT): - padl = col->width - term_strlen(tp, str); + padl = col->width - term_strlen(tp, dp->string); break; default: - padr = col->width - term_strlen(tp, str); + padr = col->width - term_strlen(tp, dp->string); break; } tbl_char(tp, ASCII_NBRSP, padl); - term_word(tp, str); - tbl_char(tp, ASCII_NBRSP, padr); + term_word(tp, dp->string); + tbl_char(tp, ASCII_NBRSP, padr + 2); } static void @@ -395,7 +400,6 @@ tbl_number(struct termp *tp, const struct tbl *tbl, { char *cp; char buf[2]; - const char *str; size_t sz, psz, ssz, d, padl; int i; @@ -404,19 +408,19 @@ tbl_number(struct termp *tp, const struct tbl *tbl, * and the maximum decimal; right-pad by the remaining amount. */ - str = dp->string ? dp->string : ""; + assert(dp->string); - sz = term_strlen(tp, str); + sz = term_strlen(tp, dp->string); buf[0] = tbl->decimal; buf[1] = '\0'; psz = term_strlen(tp, buf); - if (NULL != (cp = strrchr(str, tbl->decimal))) { + if (NULL != (cp = strrchr(dp->string, tbl->decimal))) { buf[1] = '\0'; - for (ssz = 0, i = 0; cp != &str[i]; i++) { - buf[0] = str[i]; + for (ssz = 0, i = 0; cp != &dp->string[i]; i++) { + buf[0] = dp->string[i]; ssz += term_strlen(tp, buf); } d = ssz + psz; @@ -429,7 +433,7 @@ tbl_number(struct termp *tp, const struct tbl *tbl, padl = col->decimal - d; tbl_char(tp, ASCII_NBRSP, padl); - term_word(tp, str); + term_word(tp, dp->string); tbl_char(tp, ASCII_NBRSP, col->width - sz - padl); }