- default:
- *bp++ = *--cp;
- *bp = '\0';
- buflen--;
- continue;
- }
- len = strlen (bp);
- bp += len;
- buflen -= len;
-
- /* Did we actually insert something? */
- if (bp != pp) {
- /* Insert single quote if not inside quotes already */
- if (!quoted && buflen) {
- len = strlen (pp);
- memmove (pp + 1, pp, len);
- *pp++ = '\'';
- buflen--;
- bp++;
- }
- /* Escape existing quotes */
- while ((pp = strchr (pp, '\'')) && buflen > 3) {
- len = strlen (pp++);
- memmove (pp + 3, pp, len);
- *pp++ = '\\';
- *pp++ = '\'';
- *pp++ = '\'';
- buflen -= 3;
- bp += 3;
- }
- /* If pp is still set, that means we ran out of space. */
- if (pp)
- buflen = 0;
- if (!quoted && buflen) {
- *bp++ = '\'';
- *bp = '\0';
- buflen--;
- }
- }
- } else {
+ case 'd':
+ /* insert content description */
+ if (ct->c_descr) {
+ char *s;
+
+ s = trimcpy(ct->c_descr);
+ strncpy(bp, s, buflen);
+ free(s);
+ }
+ break;
+
+ case 'e':
+ /* exclusive execution */
+ xtty = 1;
+ break;
+
+ case 'F':
+ /* %e, %f, and stdin is terminal not content */
+ xstdin = 1;
+ xtty = 1;
+ /* and fall... */
+
+ case 'f':
+ /* insert filename containing content */
+ snprintf(bp, buflen, "'%s'", file);
+ /*
+ ** since we've quoted the file argument,
+ ** set things up to look past it, to avoid
+ ** problems with the quoting logic below.
+ ** (I know, I should figure out what's
+ ** broken with the quoting logic, but..)
+ */
+ len = strlen(bp);
+ buflen -= len;
+ bp += len;
+ pp = bp;
+ break;
+
+ case 'p':
+ /* %l, and pause prior to displaying content */
+ xpause = pausesw;
+ /* and fall... */
+
+ case 'l':
+ /*
+ ** display listing prior to displaying content
+ */
+ xlist = !nolist;
+ break;
+
+ case 's':
+ /* insert subtype of content */
+ strncpy(bp, ci->ci_subtype, buflen);
+ break;
+
+ case '%':
+ /* insert character % */
+ goto raw;
+
+ default:
+ *bp++ = *--cp;
+ *bp = '\0';
+ buflen--;
+ continue;
+ }
+ len = strlen(bp);
+ bp += len;
+ buflen -= len;
+
+ /* Did we actually insert something? */
+ if (bp != pp) {
+ /*
+ ** Insert single quote if not inside quotes
+ ** already
+ */
+ if (!quoted && buflen) {
+ len = strlen(pp);
+ memmove(pp + 1, pp, len);
+ *pp++ = '\'';
+ buflen--;
+ bp++;
+ }
+ /* Escape existing quotes */
+ while ((pp = strchr(pp, '\'')) && buflen > 3) {
+ len = strlen(pp++);
+ memmove(pp + 3, pp, len);
+ *pp++ = '\\';
+ *pp++ = '\'';
+ *pp++ = '\'';
+ buflen -= 3;
+ bp += 3;
+ }
+ /*
+ ** If pp is still set, that means we ran
+ ** out of space.
+ */
+ if (pp)
+ buflen = 0;
+ if (!quoted && buflen) {
+ *bp++ = '\'';
+ *bp = '\0';
+ buflen--;
+ }
+ }
+ } else {