From ccdf39d9cb63bb341dbb5c88c9090ac8e05b350c Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Fri, 3 Jun 2022 12:15:55 +0000 Subject: 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. --- regress/roff/cond/register.in | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'regress/roff/cond/register.in') 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!? -- cgit v1.2.3-56-ge451