diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2015-01-28 17:32:07 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2015-01-28 17:32:07 +0000 |
commit | d04af2267985bcac279f3ffad1ce6ee9fec2d44f (patch) | |
tree | 416a18e84777806b55f50c7fb1147e9c88c4ef4b | |
parent | b8a3bef0831e00e2921ed5feb59338efcca0984d (diff) | |
download | mandoc-d04af2267985bcac279f3ffad1ce6ee9fec2d44f.tar.gz |
* Polish tbl(7) error reporting.
* Do not print out macro names in tbl(7) data blocks.
* Like with GNU tbl, let empty tables cause a blank line.
* Avoid producing empty tables in -Tman.
-rw-r--r-- | libroff.h | 2 | ||||
-rw-r--r-- | mandoc.1 | 49 | ||||
-rw-r--r-- | mandoc.h | 14 | ||||
-rw-r--r-- | mdoc_man.c | 13 | ||||
-rw-r--r-- | read.c | 10 | ||||
-rw-r--r-- | roff.c | 9 | ||||
-rw-r--r-- | tbl.c | 28 | ||||
-rw-r--r-- | tbl_data.c | 18 | ||||
-rw-r--r-- | tbl_opts.c | 3 |
9 files changed, 89 insertions, 57 deletions
@@ -74,7 +74,7 @@ void tbl_layout(struct tbl_node *, int, const char *, int); void tbl_data(struct tbl_node *, int, const char *, int); int tbl_cdata(struct tbl_node *, int, const char *, int); const struct tbl_span *tbl_span(struct tbl_node *); -void tbl_end(struct tbl_node **); +int tbl_end(struct tbl_node **); struct eqn_node *eqn_alloc(int, int, struct mparse *); enum rofferr eqn_end(struct eqn_node **); void eqn_free(struct eqn_node *); @@ -1336,13 +1336,30 @@ The invalid character is discarded. A table layout specification contains an opening parenthesis, but no matching closing parenthesis. The rest of the input line, starting from the parenthesis, has no effect. -.El -.Pp -.Bl -inset -compact -.It Sy "no table data cells specified" -.It Sy "ignore data in cell" -.It Sy "data block still open" -.It Sy "ignoring extra data cells" +.It Sy "tbl without any data cells" +.Pq tbl +A table does not contain any data cells. +It will probably produce no output. +.It Sy "ignoring data in spanned tbl cell" +.Pq tbl +A table cell is marked as a horizontal span +.Pq Sq Cm s +or vertical span +.Pq Sq Cm ^ +in the table layout, but it contains data. +The data is ignored. +.It Sy "ignoring extra tbl data cells" +.Pq tbl +A data line contains more cells than the corresponding layout line. +The data in the extra cells is ignored. +.It Sy "data block open at end of tbl" +.Pq tbl +A data block is opened with +.Cm T{ , +but never closed with a matching +.Cm T} . +The remaining data lines of the table are all put into one cell, +and any remaining cells stay empty. .El .Ss "Errors related to roff, mdoc, and man code" .Bl -ohang @@ -1640,17 +1657,25 @@ request supported by GNU troff or Heirloom troff but not by .Nm , and it is likely that this will cause information loss or considerable misformatting. -.It Sy "unsupported table layout modfier" +.It Sy "eqn delim option in tbl" +.Pq eqn , tbl +The options line of a table defines equation delimiters. +Any equation source code contained in the table will be printed unformatted. +.It Sy "unsupported table layout modifier" .Pq tbl A table layout specification contains an .Sq Cm m modifier. The modifier is discarded. .It Sy "ignoring macro in table" -.It Sy "eqn in tbl" -.Pq eqn , tbl -The options line of a table defines equation delimiters. -Any equation source code contained in the table will be printed unformatted. +.Pq tbl , mdoc , man +A table contains an invocation of an +.Xr mdoc 7 +or +.Xr man 7 +macro or of an undefined macro. +The macro is ignored, and its arguments are handled +as if they were a text line. .El .Sh COMPATIBILITY This section summarises @@ -143,15 +143,15 @@ enum mandocerr { /* related to tables */ MANDOCERR_TBLOPT_ALPHA, /* non-alphabetic character in tbl options */ MANDOCERR_TBLOPT_BAD, /* skipping unknown tbl option: option */ - MANDOCERR_TBLOPT_NOARG, /* missing tbl option argument */ - MANDOCERR_TBLOPT_ARGSZ, /* wrong tbl option argument size */ + MANDOCERR_TBLOPT_NOARG, /* missing tbl option argument: option */ + MANDOCERR_TBLOPT_ARGSZ, /* wrong tbl option argument size: option */ MANDOCERR_TBLLAYOUT_NONE, /* empty tbl layout */ MANDOCERR_TBLLAYOUT_CHAR, /* invalid character in tbl layout: char */ MANDOCERR_TBLLAYOUT_PAR, /* unmatched parenthesis in tbl layout */ - MANDOCERR_TBLNODATA, /* no table data cells specified */ - MANDOCERR_TBLIGNDATA, /* ignore data in cell */ - MANDOCERR_TBLBLOCK, /* data block still open */ - MANDOCERR_TBLEXTRADAT, /* ignoring extra data cells */ + MANDOCERR_TBLDATA_NONE, /* tbl without any data cells */ + MANDOCERR_TBLDATA_SPAN, /* ignoring data in spanned tbl cell: data */ + MANDOCERR_TBLDATA_EXTRA, /* ignoring extra tbl data cells: data */ + MANDOCERR_TBLDATA_BLK, /* data block open at end of tbl: macro */ /* related to document structure and macros */ MANDOCERR_FILE, /* cannot open file */ @@ -186,9 +186,9 @@ enum mandocerr { MANDOCERR_TOOLARGE, /* input too large */ MANDOCERR_CHAR_UNSUPP, /* unsupported control character: number */ MANDOCERR_REQ_UNSUPP, /* unsupported roff request: request */ + MANDOCERR_TBLOPT_EQN, /* eqn delim option in tbl: arg */ MANDOCERR_TBLLAYOUT_MOD, /* unsupported tbl layout modifier: m */ MANDOCERR_TBLMACRO, /* ignoring macro in table: macro */ - MANDOCERR_TBLEQN, /* eqn in tbl */ MANDOCERR_MAX }; @@ -1006,10 +1006,12 @@ pre_bl(DECL_ARGS) return(1); } - print_line(".TS", MMAN_nl); - for (icol = 0; icol < n->norm->Bl.ncols; icol++) - print_word("l"); - print_word("."); + if (n->nchild) { + print_line(".TS", MMAN_nl); + for (icol = 0; icol < n->norm->Bl.ncols; icol++) + print_word("l"); + print_word("."); + } outflags |= MMAN_nl; return(1); } @@ -1020,7 +1022,8 @@ post_bl(DECL_ARGS) switch (n->norm->Bl.type) { case LIST_column: - print_line(".TE", 0); + if (n->nchild) + print_line(".TE", 0); break; case LIST_enum: n->norm->Bl.count = 0; @@ -192,10 +192,10 @@ static const char * const mandocerrs[MANDOCERR_MAX] = { "empty tbl layout", "invalid character in tbl layout", "unmatched parenthesis in tbl layout", - "no table data cells specified", - "ignore data in cell", - "data block still open", - "ignoring extra data cells", + "tbl without any data cells", + "ignoring data in spanned tbl cell", + "ignoring extra tbl data cells", + "data block open at end of tbl", /* related to document structure and macros */ NULL, @@ -229,9 +229,9 @@ static const char * const mandocerrs[MANDOCERR_MAX] = { "input too large", "unsupported control character", "unsupported roff request", + "eqn delim option in tbl", "unsupported tbl layout modifier", "ignoring macro in table", - "eqn in tbl", }; static const char * const mandoclevels[MANDOCLEVEL_MAX] = { @@ -2376,9 +2376,12 @@ roff_TE(ROFF_ARGS) if (NULL == r->tbl) mandoc_msg(MANDOCERR_BLK_NOTOPEN, r->parse, ln, ppos, "TE"); - else - tbl_end(&r->tbl); - + else if ( ! tbl_end(&r->tbl)) { + free(buf->buf); + buf->buf = mandoc_strdup(".sp"); + buf->sz = 4; + return(ROFF_REPARSE); + } return(ROFF_IGN); } @@ -143,17 +143,13 @@ tbl_free(struct tbl_node *tbl) void tbl_restart(int line, int pos, struct tbl_node *tbl) { - if (TBL_PART_CDATA == tbl->part) - mandoc_msg(MANDOCERR_TBLBLOCK, tbl->parse, - tbl->line, tbl->pos, NULL); + if (tbl->part == TBL_PART_CDATA) + mandoc_msg(MANDOCERR_TBLDATA_BLK, tbl->parse, + line, pos, "T&"); tbl->part = TBL_PART_LAYOUT; tbl->line = line; tbl->pos = pos; - - if (NULL == tbl->first_span || NULL == tbl->first_span->first) - mandoc_msg(MANDOCERR_TBLNODATA, tbl->parse, - tbl->line, tbl->pos, NULL); } const struct tbl_span * @@ -169,7 +165,7 @@ tbl_span(struct tbl_node *tbl) return(span); } -void +int tbl_end(struct tbl_node **tblp) { struct tbl_node *tbl; @@ -178,17 +174,21 @@ tbl_end(struct tbl_node **tblp) tbl = *tblp; *tblp = NULL; + if (tbl->part == TBL_PART_CDATA) + mandoc_msg(MANDOCERR_TBLDATA_BLK, tbl->parse, + tbl->line, tbl->pos, "TE"); + sp = tbl->first_span; while (sp != NULL && sp->first == NULL) sp = sp->next; - if (sp == NULL) - mandoc_msg(MANDOCERR_TBLNODATA, tbl->parse, + if (sp == NULL) { + mandoc_msg(MANDOCERR_TBLDATA_NONE, tbl->parse, tbl->line, tbl->pos, NULL); + return(0); + } - if (tbl->last_span) + if (tbl->last_span != NULL) tbl->last_span->flags |= TBL_SPAN_LAST; - if (TBL_PART_CDATA == tbl->part) - mandoc_msg(MANDOCERR_TBLBLOCK, tbl->parse, - tbl->line, tbl->pos, NULL); + return(1); } @@ -64,8 +64,8 @@ getdata(struct tbl_node *tbl, struct tbl_span *dp, */ if (NULL == cp) { - mandoc_msg(MANDOCERR_TBLEXTRADAT, tbl->parse, - ln, *pos, NULL); + mandoc_msg(MANDOCERR_TBLDATA_EXTRA, tbl->parse, + ln, *pos, p + *pos); /* Skip to the end... */ while (p[*pos]) (*pos)++; @@ -131,8 +131,8 @@ getdata(struct tbl_node *tbl, struct tbl_span *dp, TBL_CELL_DHORIZ == dat->layout->pos || TBL_CELL_DOWN == dat->layout->pos) if (TBL_DATA_DATA == dat->pos && '\0' != *dat->string) - mandoc_msg(MANDOCERR_TBLIGNDATA, - tbl->parse, ln, sv, NULL); + mandoc_msg(MANDOCERR_TBLDATA_SPAN, + tbl->parse, ln, sv, dat->string); return; } @@ -163,16 +163,16 @@ tbl_cdata(struct tbl_node *tbl, int ln, const char *p, int pos) dat->pos = TBL_DATA_DATA; if (dat->string) { - sz = strlen(p) + strlen(dat->string) + 2; + sz = strlen(p + pos) + strlen(dat->string) + 2; dat->string = mandoc_realloc(dat->string, sz); (void)strlcat(dat->string, " ", sz); - (void)strlcat(dat->string, p, sz); + (void)strlcat(dat->string, p + pos, sz); } else - dat->string = mandoc_strdup(p); + dat->string = mandoc_strdup(p + pos); if (TBL_CELL_DOWN == dat->layout->pos) - mandoc_msg(MANDOCERR_TBLIGNDATA, tbl->parse, - ln, pos, NULL); + mandoc_msg(MANDOCERR_TBLDATA_SPAN, tbl->parse, + ln, pos, dat->string); return(0); } @@ -80,7 +80,8 @@ arg(struct tbl_node *tbl, int ln, const char *p, int *pos, int key) switch (key) { case KEY_DELIM: - mandoc_msg(MANDOCERR_TBLEQN, tbl->parse, ln, *pos, NULL); + mandoc_vmsg(MANDOCERR_TBLOPT_EQN, tbl->parse, + ln, *pos, "%.*s", len, p + *pos); want = 2; break; case KEY_TAB: |