summaryrefslogtreecommitdiffstats
path: root/tbl_term.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-01-07 14:59:52 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-01-07 14:59:52 +0000
commit954789a256b33b8959f60aba1e516a62d7577dce (patch)
treeed96274f5166b9d53e2cac0b08ca5871dfdfb4a6 /tbl_term.c
parentcbbbfb105eb8cfbcc27f89142cba69b42db39f7d (diff)
downloadmandoc-954789a256b33b8959f60aba1e516a62d7577dce.tar.gz
Fixes: T} can be followed by a delimiter then more data. Make this
work and add documentation for it. Also make tbl_term() not puke if the number of data cells is less than the number of layout cells (which happens from time to time). This still needs work because we should pad out empty cells so that the borders all work out.
Diffstat (limited to 'tbl_term.c')
-rw-r--r--tbl_term.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/tbl_term.c b/tbl_term.c
index ab1a4f62..62573486 100644
--- a/tbl_term.c
+++ b/tbl_term.c
@@ -272,7 +272,7 @@ tbl_data(struct termp *tp, const struct tbl *tbl,
break;
}
- pos = dp->layout ? dp->layout->pos : TBL_CELL_LEFT;
+ pos = dp && dp->layout ? dp->layout->pos : TBL_CELL_LEFT;
switch (pos) {
case (TBL_CELL_HORIZ):
@@ -344,34 +344,37 @@ tbl_literal(struct termp *tp, const struct tbl_dat *dp,
{
size_t padl, padr, ssz;
enum tbl_cellt pos;
+ const char *str;
padl = padr = 0;
- pos = dp->layout ? dp->layout->pos : TBL_CELL_LEFT;
+ pos = dp && dp->layout ? dp->layout->pos : TBL_CELL_LEFT;
+ str = dp && dp->string ? dp->string : "";
+
ssz = term_len(tp, 1);
switch (pos) {
case (TBL_CELL_LONG):
padl = ssz;
- padr = col->width - term_strlen(tp, dp->string) - ssz;
+ padr = col->width - term_strlen(tp, str) - ssz;
break;
case (TBL_CELL_CENTRE):
- padl = col->width - term_strlen(tp, dp->string);
+ padl = col->width - term_strlen(tp, str);
if (padl % 2)
padr++;
padl /= 2;
padr += padl;
break;
case (TBL_CELL_RIGHT):
- padl = col->width - term_strlen(tp, dp->string);
+ padl = col->width - term_strlen(tp, str);
break;
default:
- padr = col->width - term_strlen(tp, dp->string);
+ padr = col->width - term_strlen(tp, str);
break;
}
tbl_char(tp, ASCII_NBRSP, padl);
- term_word(tp, dp->string);
+ term_word(tp, str);
tbl_char(tp, ASCII_NBRSP, padr);
}
@@ -391,9 +394,7 @@ tbl_number(struct termp *tp, const struct tbl *tbl,
* and the maximum decimal; right-pad by the remaining amount.
*/
- str = "";
- if (dp->string)
- str = dp->string;
+ str = dp && dp->string ? dp->string : "";
sz = term_strlen(tp, str);
@@ -418,7 +419,7 @@ tbl_number(struct termp *tp, const struct tbl *tbl,
padl = col->decimal - d;
tbl_char(tp, ASCII_NBRSP, padl);
- term_word(tp, dp->string);
+ term_word(tp, str);
tbl_char(tp, ASCII_NBRSP, col->width - sz - padl);
}