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

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

Revision 1.5, Fri Jun 3 12:15:57 2022 UTC (2 years ago) by schwarze
Branch: MAIN
CVS Tags: HEAD
Changes since 1.4: +27 -2 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: 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
.ie d mystr OOPS
.el mystr not yet defined
.br
.ds mystr mystrval
.ie d mystr now defined
.el OOPS
.if !d mystr OOPS
.PP
.ie d mymac OOPS
.el mymac not yet defined
.br
.de mymac
mymacval
..
.ie dmymac now defined
.el OOPS
.if !d  mymac OOPS
.PP
.ie d myren OOPS
.el myren not yet defined
.br
.rn SM myren
.ie d myren now defined
.el OOPS
.if !d myren OOPS
.PP
standard macro is
.ie d PP defined
.el not defined \(em OOPS
.PP
identifier and tab:
.ie d mystr	mystr is defined
.el OOPS
.PP
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!?