mandoc: man.in:91:27: STYLE: whitespace at end of input line
mandoc: man.in:104:5: STYLE: unterminated quoted argument
mandoc: man.in:107:9: STYLE: unterminated quoted argument
-mandoc: man.in:131:1: ERROR: escaped character not allowed in a name: IB\(
+mandoc: man.in:131:1: ERROR: escaped character not allowed in a name: IB\(lq
mandoc: mdoc.in:112:11: STYLE: whitespace at end of input line
mandoc: mdoc.in:113:9: STYLE: unterminated quoted argument
mandoc: mdoc.in:113:15: STYLE: whitespace at end of input line
-mandoc: mdoc.in:121:1: ERROR: escaped character not allowed in a name: Fl\(
+mandoc: mdoc.in:121:1: ERROR: escaped character not allowed in a name: Fl\(lq
-.\" $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
.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!?
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)
-.\" $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
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!?
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)
-.\" $OpenBSD: escname.in,v 1.4 2017/07/04 14:53:27 schwarze Exp $
-.Dd $Mdocdate: July 4 2017 $
+.\" $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
val1
..
.Pp
-Values (first, second, first\esecond):
+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
define first = val1
- Values (first, second, first\second): val1 val2 val3
+ define first\.second = val_dot
+
+ define first\Gsecond = val_inval
+
+ Values:
+ first val1
+ second val2
+ first\second val3
+ first.second val_dot
+ first\.second val_dot
+ firstGsecond val_inval
+ first\Gsecond val_inval
Remove all but second: val2
mandoc: escname.in:22:2: ERROR: escaped character not allowed in a name: first\e
-mandoc: escname.in:32:19: ERROR: escaped character not allowed in a name: first\e
-mandoc: escname.in:33:2: ERROR: skipping unknown macro: .first
-mandoc: escname.in:35:2: ERROR: skipping unknown macro: .first\\second
-mandoc: escname.in:38:5: ERROR: skipping excess arguments: .de ... excess arguments
-mandoc: escname.in:41:1: ERROR: escaped character not allowed in a name: witharg\(
-mandoc: escname.in:43:1: ERROR: escaped character not allowed in a name: de\e
-mandoc: escname.in:43:2: WARNING: skipping empty request: de
+mandoc: escname.in:32:10: WARNING: undefined escape, printing literally: \G
+mandoc: escname.in:51:7: WARNING: undefined escape, printing literally: \G
+mandoc: escname.in:55:19: ERROR: escaped character not allowed in a name: first\e
+mandoc: escname.in:56:2: ERROR: skipping unknown macro: .first
+mandoc: escname.in:58:2: ERROR: skipping unknown macro: .first\second
+mandoc: escname.in:61:5: ERROR: skipping excess arguments: .de ... excess arguments
+mandoc: escname.in:64:1: ERROR: escaped character not allowed in a name: witharg\(en
+mandoc: escname.in:66:1: ERROR: escaped character not allowed in a name: de\e
+mandoc: escname.in:66:2: WARNING: skipping empty request: de
-# $OpenBSD: Makefile,v 1.6 2019/02/06 20:54:28 schwarze Exp $
+# $OpenBSD: Makefile,v 1.7 2022/06/03 11:50:25 schwarze Exp $
+#
+# This directory is intended for tests of string *definitions*,
+# in particular testing the behaviour of the .ds and .as macros.
+# Tests of string *expansion* are better placed in the roff/string
+# directory.
REGRESS_TARGETS = append escname nested quoting tab
-.\" $OpenBSD: escname.in,v 1.3 2017/07/04 14:53:27 schwarze Exp $
-.TH NR-ESCNAME 1 "June 29, 2014"
+.\" $OpenBSD: escname.in,v 1.4 2022/06/03 11:50:25 schwarze Exp $
+.TH NR-ESCNAME 1 "June 3, 2022"
.SH NAME
nr-escname \- escape sequences in register names
.SH DESCRIPTION
.nr second 2
.nr first\\second 3
.nr first\esecond 4
-\n[first] \n[second] \n[first\\second]
+.nr first\.second 5
+.nr first\Gsecond 6
+\n[first] \n[second] \n[first\\second] \n[first.second] \n[firstGsecond]
.PP
.rr first\esecond
\n[first] \n[second] \n[first\\second]
nr-escname - escape sequences in register names
D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
- 1 2 3
+ 1 2 3 5 6
0 2 3
incomplete:
-OpenBSD June 29, 2014 NR-ESCNAME(1)
+OpenBSD June 3, 2022 NR-ESCNAME(1)
mandoc: escname.in:9:5: ERROR: escaped character not allowed in a name: first\e
-mandoc: escname.in:12:5: ERROR: escaped character not allowed in a name: first\e
-mandoc: escname.in:18:13: WARNING: invalid escape sequence: \n[second
-mandoc: escname.in:18:12: STYLE: whitespace at end of input line
+mandoc: escname.in:11:10: WARNING: undefined escape, printing literally: \G
+mandoc: escname.in:14:5: ERROR: escaped character not allowed in a name: first\e
+mandoc: escname.in:20:13: WARNING: invalid escape sequence: \n[second
+mandoc: escname.in:20:12: STYLE: whitespace at end of input line
-# $OpenBSD: Makefile,v 1.9 2018/08/16 13:49:40 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
-.\" $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
.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
bse: \*[bse]
.br
bs: \*[bs]
+.br
+dot.: \*[dot.]
+.br
+dot\e.: \*[dot\.]
.\".br
.\"bl\e e: \*[bl\ e]
.br
ble: \*[ble]
.br
bl: \*[bl]
+.br
+inval\e\eG: \*[inval\\G]
+.br
+inval\eG: \*[inval\G]
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
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
-/* $OpenBSD: roff.c,v 1.264 2022/06/02 11:28:16 schwarze Exp $ */
+/* $OpenBSD: roff.c,v 1.265 2022/06/03 11:50:25 schwarze Exp $ */
/*
* Copyright (c) 2010-2015, 2017-2022 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
int iarg; /* index beginning the argument */
int iendarg; /* index right after the argument */
int iend; /* index right after the sequence */
+ int isrc, idst; /* to reduce \\ and \. in names */
int deftype; /* type of definition to paste */
int argi; /* macro argument index */
int quote_args; /* true for \\$@, false for \\$* */
continue;
}
+ /* Reduce \\ and \. in names. */
+
+ if (buf->buf[inam] == '*' || buf->buf[inam] == 'n') {
+ isrc = idst = iarg;
+ while (isrc < iendarg) {
+ if (isrc + 1 < iendarg &&
+ buf->buf[isrc] == '\\' &&
+ (buf->buf[isrc + 1] == '\\' ||
+ buf->buf[isrc + 1] == '.'))
+ isrc++;
+ buf->buf[idst++] = buf->buf[isrc++];
+ }
+ iendarg -= isrc - idst;
+ }
+
/* Handle expansion. */
res = NULL;
roff_getname(struct roff *r, char **cpp, int ln, int pos)
{
char *name, *cp;
- size_t namesz;
+ int namesz, inam, iend;
name = *cpp;
if (*name == '\0')
/* Advance cp to the byte after the end of the name. */
- for (cp = name; 1; cp++) {
- namesz = cp - name;
+ cp = name;
+ namesz = 0;
+ for (;;) {
if (*cp == '\0')
break;
if (*cp == ' ' || *cp == '\t') {
cp++;
break;
}
- if (*cp != '\\')
+ if (*cp != '\\') {
+ if (name + namesz < cp) {
+ name[namesz] = *cp;
+ *cp = ' ';
+ }
+ namesz++;
+ cp++;
continue;
+ }
if (cp[1] == '{' || cp[1] == '}')
break;
- if (*++cp == '\\')
- continue;
- mandoc_msg(MANDOCERR_NAMESC, ln, pos,
- "%.*s", (int)(cp - name + 1), name);
- mandoc_escape((const char **)&cp, NULL, NULL);
- break;
+ if (roff_escape(cp, 0, 0, NULL, &inam,
+ NULL, NULL, &iend) != ESCAPE_UNDEF) {
+ mandoc_msg(MANDOCERR_NAMESC, ln, pos,
+ "%.*s%.*s", namesz, name, iend, cp);
+ cp += iend;
+ break;
+ }
+
+ /*
+ * In an identifier, \\, \., \G and so on
+ * are reduced to \, ., G and so on,
+ * vaguely similar to copy mode.
+ */
+
+ name[namesz++] = cp[inam];
+ while (iend--) {
+ if (cp >= name + namesz)
+ *cp = ' ';
+ cp++;
+ }
}
/* Read past spaces. */