[BACK]Return to escname.in CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc / regress / roff / de

File: [cvsweb.bsd.lv] / mandoc / regress / roff / de / escname.in (download)

Revision 1.3, Fri Jun 3 12:15:58 2022 UTC (2 years ago) by schwarze
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +26 -3 lines

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.

.\" $OpenBSD: escname.in,v 1.5 2022/06/03 11:50:25 schwarze Exp $
.Dd $Mdocdate: June 3 2022 $
.Dt DE-ESCNAME 1
.Os
.Sh NAME
.Nm de-escname
.Nd escape sequences in macro names
.Sh DESCRIPTION
initial text
.Pp
define second = val2
.de second
val2
..
.Pp
define first\esecond = val3
.de first\\second end3
val3
.end3
.Pp
define first = val1
.de first\esecond
val1
..
.Pp
define first\e.second = val_dot
.de first\.second
val_dot
..
.Pp
define first\eGsecond = val_inval
.de first\Gsecond
val_inval
..
.Pp
Values:
.Bl -tag -width first_.second -compact
.It first
.first
.It second
.second
.It first\esecond
.first\\second
.It first.second
.first.second
.It first\e.second
.first\.second
.It firstGsecond
.firstGsecond
.It first\eGsecond
.first\Gsecond
.El
.Pp
Remove all but second:
.rm first\\second first\esecond second
.first
.second
.first\\second
.Pp
macro seperated from argument by an escape sequence:
.de witharg end4 excess arguments
.Dq \\$1
.end4 tail argument
.witharg\(enargument
.Pp
.de\e
final text