aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2015-01-28 17:32:07 +0000
committerIngo Schwarze <schwarze@openbsd.org>2015-01-28 17:32:07 +0000
commit67cfc20e20f4c603c852ddf5c88024ce0d8d628c (patch)
tree5e3c7114721eba342929a649511dbf5a94439d6c
parent7793230177d864fb80c0c572a2b896f3ecb7df10 (diff)
downloadmandoc-67cfc20e20f4c603c852ddf5c88024ce0d8d628c.tar.gz
mandoc-67cfc20e20f4c603c852ddf5c88024ce0d8d628c.tar.zst
mandoc-67cfc20e20f4c603c852ddf5c88024ce0d8d628c.zip
* 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.h4
-rw-r--r--mandoc.153
-rw-r--r--mandoc.h16
-rw-r--r--mdoc_man.c15
-rw-r--r--read.c12
-rw-r--r--roff.c11
-rw-r--r--tbl.c30
-rw-r--r--tbl_data.c20
-rw-r--r--tbl_opts.c5
9 files changed, 99 insertions, 67 deletions
diff --git a/libroff.h b/libroff.h
index be2890a5..24286337 100644
--- a/libroff.h
+++ b/libroff.h
@@ -1,4 +1,4 @@
-/* $Id: libroff.h,v 1.36 2015/01/28 15:03:45 schwarze Exp $ */
+/* $Id: libroff.h,v 1.37 2015/01/28 17:32:07 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -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 *);
diff --git a/mandoc.1 b/mandoc.1
index 82c2d720..5e0d731a 100644
--- a/mandoc.1
+++ b/mandoc.1
@@ -1,4 +1,4 @@
-.\" $Id: mandoc.1,v 1.138 2015/01/26 18:42:30 schwarze Exp $
+.\" $Id: mandoc.1,v 1.139 2015/01/28 17:32:07 schwarze Exp $
.\"
.\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
.\" Copyright (c) 2012, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -15,7 +15,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 26 2015 $
+.Dd $Mdocdate: January 28 2015 $
.Dt MANDOC 1
.Os
.Sh NAME
@@ -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
diff --git a/mandoc.h b/mandoc.h
index 82d6fd7a..58e43410 100644
--- a/mandoc.h
+++ b/mandoc.h
@@ -1,4 +1,4 @@
-/* $Id: mandoc.h,v 1.190 2015/01/27 05:21:44 schwarze Exp $ */
+/* $Id: mandoc.h,v 1.191 2015/01/28 17:32:07 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -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
};
diff --git a/mdoc_man.c b/mdoc_man.c
index 3181b4a3..f329cd98 100644
--- a/mdoc_man.c
+++ b/mdoc_man.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_man.c,v 1.82 2015/01/23 14:21:01 schwarze Exp $ */
+/* $Id: mdoc_man.c,v 1.83 2015/01/28 17:32:07 schwarze Exp $ */
/*
* Copyright (c) 2011-2015 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -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;
diff --git a/read.c b/read.c
index 7d36778e..0cdb0a03 100644
--- a/read.c
+++ b/read.c
@@ -1,4 +1,4 @@
-/* $Id: read.c,v 1.118 2015/01/26 18:42:30 schwarze Exp $ */
+/* $Id: read.c,v 1.119 2015/01/28 17:32:07 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -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] = {
diff --git a/roff.c b/roff.c
index 7e1360e2..d64807d6 100644
--- a/roff.c
+++ b/roff.c
@@ -1,4 +1,4 @@
-/* $Id: roff.c,v 1.257 2015/01/28 15:03:45 schwarze Exp $ */
+/* $Id: roff.c,v 1.258 2015/01/28 17:32:07 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011, 2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -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);
}
diff --git a/tbl.c b/tbl.c
index c183750f..935e43c0 100644
--- a/tbl.c
+++ b/tbl.c
@@ -1,4 +1,4 @@
-/* $Id: tbl.c,v 1.35 2015/01/28 15:03:45 schwarze Exp $ */
+/* $Id: tbl.c,v 1.36 2015/01/28 17:32:07 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -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);
}
diff --git a/tbl_data.c b/tbl_data.c
index 9ac2566c..23a16450 100644
--- a/tbl_data.c
+++ b/tbl_data.c
@@ -1,4 +1,4 @@
-/* $Id: tbl_data.c,v 1.35 2015/01/28 15:03:45 schwarze Exp $ */
+/* $Id: tbl_data.c,v 1.36 2015/01/28 17:32:07 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -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);
}
diff --git a/tbl_opts.c b/tbl_opts.c
index 222c6e86..c012a3c8 100644
--- a/tbl_opts.c
+++ b/tbl_opts.c
@@ -1,4 +1,4 @@
-/* $Id: tbl_opts.c,v 1.19 2015/01/28 15:03:45 schwarze Exp $ */
+/* $Id: tbl_opts.c,v 1.20 2015/01/28 17:32:07 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -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: