aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/regress/roff/cond
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2022-06-03 12:15:55 +0000
committerIngo Schwarze <schwarze@openbsd.org>2022-06-03 12:15:55 +0000
commitccdf39d9cb63bb341dbb5c88c9090ac8e05b350c (patch)
tree8205e38fed18628857329eecdbd4fda63c7ae21d /regress/roff/cond
parent3b52bb8d03ff61274832867c905a80a2761859aa (diff)
downloadmandoc-ccdf39d9cb63bb341dbb5c88c9090ac8e05b350c.tar.gz
mandoc-ccdf39d9cb63bb341dbb5c88c9090ac8e05b350c.tar.zst
mandoc-ccdf39d9cb63bb341dbb5c88c9090ac8e05b350c.zip
During identifier parsing, handle undefined escape sequences
in the same way as groff: * \\ is always reduced to \ * \. is always reduced to . * other undefined escape sequences are usually reduced to the escape name, for example \G to G, except during the expansion of expanding escape sequences having the standard argument form (in particular \* and \n), in which case the backslash is preserved literally. Yes, this is confusing indeed. For example, the following have the same meaning: * .ds \. and .ds . which is not the same as .ds \\. * \*[\.] and \*[.] which is not the same as \*[\\.] * .ds \G and .ds G which is not the same as .ds \\G * \*[\G] and \*[\\G] which is not the same as \*[G] <- sic! To feel less dirty, have a leaning toothpick, if you are so inclined. This patch also slightly improves the string shown by the "escaped character not allowed in a name" error message.
Diffstat (limited to 'regress/roff/cond')
-rw-r--r--regress/roff/cond/register.in31
-rw-r--r--regress/roff/cond/register.out_ascii10
-rw-r--r--regress/roff/cond/string.in29
-rw-r--r--regress/roff/cond/string.out_ascii8
4 files changed, 70 insertions, 8 deletions
diff --git a/regress/roff/cond/register.in b/regress/roff/cond/register.in
index 879c573c..7f137c9c 100644
--- a/regress/roff/cond/register.in
+++ b/regress/roff/cond/register.in
@@ -1,5 +1,5 @@
-.\" $OpenBSD: register.in,v 1.3 2019/02/06 20:54:28 schwarze Exp $
-.TH REGISTER 1 "February 6, 2019"
+.\" $OpenBSD: register.in,v 1.4 2022/06/03 11:50:25 schwarze Exp $
+.TH REGISTER 1 "June 3, 2022"
.SH NAME
register \- conditional testing whether a register is defined
.SH DESCRIPTION
@@ -11,10 +11,35 @@ register \- conditional testing whether a register is defined
.el OOPS
.if !rmyreg OOPS
.PP
-identifier + identifier:
+tab after identifier:
.ie rmyreg myreg is defined
.el OOPS
.PP
escape sequence after identifier:
.ie rmyreg\(enmyreg is defined
.el OOPS
+.PP
+backslash in name:
+.nr \\ 0
+.ie r\\ \e is defined
+.el OOPS
+.rr \\
+.if r\\ is still defined!?
+.PP
+dot in name:
+.nr . 0
+.ie r. \&. is defined
+.el OOPS
+.ie r\. \e. is defined
+.el OOPS
+.rr \.
+.if r. is still defined!?
+.PP
+invalid escape in name:
+.nr G 0
+.ie rG G is defined
+.el OOPS
+.ie r\G \eG is defined
+.el OOPS
+.rr \G
+.if rG is still defined!?
diff --git a/regress/roff/cond/register.out_ascii b/regress/roff/cond/register.out_ascii
index 928c6138..673b9f12 100644
--- a/regress/roff/cond/register.out_ascii
+++ b/regress/roff/cond/register.out_ascii
@@ -7,8 +7,14 @@ DDEESSCCRRIIPPTTIIOONN
not yet defined
now defined
- identifier + identifier: myreg is defined
+ tab after identifier: myreg is defined
escape sequence after identifier: -myreg is defined
-OpenBSD February 6, 2019 REGISTER(1)
+ backslash in name: \ is defined
+
+ dot in name: . is defined \. is defined
+
+ invalid escape in name: G is defined \G is defined
+
+OpenBSD June 3, 2022 REGISTER(1)
diff --git a/regress/roff/cond/string.in b/regress/roff/cond/string.in
index 273984be..fedb4d81 100644
--- a/regress/roff/cond/string.in
+++ b/regress/roff/cond/string.in
@@ -1,5 +1,5 @@
-.\" $OpenBSD: string.in,v 1.4 2019/02/06 20:54:28 schwarze Exp $
-.TH STRING 1 "February 6, 2019"
+.\" $OpenBSD: string.in,v 1.5 2022/06/03 11:50:25 schwarze Exp $
+.TH STRING 1 "June 3, 2022"
.SH NAME
string \- conditional testing whether a string is defined
.SH DESCRIPTION
@@ -40,3 +40,28 @@ identifier and tab:
escape sequence after identifier:
.ie d mystr\(enmystr is defined
.el OOPS
+.PP
+backslash in name:
+.ds \\ value
+.ie d \\ \e is defined
+.el OOPS
+.rm \\
+.if d \\ still defined!?
+.PP
+dot in name:
+.ds . value
+.ie d . \&. is defined
+.el OOPS
+.ie d \. \e. is defined
+.el OOPS
+.rm .
+.if d . still defined!?
+.PP
+invalid escape in name:
+.ds G value
+.ie d G G is defined
+.el OOPS
+.ie d \G \eG is defined
+.el OOPS
+.rm \G
+.if d G still defined!?
diff --git a/regress/roff/cond/string.out_ascii b/regress/roff/cond/string.out_ascii
index 2d80a903..c67c0c55 100644
--- a/regress/roff/cond/string.out_ascii
+++ b/regress/roff/cond/string.out_ascii
@@ -19,4 +19,10 @@ DDEESSCCRRIIPPTTIIOONN
escape sequence after identifier: -mystr is defined
-OpenBSD February 6, 2019 STRING(1)
+ backslash in name: \ is defined
+
+ dot in name: . is defined \. is defined
+
+ invalid escape in name: G is defined \G is defined
+
+OpenBSD June 3, 2022 STRING(1)