=================================================================== RCS file: /cvs/mandoc/tbl_layout.c,v retrieving revision 1.13 retrieving revision 1.17 diff -u -p -r1.13 -r1.17 --- mandoc/tbl_layout.c 2011/01/09 05:38:23 1.13 +++ mandoc/tbl_layout.c 2011/03/20 16:02:05 1.17 @@ -1,4 +1,4 @@ -/* $Id: tbl_layout.c,v 1.13 2011/01/09 05:38:23 joerg Exp $ */ +/* $Id: tbl_layout.c,v 1.17 2011/03/20 16:02:05 kristaps Exp $ */ /* * Copyright (c) 2009, 2010 Kristaps Dzonsons * @@ -100,7 +100,8 @@ mod: (*pos)++; goto mod; } - TBL_MSG(tbl, MANDOCERR_TBLLAYOUT, ln, *pos); + mandoc_msg(MANDOCERR_TBLLAYOUT, + tbl->parse, ln, *pos, NULL); return(0); } @@ -117,12 +118,13 @@ mod: /* No greater than 4 digits. */ if (4 == i) { - TBL_MSG(tbl, MANDOCERR_TBLLAYOUT, ln, *pos); + mandoc_msg(MANDOCERR_TBLLAYOUT, tbl->parse, + ln, *pos, NULL); return(0); } *pos += i; - cp->spacing = atoi(buf); + cp->spacing = (size_t)atoi(buf); goto mod; /* NOTREACHED */ @@ -156,7 +158,8 @@ mod: (*pos)--; break; default: - TBL_MSG(tbl, MANDOCERR_TBLLAYOUT, ln, *pos - 1); + mandoc_msg(MANDOCERR_TBLLAYOUT, tbl->parse, + ln, *pos - 1, NULL); return(0); } @@ -171,7 +174,8 @@ mod: break; } - TBL_MSG(tbl, MANDOCERR_TBLLAYOUT, ln, *pos - 1); + mandoc_msg(MANDOCERR_TBLLAYOUT, tbl->parse, + ln, *pos - 1, NULL); return(0); } @@ -189,7 +193,8 @@ cell(struct tbl_node *tbl, struct tbl_row *rp, break; if (KEYS_MAX == i) { - TBL_MSG(tbl, MANDOCERR_TBLLAYOUT, ln, *pos); + mandoc_msg(MANDOCERR_TBLLAYOUT, tbl->parse, + ln, *pos, NULL); return(0); } @@ -197,11 +202,38 @@ cell(struct tbl_node *tbl, struct tbl_row *rp, /* * If a span cell is found first, raise a warning and abort the - * parse. FIXME: recover from this somehow? + * parse. If a span cell is found and the last layout element + * isn't a "normal" layout, bail. + * + * FIXME: recover from this somehow? */ - if (NULL == rp->first && TBL_CELL_SPAN == c) { - TBL_MSG(tbl, MANDOCERR_TBLLAYOUT, ln, *pos); + if (TBL_CELL_SPAN == c) { + if (NULL == rp->first) { + mandoc_msg(MANDOCERR_TBLLAYOUT, tbl->parse, + ln, *pos, NULL); + return(0); + } else if (rp->last) + switch (rp->last->pos) { + case (TBL_CELL_VERT): + case (TBL_CELL_DVERT): + case (TBL_CELL_HORIZ): + case (TBL_CELL_DHORIZ): + mandoc_msg(MANDOCERR_TBLLAYOUT, tbl->parse, + ln, *pos, NULL); + return(0); + default: + break; + } + } + + /* + * If a vertical spanner is found, we may not be in the first + * row. + */ + + if (TBL_CELL_DOWN == c && rp == tbl->first_row) { + mandoc_msg(MANDOCERR_TBLLAYOUT, tbl->parse, ln, *pos, NULL); return(0); } @@ -219,7 +251,7 @@ cell(struct tbl_node *tbl, struct tbl_row *rp, if (rp->last && (TBL_CELL_VERT == c || TBL_CELL_DVERT == c) && (TBL_CELL_VERT == rp->last->pos || TBL_CELL_DVERT == rp->last->pos)) { - TBL_MSG(tbl, MANDOCERR_TBLLAYOUT, ln, *pos - 1); + mandoc_msg(MANDOCERR_TBLLAYOUT, tbl->parse, ln, *pos - 1, NULL); return(0); } @@ -260,7 +292,8 @@ cell: if ('.' == p[*pos]) { tbl->part = TBL_PART_DATA; if (NULL == tbl->first_row) - TBL_MSG(tbl, MANDOCERR_TBLNOLAYOUT, ln, *pos); + mandoc_msg(MANDOCERR_TBLNOLAYOUT, tbl->parse, + ln, *pos, NULL); (*pos)++; return; }