summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2010-11-28 19:35:34 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2010-11-28 19:35:34 +0000
commit73ae9b994578b84a3e6e5ed89a1b06fd8722dd3f (patch)
tree4a58fe0915ebe7770c32896a98db21ed280b0e17 /usr.bin
parentee45f40b239b55c3fd78fe75c0303cd5a067a804 (diff)
To avoid FATAL errors, we have been parsing and ignoring the roff
requests .am, .ami, .am1, .dei, and .rm for a long time. Since ignoring them can (rarely) cause information loss and serious misformatting, throw an ERROR: NOT IMPLEMENTED when finding them. Implementing them would not be too difficult, but they are so rare in practice that i can find better use for my time right now. In this context, - Put the string "NOT IMPLEMENTED" into two other error messages as well, to distinguish them from those caused by broken input. - Print the string "unknown macro" once, not twice in the error message associated with MANDOCERR_MACRO, and begin printing the buffer at the point where the unknown macro really is, not at the start of line.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mandoc/main.c7
-rw-r--r--usr.bin/mandoc/man.c6
-rw-r--r--usr.bin/mandoc/mandoc.h7
-rw-r--r--usr.bin/mandoc/mdoc.c6
-rw-r--r--usr.bin/mandoc/roff.c32
5 files changed, 35 insertions, 23 deletions
diff --git a/usr.bin/mandoc/main.c b/usr.bin/mandoc/main.c
index ed3d1ba85fa..499d5a9425c 100644
--- a/usr.bin/mandoc/main.c
+++ b/usr.bin/mandoc/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.55 2010/11/25 22:23:31 schwarze Exp $ */
+/* $Id: main.c,v 1.56 2010/11/28 19:35:33 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -163,6 +163,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = {
"skipping bad character",
"skipping text before the first section header",
"skipping unknown macro",
+ "NOT IMPLEMENTED: skipping request",
"line scope broken",
"argument count wrong",
"skipping end of block that is not open",
@@ -180,12 +181,12 @@ static const char * const mandocerrs[MANDOCERR_MAX] = {
"generic fatal error",
"column syntax is inconsistent",
- "unsupported display type",
+ "NOT IMPLEMENTED: .Bd -file",
"line scope broken, syntax violated",
"argument count wrong, violates syntax",
"child violates parent syntax",
"argument count wrong, violates syntax",
- "invalid path in include directive",
+ "NOT IMPLEMENTED: .so with absolute path or \"..\"",
"no document body",
"no document prologue",
"static buffer exhausted",
diff --git a/usr.bin/mandoc/man.c b/usr.bin/mandoc/man.c
index 9f43b074228..b032524de7b 100644
--- a/usr.bin/mandoc/man.c
+++ b/usr.bin/mandoc/man.c
@@ -1,4 +1,4 @@
-/* $Id: man.c,v 1.43 2010/10/16 20:49:37 schwarze Exp $ */
+/* $Id: man.c,v 1.44 2010/11/28 19:35:33 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -490,9 +490,7 @@ man_pmacro(struct man *m, int ln, char *buf, int offs)
tok = (j > 0 && j < 4) ? man_hash_find(mac) : MAN_MAX;
if (MAN_MAX == tok) {
- man_vmsg(m, MANDOCERR_MACRO, ln, ppos,
- "unknown macro: %s%s",
- buf, strlen(buf) > 3 ? "..." : "");
+ man_vmsg(m, MANDOCERR_MACRO, ln, ppos, "%s", buf + ppos - 1);
return(1);
}
diff --git a/usr.bin/mandoc/mandoc.h b/usr.bin/mandoc/mandoc.h
index 65d9b1fb79a..46d683489db 100644
--- a/usr.bin/mandoc/mandoc.h
+++ b/usr.bin/mandoc/mandoc.h
@@ -1,4 +1,4 @@
-/* $Id: mandoc.h,v 1.20 2010/10/26 23:34:38 schwarze Exp $ */
+/* $Id: mandoc.h,v 1.21 2010/11/28 19:35:33 schwarze Exp $ */
/*
* Copyright (c) 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -103,6 +103,7 @@ enum mandocerr {
MANDOCERR_BADCHAR, /* skipping bad character */
MANDOCERR_NOTEXT, /* skipping text before the first section header */
MANDOCERR_MACRO, /* skipping unknown macro */
+ MANDOCERR_REQUEST, /* NOT IMPLEMENTED: skipping request */
MANDOCERR_LINESCOPE, /* line scope broken */
MANDOCERR_ARGCOUNT, /* argument count wrong */
MANDOCERR_NOSCOPE, /* skipping end of block that is not open */
@@ -120,12 +121,12 @@ enum mandocerr {
MANDOCERR_FATAL, /* ===== start of fatal errors ===== */
MANDOCERR_COLUMNS, /* column syntax is inconsistent */
- MANDOCERR_BADDISP, /* unsupported display type */
+ MANDOCERR_BADDISP, /* NOT IMPLEMENTED: .Bd -file */
MANDOCERR_SYNTLINESCOPE, /* line scope broken, syntax violated */
MANDOCERR_SYNTARGVCOUNT, /* argument count wrong, violates syntax */
MANDOCERR_SYNTCHILD, /* child violates parent syntax */
MANDOCERR_SYNTARGCOUNT, /* argument count wrong, violates syntax */
- MANDOCERR_SOPATH, /* invalid path in include directive */
+ MANDOCERR_SOPATH, /* NOT IMPLEMENTED: .so with absolute path or ".." */
MANDOCERR_NODOCBODY, /* no document body */
MANDOCERR_NODOCPROLOG, /* no document prologue */
MANDOCERR_MEM, /* static buffer exhausted */
diff --git a/usr.bin/mandoc/mdoc.c b/usr.bin/mandoc/mdoc.c
index f1afacbc93a..67976bfbf5d 100644
--- a/usr.bin/mandoc/mdoc.c
+++ b/usr.bin/mandoc/mdoc.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc.c,v 1.68 2010/10/16 20:49:37 schwarze Exp $ */
+/* $Id: mdoc.c,v 1.69 2010/11/28 19:35:33 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -783,9 +783,7 @@ mdoc_pmacro(struct mdoc *m, int ln, char *buf, int offs)
tok = (j > 1 || j < 4) ? mdoc_hash_find(mac) : MDOC_MAX;
if (MDOC_MAX == tok) {
- mdoc_vmsg(m, MANDOCERR_MACRO, ln, sv,
- "unknown macro: %s%s",
- buf, strlen(buf) > 3 ? "..." : "");
+ mdoc_vmsg(m, MANDOCERR_MACRO, ln, sv, "%s", buf + sv - 1);
return(1);
}
diff --git a/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c
index eb725b6a33f..de161836d77 100644
--- a/usr.bin/mandoc/roff.c
+++ b/usr.bin/mandoc/roff.c
@@ -1,4 +1,4 @@
-/* $Id: roff.c,v 1.20 2010/11/28 01:00:40 schwarze Exp $ */
+/* $Id: roff.c,v 1.21 2010/11/28 19:35:33 schwarze Exp $ */
/*
* Copyright (c) 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -130,7 +130,8 @@ static enum roffrule roff_evalcond(const char *, int *);
static void roff_freestr(struct roff *);
static const char *roff_getstrn(const struct roff *,
const char *, size_t);
-static enum rofferr roff_line(ROFF_ARGS);
+static enum rofferr roff_line_ignore(ROFF_ARGS);
+static enum rofferr roff_line_error(ROFF_ARGS);
static enum rofferr roff_nr(ROFF_ARGS);
static int roff_res(struct roff *,
char **, size_t *, int);
@@ -148,7 +149,7 @@ static enum rofferr roff_userdef(ROFF_ARGS);
static struct roffmac *hash[HASHWIDTH];
static struct roffmac roffs[ROFF_MAX] = {
- { "ad", roff_line, NULL, NULL, 0, NULL },
+ { "ad", roff_line_ignore, NULL, NULL, 0, NULL },
{ "am", roff_block, roff_block_text, roff_block_sub, 0, NULL },
{ "ami", roff_block, roff_block_text, roff_block_sub, 0, NULL },
{ "am1", roff_block, roff_block_text, roff_block_sub, 0, NULL },
@@ -157,16 +158,16 @@ static struct roffmac roffs[ROFF_MAX] = {
{ "de1", roff_block, roff_block_text, roff_block_sub, 0, NULL },
{ "ds", roff_ds, NULL, NULL, 0, NULL },
{ "el", roff_cond, roff_cond_text, roff_cond_sub, ROFFMAC_STRUCT, NULL },
- { "hy", roff_line, NULL, NULL, 0, NULL },
+ { "hy", roff_line_ignore, NULL, NULL, 0, NULL },
{ "ie", roff_cond, roff_cond_text, roff_cond_sub, ROFFMAC_STRUCT, NULL },
{ "if", roff_cond, roff_cond_text, roff_cond_sub, ROFFMAC_STRUCT, NULL },
{ "ig", roff_block, roff_block_text, roff_block_sub, 0, NULL },
- { "ne", roff_line, NULL, NULL, 0, NULL },
- { "nh", roff_line, NULL, NULL, 0, NULL },
+ { "ne", roff_line_ignore, NULL, NULL, 0, NULL },
+ { "nh", roff_line_ignore, NULL, NULL, 0, NULL },
{ "nr", roff_nr, NULL, NULL, 0, NULL },
- { "rm", roff_line, NULL, NULL, 0, NULL },
+ { "rm", roff_line_error, NULL, NULL, 0, NULL },
{ "so", roff_so, NULL, NULL, 0, NULL },
- { "tr", roff_line, NULL, NULL, 0, NULL },
+ { "tr", roff_line_ignore, NULL, NULL, 0, NULL },
{ ".", roff_cblock, NULL, NULL, 0, NULL },
{ "\\}", roff_ccond, NULL, NULL, 0, NULL },
{ NULL, roff_userdef, NULL, NULL, 0, NULL },
@@ -636,6 +637,9 @@ roff_block(ROFF_ARGS)
tok = ROFF_de;
if (ROFF_de == tok)
name = *bufp + pos;
+ else
+ (*r->msg)(MANDOCERR_REQUEST, r->data, ln, ppos,
+ roffs[tok].name);
while ((*bufp)[pos] && ' ' != (*bufp)[pos])
pos++;
while (' ' == (*bufp)[pos])
@@ -857,9 +861,19 @@ roff_evalcond(const char *v, int *pos)
/* ARGSUSED */
static enum rofferr
-roff_line(ROFF_ARGS)
+roff_line_ignore(ROFF_ARGS)
+{
+
+ return(ROFF_IGN);
+}
+
+
+/* ARGSUSED */
+static enum rofferr
+roff_line_error(ROFF_ARGS)
{
+ (*r->msg)(MANDOCERR_REQUEST, r->data, ln, ppos, roffs[tok].name);
return(ROFF_IGN);
}