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/string/Makefile | 7 ++++++- regress/roff/string/name.in | 14 ++++++++++++-- regress/roff/string/name.out_ascii | 6 +++++- regress/roff/string/name.out_lint | 31 ++++++++++++++++--------------- 4 files changed, 39 insertions(+), 19 deletions(-) (limited to 'regress/roff/string') diff --git a/regress/roff/string/Makefile b/regress/roff/string/Makefile index b8885c65..2fa10557 100644 --- a/regress/roff/string/Makefile +++ b/regress/roff/string/Makefile @@ -1,4 +1,9 @@ -# $OpenBSD: Makefile,v 1.6 2014/07/06 19:08:57 schwarze Exp $ +# $OpenBSD: Makefile,v 1.10 2022/06/03 11:50:25 schwarze Exp $ +# +# This directory is intended for tests of string *expansion*, +# in particular testing the behaviour of the \* escape sequence. +# Tests of string *definitions* are better placed in the roff/ds +# directory. REGRESS_TARGETS = dotT escape infinite name std undef zerolength LINT_TARGETS = name std undef diff --git a/regress/roff/string/name.in b/regress/roff/string/name.in index 2948f164..b2612be2 100644 --- a/regress/roff/string/name.in +++ b/regress/roff/string/name.in @@ -1,5 +1,5 @@ -.\" $OpenBSD: name.in,v 1.4 2017/07/04 14:53:27 schwarze Exp $ -.Dd $Mdocdate: July 4 2017 $ +.\" $OpenBSD: name.in,v 1.5 2022/06/03 11:50:25 schwarze Exp $ +.Dd $Mdocdate: June 3 2022 $ .Dt STRING-NAME 1 .Os .Sh NAME @@ -10,7 +10,9 @@ .ds "quot" value of "quot" .ds bs\e value of bs\ee .ds bs\\e value of bs\e\ee +.ds dot. value of dot. .ds bl\ e value of bl\e e +.ds inval\\G value of inval\eG norm: \*[norm] .br norm without closing brace: \*[norm @@ -26,6 +28,10 @@ bs\e\ee: \*[bs\\e] bse: \*[bse] .br bs: \*[bs] +.br +dot.: \*[dot.] +.br +dot\e.: \*[dot\.] .\".br .\"bl\e e: \*[bl\ e] .br @@ -34,3 +40,7 @@ bl e: \*[bl e] ble: \*[ble] .br bl: \*[bl] +.br +inval\e\eG: \*[inval\\G] +.br +inval\eG: \*[inval\G] diff --git a/regress/roff/string/name.out_ascii b/regress/roff/string/name.out_ascii index 325e28aa..38258a72 100644 --- a/regress/roff/string/name.out_ascii +++ b/regress/roff/string/name.out_ascii @@ -11,8 +11,12 @@ DDEESSCCRRIIPPTTIIOONN bs\\e: value of bs\\e bse: bs: + dot.: value of dot. + dot\.: value of dot. bl e: ble: bl: + inval\\G: value of inval\G + inval\G: value of inval\G -OpenBSD July 4, 2017 OpenBSD +OpenBSD June 3, 2022 OpenBSD diff --git a/regress/roff/string/name.out_lint b/regress/roff/string/name.out_lint index 5a6340a0..13283f5d 100644 --- a/regress/roff/string/name.out_lint +++ b/regress/roff/string/name.out_lint @@ -1,16 +1,17 @@ mandoc: name.in:11:5: ERROR: escaped character not allowed in a name: bs\e -mandoc: name.in:13:5: ERROR: escaped character not allowed in a name: bl\ -mandoc: name.in:16:29: WARNING: invalid escape sequence: \*[norm -mandoc: name.in:16:28: STYLE: whitespace at end of input line -mandoc: name.in:18:7: WARNING: undefined string, using "": quot -mandoc: name.in:18:6: STYLE: whitespace at end of input line -mandoc: name.in:26:6: WARNING: undefined string, using "": bse -mandoc: name.in:26:5: STYLE: whitespace at end of input line -mandoc: name.in:28:5: WARNING: undefined string, using "": bs -mandoc: name.in:28:4: STYLE: whitespace at end of input line -mandoc: name.in:32:7: WARNING: undefined string, using "": bl e -mandoc: name.in:32:6: STYLE: whitespace at end of input line -mandoc: name.in:34:6: WARNING: undefined string, using "": ble -mandoc: name.in:34:5: STYLE: whitespace at end of input line -mandoc: name.in:36:5: WARNING: undefined string, using "": bl -mandoc: name.in:36:4: STYLE: whitespace at end of input line +mandoc: name.in:14:5: ERROR: escaped character not allowed in a name: bl\ +mandoc: name.in:18:29: WARNING: invalid escape sequence: \*[norm +mandoc: name.in:18:28: STYLE: whitespace at end of input line +mandoc: name.in:20:7: WARNING: undefined string, using "": quot +mandoc: name.in:20:6: STYLE: whitespace at end of input line +mandoc: name.in:28:6: WARNING: undefined string, using "": bse +mandoc: name.in:28:5: STYLE: whitespace at end of input line +mandoc: name.in:30:5: WARNING: undefined string, using "": bs +mandoc: name.in:30:4: STYLE: whitespace at end of input line +mandoc: name.in:38:7: WARNING: undefined string, using "": bl e +mandoc: name.in:38:6: STYLE: whitespace at end of input line +mandoc: name.in:40:6: WARNING: undefined string, using "": ble +mandoc: name.in:40:5: STYLE: whitespace at end of input line +mandoc: name.in:42:5: WARNING: undefined string, using "": bl +mandoc: name.in:42:4: STYLE: whitespace at end of input line +mandoc: name.in:46:19: WARNING: undefined escape, printing literally: \G -- cgit v1.2.3