From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from localhost (fantadrom.bsd.lv [local]); by fantadrom.bsd.lv (OpenSMTPD) with ESMTPA id c7793731; for ; Wed, 28 Jan 2015 12:32:38 -0500 (EST) Date: Wed, 28 Jan 2015 12:32:38 -0500 (EST) Message-Id: <14968312938028566682.enqueue@fantadrom.bsd.lv> X-Mailinglist: mdocml-source Reply-To: source@mdocml.bsd.lv MIME-Version: 1.0 From: schwarze@mdocml.bsd.lv To: source@mdocml.bsd.lv Subject: mdocml: * Polish tbl(7) error reporting. X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Log Message: ----------- * 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. Modified Files: -------------- mdocml: libroff.h mandoc.1 mandoc.h mdoc_man.c read.c roff.c tbl.c tbl_data.c tbl_opts.c Revision Data ------------- Index: mdoc_man.c =================================================================== RCS file: /home/cvs/mdocml/mdocml/mdoc_man.c,v retrieving revision 1.82 retrieving revision 1.83 diff -Lmdoc_man.c -Lmdoc_man.c -u -p -r1.82 -r1.83 --- mdoc_man.c +++ mdoc_man.c @@ -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; Index: mandoc.1 =================================================================== RCS file: /home/cvs/mdocml/mdocml/mandoc.1,v retrieving revision 1.138 retrieving revision 1.139 diff -Lmandoc.1 -Lmandoc.1 -u -p -r1.138 -r1.139 --- mandoc.1 +++ mandoc.1 @@ -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 Heirlo .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 Index: libroff.h =================================================================== RCS file: /home/cvs/mdocml/mdocml/libroff.h,v retrieving revision 1.36 retrieving revision 1.37 diff -Llibroff.h -Llibroff.h -u -p -r1.36 -r1.37 --- libroff.h +++ libroff.h @@ -74,7 +74,7 @@ void tbl_layout(struct tbl_node *, 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 *); Index: tbl_data.c =================================================================== RCS file: /home/cvs/mdocml/mdocml/tbl_data.c,v retrieving revision 1.35 retrieving revision 1.36 diff -Ltbl_data.c -Ltbl_data.c -u -p -r1.35 -r1.36 --- tbl_data.c +++ tbl_data.c @@ -64,8 +64,8 @@ getdata(struct tbl_node *tbl, struct tbl */ 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 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, 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); } Index: roff.c =================================================================== RCS file: /home/cvs/mdocml/mdocml/roff.c,v retrieving revision 1.257 retrieving revision 1.258 diff -Lroff.c -Lroff.c -u -p -r1.257 -r1.258 --- roff.c +++ roff.c @@ -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); } Index: tbl.c =================================================================== RCS file: /home/cvs/mdocml/mdocml/tbl.c,v retrieving revision 1.35 retrieving revision 1.36 diff -Ltbl.c -Ltbl.c -u -p -r1.35 -r1.36 --- tbl.c +++ tbl.c @@ -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); } Index: mandoc.h =================================================================== RCS file: /home/cvs/mdocml/mdocml/mandoc.h,v retrieving revision 1.190 retrieving revision 1.191 diff -Lmandoc.h -Lmandoc.h -u -p -r1.190 -r1.191 --- mandoc.h +++ mandoc.h @@ -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 }; Index: tbl_opts.c =================================================================== RCS file: /home/cvs/mdocml/mdocml/tbl_opts.c,v retrieving revision 1.19 retrieving revision 1.20 diff -Ltbl_opts.c -Ltbl_opts.c -u -p -r1.19 -r1.20 --- tbl_opts.c +++ tbl_opts.c @@ -80,7 +80,8 @@ arg(struct tbl_node *tbl, int ln, const 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: Index: read.c =================================================================== RCS file: /home/cvs/mdocml/mdocml/read.c,v retrieving revision 1.118 retrieving revision 1.119 diff -Lread.c -Lread.c -u -p -r1.118 -r1.119 --- read.c +++ read.c @@ -192,10 +192,10 @@ static const char * const mandocerrs[MAN "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[MAN "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] = { -- To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv