summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--regress/usr.bin/mandoc/roff/args/man.in10
-rw-r--r--regress/usr.bin/mandoc/roff/args/man.out_ascii4
-rw-r--r--regress/usr.bin/mandoc/roff/args/man.out_lint1
-rw-r--r--regress/usr.bin/mandoc/roff/args/mdoc.in18
-rw-r--r--regress/usr.bin/mandoc/roff/args/mdoc.out_ascii5
-rw-r--r--regress/usr.bin/mandoc/roff/args/mdoc.out_lint1
-rw-r--r--usr.bin/mandoc/man.c29
-rw-r--r--usr.bin/mandoc/mdoc.c26
8 files changed, 71 insertions, 23 deletions
diff --git a/regress/usr.bin/mandoc/roff/args/man.in b/regress/usr.bin/mandoc/roff/args/man.in
index 190e66d5709..cad7cd0bda9 100644
--- a/regress/usr.bin/mandoc/roff/args/man.in
+++ b/regress/usr.bin/mandoc/roff/args/man.in
@@ -1,4 +1,4 @@
-.TH ARGS-MAN 1 "January 1, 2011"
+.TH ARGS-MAN 1 "November 19, 2014"
.SH NAME
args-man - arguments to man macros
.SH DESCRIPTION
@@ -109,5 +109,13 @@ text
.\"IB one "two
.\"text
.\"br
+tab after macro:
+.IB one two
+text
+.br
+escape sequence after macro:
+.IB\(lqone two
+text
+.br
backslash at eol:
.IB one two\
diff --git a/regress/usr.bin/mandoc/roff/args/man.out_ascii b/regress/usr.bin/mandoc/roff/args/man.out_ascii
index 12f8fad230d..3ad61f96496 100644
--- a/regress/usr.bin/mandoc/roff/args/man.out_ascii
+++ b/regress/usr.bin/mandoc/roff/args/man.out_ascii
@@ -28,8 +28,10 @@ DDEESSCCRRIIPPTTIIOONN
double eol blank: _o_n_e _o_n_ettwwoo ttwwoo text
triple eol blank: _o_n_e _o_n_ettwwoo ttwwoo text
unterminated quotes: _o_n_e _o_n_ettwwoo text
+ tab after macro: _o_n_ettwwoo text
+ escape sequence after macro: _o_n_ettwwoo text
backslash at eol: _o_n_ettwwoo
- January 1, 2011 ARGS-MAN(1)
+ November 19, 2014 ARGS-MAN(1)
diff --git a/regress/usr.bin/mandoc/roff/args/man.out_lint b/regress/usr.bin/mandoc/roff/args/man.out_lint
index 2ae0fd4e199..b82b4164952 100644
--- a/regress/usr.bin/mandoc/roff/args/man.out_lint
+++ b/regress/usr.bin/mandoc/roff/args/man.out_lint
@@ -6,3 +6,4 @@ mandoc: man.in:86:26: WARNING: whitespace at end of input line
mandoc: man.in:90:27: WARNING: whitespace at end of input line
mandoc: man.in:98:5: WARNING: unterminated quoted argument
mandoc: man.in:99:9: WARNING: unterminated quoted argument
+mandoc: man.in:117:1: ERROR: escaped character not allowed in a name: IB\(
diff --git a/regress/usr.bin/mandoc/roff/args/mdoc.in b/regress/usr.bin/mandoc/roff/args/mdoc.in
index 3e8593f2c37..0a134816f54 100644
--- a/regress/usr.bin/mandoc/roff/args/mdoc.in
+++ b/regress/usr.bin/mandoc/roff/args/mdoc.in
@@ -1,4 +1,4 @@
-.Dd December 15, 2013
+.Dd November 19, 2014
.Dt ARGS-MDOC 1
.Os OpenBSD
.Sh NAME
@@ -21,10 +21,10 @@ text
.\"Fl one\\ two
.\"text
.\"br
-.\"escaped backslash before 'e' character:
-.\"Fl one\\e two
-.\"text
-.\"br
+escaped backslash before 'e' character:
+.Fl one\\e two
+text
+.br
double inter-argument space:
.Fl one two
text
@@ -112,5 +112,13 @@ double trailing blank in unterminated quotes:
.Fl one "two
text
.br
+tab after macro:
+.Fl one two
+text
+.br
+escape sequence after macro:
+.Fl\(lqone two
+text
+.br
backslash at eol:
.Fl one two\
diff --git a/regress/usr.bin/mandoc/roff/args/mdoc.out_ascii b/regress/usr.bin/mandoc/roff/args/mdoc.out_ascii
index 52b8a3a5364..94a12518653 100644
--- a/regress/usr.bin/mandoc/roff/args/mdoc.out_ascii
+++ b/regress/usr.bin/mandoc/roff/args/mdoc.out_ascii
@@ -7,6 +7,7 @@ DDEESSCCRRIIPPTTIIOONN
standard unquoted: --oonnee --ttwwoo text
escaped blanks: --oonnee oonnee --ttwwoo ttwwoo text
escaped 'e' character: --oonnee\\oonnee --ttwwoo text
+ escaped backslash before 'e' character: --oonnee\\ --ttwwoo text
double inter-argument space: --oonnee --ttwwoo text
triple inter-argument space: --oonnee --ttwwoo text
single eol blank: --oonnee --ttwwoo text
@@ -26,6 +27,8 @@ DDEESSCCRRIIPPTTIIOONN
unterminated quotes: --oonnee --oonnee --ttwwoo text
single trailing blank in unterminated quotes: --oonnee --oonnee --ttwwoo text
double trailing blank in unterminated quotes: --oonnee --oonnee --ttwwoo text
+ tab after macro: --oonnee --ttwwoo text
+ escape sequence after macro: --oonnee --ttwwoo text
backslash at eol: --oonnee --ttwwoo
-OpenBSD December 15, 2013 OpenBSD
+OpenBSD November 19, 2014 OpenBSD
diff --git a/regress/usr.bin/mandoc/roff/args/mdoc.out_lint b/regress/usr.bin/mandoc/roff/args/mdoc.out_lint
index affe49b4c4f..a622c6c7009 100644
--- a/regress/usr.bin/mandoc/roff/args/mdoc.out_lint
+++ b/regress/usr.bin/mandoc/roff/args/mdoc.out_lint
@@ -10,3 +10,4 @@ mandoc: mdoc.in:106:10: WARNING: unterminated quoted argument
mandoc: mdoc.in:107:14: WARNING: unterminated quoted argument
mandoc: mdoc.in:111:11: WARNING: unterminated quoted argument
mandoc: mdoc.in:112:15: WARNING: unterminated quoted argument
+mandoc: mdoc.in:120:1: ERROR: escaped character not allowed in a name: Fl\(
diff --git a/usr.bin/mandoc/man.c b/usr.bin/mandoc/man.c
index e9ca83f030c..0b0acdc4380 100644
--- a/usr.bin/mandoc/man.c
+++ b/usr.bin/mandoc/man.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: man.c,v 1.90 2014/11/03 23:17:21 schwarze Exp $ */
+/* $OpenBSD: man.c,v 1.91 2014/11/19 03:07:43 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -481,35 +481,50 @@ man_ptext(struct man *man, int line, char *buf, int offs)
static int
man_pmacro(struct man *man, int ln, char *buf, int offs)
{
- char mac[5];
struct man_node *n;
+ const char *cp;
enum mant tok;
int i, ppos;
int bline;
+ char mac[5];
ppos = offs;
/*
* Copy the first word into a nil-terminated buffer.
- * Stop copying when a tab, space, or eoln is encountered.
+ * Stop when a space, tab, escape, or eoln is encountered.
*/
i = 0;
- while (i < 4 && '\0' != buf[offs] && ' ' != buf[offs] &&
- '\t' != buf[offs])
+ while (i < 4 && strchr(" \t\\", buf[offs]) == NULL)
mac[i++] = buf[offs++];
mac[i] = '\0';
tok = (i > 0 && i < 4) ? man_hash_find(mac) : MAN_MAX;
- if (MAN_MAX == tok) {
+ if (tok == MAN_MAX) {
mandoc_msg(MANDOCERR_MACRO, man->parse,
ln, ppos, buf + ppos - 1);
return(1);
}
- /* The macro is sane. Jump to the next word. */
+ /* Skip a leading escape sequence or tab. */
+
+ switch (buf[offs]) {
+ case '\\':
+ cp = buf + offs + 1;
+ mandoc_escape(&cp, NULL, NULL);
+ offs = cp - buf;
+ break;
+ case '\t':
+ offs++;
+ break;
+ default:
+ break;
+ }
+
+ /* Jump to the next non-whitespace word. */
while (buf[offs] && ' ' == buf[offs])
offs++;
diff --git a/usr.bin/mandoc/mdoc.c b/usr.bin/mandoc/mdoc.c
index ee77219710c..826702cd815 100644
--- a/usr.bin/mandoc/mdoc.c
+++ b/usr.bin/mandoc/mdoc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc.c,v 1.117 2014/10/20 15:49:45 schwarze Exp $ */
+/* $OpenBSD: mdoc.c,v 1.118 2014/11/19 03:07:43 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -732,37 +732,47 @@ mdoc_ptext(struct mdoc *mdoc, int line, char *buf, int offs)
static int
mdoc_pmacro(struct mdoc *mdoc, int ln, char *buf, int offs)
{
+ struct mdoc_node *n;
+ const char *cp;
enum mdoct tok;
int i, sv;
char mac[5];
- struct mdoc_node *n;
sv = offs;
/*
* Copy the first word into a nil-terminated buffer.
- * Stop copying when a tab, space, or eoln is encountered.
+ * Stop when a space, tab, escape, or eoln is encountered.
*/
i = 0;
- while (i < 4 && '\0' != buf[offs] && ' ' != buf[offs] &&
- '\t' != buf[offs])
+ while (i < 4 && strchr(" \t\\", buf[offs]) == NULL)
mac[i++] = buf[offs++];
mac[i] = '\0';
tok = (i > 1 && i < 4) ? mdoc_hash_find(mac) : MDOC_MAX;
- if (MDOC_MAX == tok) {
+ if (tok == MDOC_MAX) {
mandoc_msg(MANDOCERR_MACRO, mdoc->parse,
ln, sv, buf + sv - 1);
return(1);
}
- /* Disregard the first trailing tab, if applicable. */
+ /* Skip a leading escape sequence or tab. */
- if ('\t' == buf[offs])
+ switch (buf[offs]) {
+ case '\\':
+ cp = buf + offs + 1;
+ mandoc_escape(&cp, NULL, NULL);
+ offs = cp - buf;
+ break;
+ case '\t':
offs++;
+ break;
+ default:
+ break;
+ }
/* Jump to the next non-whitespace word. */