-.\" $OpenBSD: roff.7,v 1.81 2018/08/19 17:43:39 schwarze Exp $
+.\" $OpenBSD: roff.7,v 1.82 2018/08/21 18:15:17 schwarze Exp $
.\"
.\" Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
.\" Copyright (c) 2010-2018 Ingo Schwarze <schwarze@openbsd.org>
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: August 19 2018 $
+.Dd $Mdocdate: August 21 2018 $
.Dt ROFF 7
.Os
.Sh NAME
in the input stream, and thus in the output: \fI\^XtFree\^\fP.
Each occurrence of \e\e$* is replaced with all the arguments,
joined together with single space characters.
+The variant \e\e$@ is similar, except that each argument is
+individually quoted.
.Pp
Since macros and user-defined strings share a common string table,
defining a macro
input line on the next physical input line, joining the text on
both lines together as if it were on a single input line.
This is a groff extension.
+.Ss \e$ Ns Ar arg
+Macro argument expansion, see
+.Sx de .
.Ss \e%
Hyphenation allowed at this point of the word; ignored by
.Xr mandoc 1 .
-/* $OpenBSD: roff.c,v 1.209 2018/08/20 17:31:44 schwarze Exp $ */
+/* $OpenBSD: roff.c,v 1.210 2018/08/21 18:15:16 schwarze Exp $ */
/*
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
if (oldsz == 0)
return ROFF_IGN;
- valsz = mandoc_asprintf(&value, ".%.*s \\$*\\\"\n",
+ valsz = mandoc_asprintf(&value, ".%.*s \\$@\\\"\n",
(int)oldsz, oldn);
roff_setstrn(&r->strtab, newn, newsz, value, valsz, 0);
roff_setstrn(&r->rentab, newn, newsz, NULL, 0, 0);
{
const char *arg[16], *ap;
char *cp, *n1, *n2;
- int argc, expand_count, i, ib, ie;
+ int argc, expand_count, i, ib, ie, quote_args;
size_t asz, esz, rsz;
/*
continue;
if (*cp++ != '$')
continue;
- if (*cp == '*') { /* \\$* inserts all arguments */
+
+ quote_args = 0;
+ switch (*cp) {
+ case '@': /* \\$@ inserts all arguments, quoted */
+ quote_args = 1;
+ /* FALLTHROUGH */
+ case '*': /* \\$* inserts all arguments, unquoted */
ib = 0;
ie = argc - 1;
- } else { /* \\$1 .. \\$9 insert one argument */
+ break;
+ default: /* \\$1 .. \\$9 insert one argument */
ib = ie = *cp - '1';
if (ib < 0 || ib > 8)
continue;
+ break;
}
cp -= 2;
asz = ie > ib ? ie - ib : 0; /* for blanks */
for (i = ib; i <= ie; i++) {
+ if (quote_args)
+ asz += 2;
for (ap = arg[i]; *ap != '\0'; ap++) {
asz++;
if (*ap == '"')
n2 = cp;
for (i = ib; i <= ie; i++) {
+ if (quote_args)
+ *n2++ = '"';
for (ap = arg[i]; *ap != '\0'; ap++) {
if (*ap == '"') {
memcpy(n2, "\\(dq", 4);
} else
*n2++ = *ap;
}
+ if (quote_args)
+ *n2++ = '"';
if (i < ie)
*n2++ = ' ';
}