summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2018-12-15 19:30:21 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2018-12-15 19:30:21 +0000
commit3962ec0010304a43d14512a8b79da75485655694 (patch)
treed05b34a3a0c349eea038e76ce0f88596e149de67 /usr.bin/mandoc
parent41d43cda283dfff21b7d5685cb433805d215733e (diff)
Several improvements to escape sequence handling.
* Add the missing special character \_ (underscore). * Partial implementations of \a (leader character) and \E (uninterpreted escape character). * Parse and ignore \r (reverse line feed). * Add a WARNING message about undefined escape sequences. * Add an UNSUPP message about unsupported escape sequences. * Mark \! and \? (transparent throughput) and \O (suppress output) as unsupported. * Treat the various variants of zero-width spaces as one-byte escape sequences rather than as special characters, to avoid defining bogus forms with square brackets. * For special characters with one-byte names, do not define bogus forms with square brackets, except for \[-], which is valid. * In the form with square brackets, undefined special characters do not fall back to printing the name verbatim, not even for one-byte names. * Starting a special character name with a blank is an error. * Undefined escape sequences never abort formatting of the input string, not even in HTML output mode. * Document the newly handled escapes, and a few that were missing. * Regression tests for most of the above.
Diffstat (limited to 'usr.bin/mandoc')
-rw-r--r--usr.bin/mandoc/chars.c22
-rw-r--r--usr.bin/mandoc/html.c10
-rw-r--r--usr.bin/mandoc/mandoc.120
-rw-r--r--usr.bin/mandoc/mandoc.c96
-rw-r--r--usr.bin/mandoc/mandoc.h6
-rw-r--r--usr.bin/mandoc/mandoc_msg.c4
-rw-r--r--usr.bin/mandoc/mdoc_man.c3
-rw-r--r--usr.bin/mandoc/mdoc_markdown.c5
-rw-r--r--usr.bin/mandoc/roff.c49
-rw-r--r--usr.bin/mandoc/term.c20
10 files changed, 167 insertions, 68 deletions
diff --git a/usr.bin/mandoc/chars.c b/usr.bin/mandoc/chars.c
index c28e78b50eb..13ccc6ba119 100644
--- a/usr.bin/mandoc/chars.c
+++ b/usr.bin/mandoc/chars.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: chars.c,v 1.47 2018/12/14 01:17:46 schwarze Exp $ */
+/* $OpenBSD: chars.c,v 1.48 2018/12/15 19:30:19 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2011, 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2011,2014,2015,2017,2018 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -46,21 +46,13 @@ static struct ln lines[] = {
{ " ", ascii_nbrsp, 0x00a0 },
{ "~", ascii_nbrsp, 0x00a0 },
{ "0", " ", 0x2002 },
- { "|", "", 0 },
- { "^", "", 0 },
- { "&", "", 0 },
- { ")", "", 0 },
- { "%", "", 0 },
{ ":", ascii_break, 0 },
- /* XXX The following three do not really belong here. */
- { "t", "", 0 },
- { "c", "", 0 },
- { "}", "", 0 },
/* Lines. */
{ "ba", "|", 0x007c },
{ "br", "|", 0x2502 },
{ "ul", "_", 0x005f },
+ { "_", "_", 0x005f },
{ "ru", "_", 0x005f },
{ "rn", "-", 0x203e },
{ "bb", "|", 0x00a6 },
@@ -463,7 +455,7 @@ mchars_spec2cp(const char *p, size_t sz)
end = p + sz;
ln = ohash_find(&mchars, ohash_qlookupi(&mchars, p, &end));
- return ln != NULL ? ln->unicode : sz == 1 ? (unsigned char)*p : -1;
+ return ln != NULL ? ln->unicode : -1;
}
int
@@ -493,10 +485,8 @@ mchars_spec2str(const char *p, size_t sz, size_t *rsz)
end = p + sz;
ln = ohash_find(&mchars, ohash_qlookupi(&mchars, p, &end));
- if (ln == NULL) {
- *rsz = 1;
- return sz == 1 ? p : NULL;
- }
+ if (ln == NULL)
+ return NULL;
*rsz = strlen(ln->ascii);
return ln->ascii;
diff --git a/usr.bin/mandoc/html.c b/usr.bin/mandoc/html.c
index cf44f6caced..9c93eb64e55 100644
--- a/usr.bin/mandoc/html.c
+++ b/usr.bin/mandoc/html.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: html.c,v 1.115 2018/12/04 18:29:18 schwarze Exp $ */
+/* $OpenBSD: html.c,v 1.116 2018/12/15 19:30:19 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -400,9 +400,6 @@ print_encode(struct html *h, const char *p, const char *pend, int norecurse)
continue;
esc = mandoc_escape(&p, &seq, &len);
- if (ESCAPE_ERROR == esc)
- break;
-
switch (esc) {
case ESCAPE_FONT:
case ESCAPE_FONTPREV:
@@ -420,6 +417,8 @@ print_encode(struct html *h, const char *p, const char *pend, int norecurse)
case ESCAPE_SKIPCHAR:
h->flags |= HTML_SKIPCHAR;
continue;
+ case ESCAPE_ERROR:
+ continue;
default:
break;
}
@@ -444,6 +443,9 @@ print_encode(struct html *h, const char *p, const char *pend, int norecurse)
if (c <= 0)
continue;
break;
+ case ESCAPE_UNDEF:
+ c = *seq;
+ break;
case ESCAPE_DEVICE:
print_word(h, "html");
continue;
diff --git a/usr.bin/mandoc/mandoc.1 b/usr.bin/mandoc/mandoc.1
index af46152384c..4413055c909 100644
--- a/usr.bin/mandoc/mandoc.1
+++ b/usr.bin/mandoc/mandoc.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: mandoc.1,v 1.155 2018/11/22 11:30:15 schwarze Exp $
+.\" $OpenBSD: mandoc.1,v 1.156 2018/12/15 19:30:19 schwarze Exp $
.\"
.\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
.\" Copyright (c) 2012, 2014-2018 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: November 22 2018 $
+.Dd $Mdocdate: December 15 2018 $
.Dt MANDOC 1
.Os
.Sh NAME
@@ -1676,7 +1676,8 @@ Start it on a new input line to help formatters produce correct spacing.
.It Sy "invalid escape sequence"
.Pq roff
An escape sequence has an invalid opening argument delimiter, lacks the
-closing argument delimiter, or the argument has too few characters.
+closing argument delimiter, the argument is of an invalid form, or it is
+a character escape sequence with an invalid name.
If the argument is incomplete,
.Ic \e*
and
@@ -1689,6 +1690,12 @@ and
.Ic \ew
to the length of the incomplete argument.
All other invalid escape sequences are ignored.
+.It Sy "undefined escape, printing literally"
+.Pq roff
+In an escape sequence, the first character
+right after the leading backslash is invalid.
+That character is printed literally,
+which is equivalent to ignoring the backslash.
.It Sy "undefined string, using \(dq\(dq"
.Pq roff
If a string is used without being defined before,
@@ -2154,6 +2161,13 @@ implementations but not by
.Nm
was found in an input file.
It is replaced by a question mark.
+.It Sy "unsupported escape sequence"
+.Pq roff
+An input file contains an escape sequence 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 roff request"
.Pq roff
An input file contains a
diff --git a/usr.bin/mandoc/mandoc.c b/usr.bin/mandoc/mandoc.c
index ac84e93497c..f4249a4b78f 100644
--- a/usr.bin/mandoc/mandoc.c
+++ b/usr.bin/mandoc/mandoc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mandoc.c,v 1.78 2018/12/14 06:33:03 schwarze Exp $ */
+/* $OpenBSD: mandoc.c,v 1.79 2018/12/15 19:30:19 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -54,6 +54,14 @@ mandoc_escape(const char **end, const char **start, int *sz)
sz = &local_sz;
/*
+ * Treat "\E" just like "\";
+ * it only makes a difference in copy mode.
+ */
+
+ if (**end == 'E')
+ ++*end;
+
+ /*
* Beyond the backslash, at least one input character
* is part of the escape sequence. With one exception
* (see below), that character won't be returned.
@@ -75,6 +83,10 @@ mandoc_escape(const char **end, const char **start, int *sz)
*sz = 2;
break;
case '[':
+ if (**start == ' ') {
+ ++*end;
+ return ESCAPE_ERROR;
+ }
gly = ESCAPE_SPECIAL;
term = ']';
break;
@@ -89,11 +101,26 @@ mandoc_escape(const char **end, const char **start, int *sz)
/*
* Escapes taking no arguments at all.
*/
- case 'd':
- case 'u':
+ case '!':
+ case '?':
+ return ESCAPE_UNSUPP;
+ case '%':
+ case '&':
+ case ')':
case ',':
case '/':
+ case '^':
+ case 'a':
+ case 'd':
+ case 'r':
+ case 't':
+ case 'u':
+ case '{':
+ case '|':
+ case '}':
return ESCAPE_IGNORE;
+ case 'c':
+ return ESCAPE_NOSPACE;
case 'p':
return ESCAPE_BREAK;
@@ -111,28 +138,46 @@ mandoc_escape(const char **end, const char **start, int *sz)
* 'X' is the trigger. These have opaque sub-strings.
*/
case 'F':
+ case 'f':
case 'g':
case 'k':
case 'M':
case 'm':
case 'n':
+ case 'O':
case 'V':
case 'Y':
- gly = ESCAPE_IGNORE;
- /* FALLTHROUGH */
- case 'f':
- if (ESCAPE_ERROR == gly)
- gly = ESCAPE_FONT;
+ gly = (*start)[-1] == 'f' ? ESCAPE_FONT : ESCAPE_IGNORE;
switch (**start) {
case '(':
+ if ((*start)[-1] == 'O')
+ gly = ESCAPE_ERROR;
*start = ++*end;
*sz = 2;
break;
case '[':
+ if ((*start)[-1] == 'O')
+ gly = (*start)[1] == '5' ?
+ ESCAPE_UNSUPP : ESCAPE_ERROR;
*start = ++*end;
term = ']';
break;
default:
+ if ((*start)[-1] == 'O') {
+ switch (**start) {
+ case '0':
+ gly = ESCAPE_UNSUPP;
+ break;
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ break;
+ default:
+ gly = ESCAPE_ERROR;
+ break;
+ }
+ }
*sz = 1;
break;
}
@@ -255,18 +300,29 @@ mandoc_escape(const char **end, const char **start, int *sz)
break;
/*
- * Anything else is assumed to be a glyph.
- * In this case, pass back the character after the backslash.
+ * Several special characters can be encoded as
+ * one-byte escape sequences without using \[].
*/
- default:
+ case ' ':
+ case '\'':
+ case '-':
+ case '.':
+ case '0':
+ case ':':
+ case '_':
+ case '`':
+ case 'e':
+ case '~':
gly = ESCAPE_SPECIAL;
+ /* FALLTHROUGH */
+ default:
+ if (gly == ESCAPE_ERROR)
+ gly = ESCAPE_UNDEF;
*start = --*end;
*sz = 1;
break;
}
- assert(ESCAPE_ERROR != gly);
-
/*
* Read up to the terminating character,
* paying attention to nested escapes.
@@ -289,6 +345,15 @@ mandoc_escape(const char **end, const char **start, int *sz)
}
}
*sz = (*end)++ - *start;
+
+ /*
+ * The file chars.c only provides one common list
+ * of character names, but \[-] == \- is the only
+ * one of the characters with one-byte names that
+ * allows enclosing the name in brackets.
+ */
+ if (gly == ESCAPE_SPECIAL && *sz == 1 && **start != '-')
+ return ESCAPE_ERROR;
} else {
assert(*sz > 0);
if ((size_t)*sz > strlen(*start))
@@ -344,10 +409,6 @@ mandoc_escape(const char **end, const char **start, int *sz)
break;
case ESCAPE_SPECIAL:
if (**start == 'c') {
- if (*sz == 1) {
- gly = ESCAPE_NOSPACE;
- break;
- }
if (*sz < 6 || *sz > 7 ||
strncmp(*start, "char", 4) != 0 ||
(int)strspn(*start + 4, "0123456789") + 4 < *sz)
@@ -429,6 +490,7 @@ mandoc_getarg(char **cpp, int ln, int *pos)
* backslashes and backslash-t to literal tabs.
*/
switch (cp[1]) {
+ case 'a':
case 't':
cp[0] = '\t';
/* FALLTHROUGH */
diff --git a/usr.bin/mandoc/mandoc.h b/usr.bin/mandoc/mandoc.h
index 00b10f91c66..2e4a9dc0317 100644
--- a/usr.bin/mandoc/mandoc.h
+++ b/usr.bin/mandoc/mandoc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mandoc.h,v 1.202 2018/12/14 05:17:45 schwarze Exp $ */
+/* $OpenBSD: mandoc.h,v 1.203 2018/12/15 19:30:19 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2012-2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -169,6 +169,7 @@ enum mandocerr {
MANDOCERR_FI_TAB, /* tab in filled text */
MANDOCERR_EOS, /* new sentence, new line */
MANDOCERR_ESC_BAD, /* invalid escape sequence: esc */
+ MANDOCERR_ESC_UNDEF, /* undefined escape, printing literally: char */
MANDOCERR_STR_UNDEF, /* undefined string, using "": name */
/* related to tables */
@@ -231,6 +232,7 @@ enum mandocerr {
MANDOCERR_TOOLARGE, /* input too large */
MANDOCERR_CHAR_UNSUPP, /* unsupported control character: number */
+ MANDOCERR_ESC_UNSUPP, /* unsupported escape sequence: escape */
MANDOCERR_REQ_UNSUPP, /* unsupported roff request: request */
MANDOCERR_WHILE_NEST, /* nested .while loops */
MANDOCERR_WHILE_OUTOF, /* end of scope with open .while loop */
@@ -245,7 +247,9 @@ enum mandocerr {
enum mandoc_esc {
ESCAPE_ERROR = 0, /* bail! unparsable escape */
+ ESCAPE_UNSUPP, /* unsupported escape; ignore it */
ESCAPE_IGNORE, /* escape to be ignored */
+ ESCAPE_UNDEF, /* undefined escape; print literal character */
ESCAPE_SPECIAL, /* a regular special character */
ESCAPE_FONT, /* a generic font mode */
ESCAPE_FONTBOLD, /* bold font mode */
diff --git a/usr.bin/mandoc/mandoc_msg.c b/usr.bin/mandoc/mandoc_msg.c
index 03fe7bd3315..a21964be228 100644
--- a/usr.bin/mandoc/mandoc_msg.c
+++ b/usr.bin/mandoc/mandoc_msg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mandoc_msg.c,v 1.2 2018/12/14 05:17:45 schwarze Exp $ */
+/* $OpenBSD: mandoc_msg.c,v 1.3 2018/12/15 19:30:19 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014,2015,2016,2017,2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -167,6 +167,7 @@ static const char *const type_message[MANDOCERR_MAX] = {
"tab in filled text",
"new sentence, new line",
"invalid escape sequence",
+ "undefined escape, printing literally",
"undefined string, using \"\"",
/* related to tables */
@@ -228,6 +229,7 @@ static const char *const type_message[MANDOCERR_MAX] = {
"unsupported feature",
"input too large",
"unsupported control character",
+ "unsupported escape sequence",
"unsupported roff request",
"nested .while loops",
"end of scope with open .while loop",
diff --git a/usr.bin/mandoc/mdoc_man.c b/usr.bin/mandoc/mdoc_man.c
index 0edf3c7e121..17446b70f2a 100644
--- a/usr.bin/mandoc/mdoc_man.c
+++ b/usr.bin/mandoc/mdoc_man.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_man.c,v 1.127 2018/12/03 21:00:06 schwarze Exp $ */
+/* $OpenBSD: mdoc_man.c,v 1.128 2018/12/15 19:30:19 schwarze Exp $ */
/*
* Copyright (c) 2011-2018 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -323,6 +323,7 @@ man_strlen(const char *cp)
case ESCAPE_UNICODE:
case ESCAPE_NUMBERED:
case ESCAPE_SPECIAL:
+ case ESCAPE_UNDEF:
case ESCAPE_OVERSTRIKE:
if (skip)
skip = 0;
diff --git a/usr.bin/mandoc/mdoc_markdown.c b/usr.bin/mandoc/mdoc_markdown.c
index 76f0f0a2559..ffb28bd704a 100644
--- a/usr.bin/mandoc/mdoc_markdown.c
+++ b/usr.bin/mandoc/mdoc_markdown.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_markdown.c,v 1.28 2018/12/03 21:00:06 schwarze Exp $ */
+/* $OpenBSD: mdoc_markdown.c,v 1.29 2018/12/15 19:30:19 schwarze Exp $ */
/*
* Copyright (c) 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -589,6 +589,9 @@ md_word(const char *s)
case ESCAPE_SPECIAL:
uc = mchars_spec2cp(seq, sz);
break;
+ case ESCAPE_UNDEF:
+ uc = *seq;
+ break;
case ESCAPE_DEVICE:
md_rawword("markdown");
continue;
diff --git a/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c
index 439ef112e16..6e5924d5925 100644
--- a/usr.bin/mandoc/roff.c
+++ b/usr.bin/mandoc/roff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: roff.c,v 1.223 2018/12/14 06:33:03 schwarze Exp $ */
+/* $OpenBSD: roff.c,v 1.224 2018/12/15 19:30:19 schwarze Exp $ */
/*
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -1152,6 +1152,7 @@ roff_res(struct roff *r, struct buf *buf, int ln, int pos)
struct roff_node *n; /* used for header comments */
const char *start; /* start of the string to process */
char *stesc; /* start of an escape sequence ('\\') */
+ const char *esct; /* type of esccape sequence */
char *ep; /* end of comment string */
const char *stnam; /* start of the name, after "[(*" */
const char *cp; /* end of the name, e.g. before ']' */
@@ -1161,7 +1162,6 @@ roff_res(struct roff *r, struct buf *buf, int ln, int pos)
size_t naml; /* actual length of the escape name */
size_t asz; /* length of the replacement */
size_t rsz; /* length of the rest of the string */
- enum mandoc_esc esc; /* type of the escape sequence */
int inaml; /* length returned from mandoc_escape() */
int expand_count; /* to avoid infinite loops */
int npos; /* position in numeric expression */
@@ -1170,6 +1170,7 @@ roff_res(struct roff *r, struct buf *buf, int ln, int pos)
int done; /* no more input available */
int deftype; /* type of definition to paste */
int rcsid; /* kind of RCS id seen */
+ enum mandocerr err; /* for escape sequence problems */
char sign; /* increment number register */
char term; /* character terminating the escape */
@@ -1302,7 +1303,10 @@ roff_res(struct roff *r, struct buf *buf, int ln, int pos)
term = '\0';
cp = stesc + 1;
- switch (*cp) {
+ if (*cp == 'E')
+ cp++;
+ esct = cp;
+ switch (*esct) {
case '*':
case '$':
res = NULL;
@@ -1318,12 +1322,26 @@ roff_res(struct roff *r, struct buf *buf, int ln, int pos)
res = ubuf;
break;
default:
- esc = mandoc_escape(&cp, &stnam, &inaml);
- if (esc == ESCAPE_ERROR ||
- (esc == ESCAPE_SPECIAL &&
- mchars_spec2cp(stnam, inaml) < 0))
- mandoc_msg(MANDOCERR_ESC_BAD,
- ln, (int)(stesc - buf->buf),
+ err = MANDOCERR_OK;
+ switch(mandoc_escape(&cp, &stnam, &inaml)) {
+ case ESCAPE_SPECIAL:
+ if (mchars_spec2cp(stnam, inaml) >= 0)
+ break;
+ /* FALLTHROUGH */
+ case ESCAPE_ERROR:
+ err = MANDOCERR_ESC_BAD;
+ break;
+ case ESCAPE_UNDEF:
+ err = MANDOCERR_ESC_UNDEF;
+ break;
+ case ESCAPE_UNSUPP:
+ err = MANDOCERR_ESC_UNSUPP;
+ break;
+ default:
+ break;
+ }
+ if (err != MANDOCERR_OK)
+ mandoc_msg(err, ln, (int)(stesc - buf->buf),
"%.*s", (int)(cp - stesc), stesc);
stesc--;
continue;
@@ -1380,7 +1398,7 @@ roff_res(struct roff *r, struct buf *buf, int ln, int pos)
cp++;
break;
}
- if (*cp++ != '\\' || stesc[1] != 'w') {
+ if (*cp++ != '\\' || *esct != 'w') {
naml++;
continue;
}
@@ -1388,6 +1406,7 @@ roff_res(struct roff *r, struct buf *buf, int ln, int pos)
case ESCAPE_SPECIAL:
case ESCAPE_UNICODE:
case ESCAPE_NUMBERED:
+ case ESCAPE_UNDEF:
case ESCAPE_OVERSTRIKE:
naml++;
break;
@@ -1401,7 +1420,7 @@ roff_res(struct roff *r, struct buf *buf, int ln, int pos)
* undefined, resume searching for escapes.
*/
- switch (stesc[1]) {
+ switch (*esct) {
case '*':
if (arg_complete) {
deftype = ROFFDEF_USER | ROFFDEF_PRE;
@@ -1428,15 +1447,15 @@ roff_res(struct roff *r, struct buf *buf, int ln, int pos)
break;
}
ctx = r->mstack + r->mstackpos;
- npos = stesc[2] - '1';
+ npos = esct[1] - '1';
if (npos >= 0 && npos <= 8) {
res = npos < ctx->argc ?
ctx->argv[npos] : "";
break;
}
- if (stesc[2] == '*')
+ if (esct[1] == '*')
quote_args = 0;
- else if (stesc[2] == '@')
+ else if (esct[1] == '@')
quote_args = 1;
else {
mandoc_msg(MANDOCERR_ARG_NONUM, ln,
@@ -1498,7 +1517,7 @@ roff_res(struct roff *r, struct buf *buf, int ln, int pos)
}
if (res == NULL) {
- if (stesc[1] == '*')
+ if (*esct == '*')
mandoc_msg(MANDOCERR_STR_UNDEF,
ln, (int)(stesc - buf->buf),
"%.*s", (int)naml, stnam);
diff --git a/usr.bin/mandoc/term.c b/usr.bin/mandoc/term.c
index e21c2622927..7b5816be28a 100644
--- a/usr.bin/mandoc/term.c
+++ b/usr.bin/mandoc/term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: term.c,v 1.136 2018/10/25 01:21:30 schwarze Exp $ */
+/* $OpenBSD: term.c,v 1.137 2018/12/15 19:30:19 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -475,9 +475,6 @@ term_word(struct termp *p, const char *word)
word++;
esc = mandoc_escape(&word, &seq, &sz);
- if (ESCAPE_ERROR == esc)
- continue;
-
switch (esc) {
case ESCAPE_UNICODE:
uc = mchars_num2uc(seq + 1, sz - 1);
@@ -498,6 +495,9 @@ term_word(struct termp *p, const char *word)
encode1(p, uc);
}
continue;
+ case ESCAPE_UNDEF:
+ uc = *seq;
+ break;
case ESCAPE_FONTBOLD:
term_fontrepl(p, TERMFONT_BOLD);
continue;
@@ -585,6 +585,9 @@ term_word(struct termp *p, const char *word)
case ESCAPE_SPECIAL:
uc = mchars_spec2cp(cp, sz);
break;
+ case ESCAPE_UNDEF:
+ uc = *seq;
+ break;
default:
uc = -1;
break;
@@ -843,12 +846,8 @@ term_strlen(const struct termp *p, const char *cp)
switch (*cp) {
case '\\':
cp++;
- esc = mandoc_escape(&cp, &seq, &ssz);
- if (ESCAPE_ERROR == esc)
- continue;
-
rhs = NULL;
-
+ esc = mandoc_escape(&cp, &seq, &ssz);
switch (esc) {
case ESCAPE_UNICODE:
uc = mchars_num2uc(seq + 1, ssz - 1);
@@ -869,6 +868,9 @@ term_strlen(const struct termp *p, const char *cp)
sz += cond_width(p, uc, &skip);
}
continue;
+ case ESCAPE_UNDEF:
+ uc = *seq;
+ break;
case ESCAPE_DEVICE:
if (p->type == TERMTYPE_PDF) {
rhs = "pdf";