=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mandoc/roff.c,v retrieving revision 1.209 retrieving revision 1.210 diff -c -r1.209 -r1.210 *** src/usr.bin/mandoc/roff.c 2018/08/20 17:31:44 1.209 --- src/usr.bin/mandoc/roff.c 2018/08/21 18:15:16 1.210 *************** *** 1,4 **** ! /* $OpenBSD: roff.c,v 1.209 2018/08/20 17:31:44 schwarze Exp $ */ /* * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons * Copyright (c) 2010-2015, 2017, 2018 Ingo Schwarze --- 1,4 ---- ! /* $OpenBSD: roff.c,v 1.210 2018/08/21 18:15:16 schwarze Exp $ */ /* * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons * Copyright (c) 2010-2015, 2017, 2018 Ingo Schwarze *************** *** 3154,3160 **** if (oldsz == 0) return ROFF_IGN; ! 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); --- 3154,3160 ---- if (oldsz == 0) return ROFF_IGN; ! 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); *************** *** 3378,3384 **** { const char *arg[16], *ap; char *cp, *n1, *n2; ! int argc, expand_count, i, ib, ie; size_t asz, esz, rsz; /* --- 3378,3384 ---- { const char *arg[16], *ap; char *cp, *n1, *n2; ! int argc, expand_count, i, ib, ie, quote_args; size_t asz, esz, rsz; /* *************** *** 3413,3425 **** continue; if (*cp++ != '$') continue; ! if (*cp == '*') { /* \\$* inserts all arguments */ ib = 0; ie = argc - 1; ! } else { /* \\$1 .. \\$9 insert one argument */ ib = ie = *cp - '1'; if (ib < 0 || ib > 8) continue; } cp -= 2; --- 3413,3433 ---- continue; if (*cp++ != '$') continue; ! ! quote_args = 0; ! switch (*cp) { ! case '@': /* \\$@ inserts all arguments, quoted */ ! quote_args = 1; ! /* FALLTHROUGH */ ! case '*': /* \\$* inserts all arguments, unquoted */ ib = 0; ie = argc - 1; ! break; ! default: /* \\$1 .. \\$9 insert one argument */ ib = ie = *cp - '1'; if (ib < 0 || ib > 8) continue; + break; } cp -= 2; *************** *** 3445,3450 **** --- 3453,3460 ---- 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 == '"') *************** *** 3491,3496 **** --- 3501,3508 ---- 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); *************** *** 3498,3503 **** --- 3510,3517 ---- } else *n2++ = *ap; } + if (quote_args) + *n2++ = '"'; if (i < ie) *n2++ = ' '; }