diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2011-01-07 14:59:52 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2011-01-07 14:59:52 +0000 |
commit | 3d53bc0f504bfa821a250cb8c824f1a71d3fa18b (patch) | |
tree | 93d8918633cf5b3607ab4d7e2acaebbe38ada6ac | |
parent | d5e33853a27c639beda0a85062ce7db9996e22e1 (diff) | |
download | mandoc-3d53bc0f504bfa821a250cb8c824f1a71d3fa18b.tar.gz mandoc-3d53bc0f504bfa821a250cb8c824f1a71d3fa18b.tar.zst mandoc-3d53bc0f504bfa821a250cb8c824f1a71d3fa18b.zip |
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.
-rw-r--r-- | tbl.7 | 9 | ||||
-rw-r--r-- | tbl_data.c | 22 | ||||
-rw-r--r-- | tbl_layout.c | 16 | ||||
-rw-r--r-- | tbl_term.c | 25 |
4 files changed, 51 insertions, 21 deletions
@@ -1,4 +1,4 @@ -.\" $Id: tbl.7,v 1.3 2011/01/05 20:02:34 kristaps Exp $ +.\" $Id: tbl.7,v 1.4 2011/01/07 14:59:52 kristaps Exp $ .\" .\" Copyright (c) 2010 Kristaps Dzonsons <kristaps@bsd.lv> .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: January 5 2011 $ +.Dd $Mdocdate: January 7 2011 $ .Dt TBL 7 .Os .Sh NAME @@ -277,7 +277,10 @@ If the last cell of a line is .Cm T{ , all subsequent lines are included as part of the cell until .Cm T} -is specified on its own line. +is specified as its own data cell. +It may then be followed by a tab +.Pq or as designated by Cm tab +or an end-of-line to terminate the row. .Sh COMPATIBILITY This section documents compatibility between mandoc and other .Nm @@ -1,4 +1,4 @@ -/* $Id: tbl_data.c,v 1.13 2011/01/07 13:20:58 kristaps Exp $ */ +/* $Id: tbl_data.c,v 1.14 2011/01/07 14:59:52 kristaps Exp $ */ /* * Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -118,15 +118,27 @@ tbl_cdata(struct tbl_node *tbl, int ln, const char *p) { struct tbl_dat *dat; size_t sz; + int pos; - if (0 == strcmp(p, "T}")) { - tbl->part = TBL_PART_DATA; - return(1); - } + pos = 0; dat = tbl->last_span->last; dat->pos = TBL_DATA_DATA; + if (p[pos] == 'T' && p[pos + 1] == '}') { + pos += 2; + if (p[pos] == tbl->opts.tab) { + tbl->part = TBL_PART_DATA; + pos++; + return(data(tbl, tbl->last_span, ln, p, &pos)); + } else if ('\0' == p[pos]) { + tbl->part = TBL_PART_DATA; + return(1); + } + + /* Fallthrough: T} is part of a word. */ + } + if (dat->string) { sz = strlen(p) + strlen(dat->string) + 2; dat->string = mandoc_realloc(dat->string, sz); diff --git a/tbl_layout.c b/tbl_layout.c index c5686c04..fc03086b 100644 --- a/tbl_layout.c +++ b/tbl_layout.c @@ -1,4 +1,4 @@ -/* $Id: tbl_layout.c,v 1.11 2011/01/07 13:03:48 kristaps Exp $ */ +/* $Id: tbl_layout.c,v 1.12 2011/01/07 14:59:52 kristaps Exp $ */ /* * Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -90,6 +90,20 @@ mod: break; } + /* Throw away parenthesised expression. */ + + if ('(' == p[*pos]) { + (*pos)++; + while (p[*pos] && ')' != p[*pos]) + (*pos)++; + if (')' == p[*pos]) { + (*pos)++; + goto mod; + } + TBL_MSG(tbl, MANDOCERR_TBLLAYOUT, ln, *pos); + return(0); + } + /* Parse numerical spacing from modifier string. */ if (isdigit((unsigned char)p[*pos])) { @@ -1,4 +1,4 @@ -/* $Id: tbl_term.c,v 1.12 2011/01/07 13:20:58 kristaps Exp $ */ +/* $Id: tbl_term.c,v 1.13 2011/01/07 14:59:52 kristaps Exp $ */ /* * Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -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); } |