- if (asz != 3) {
-
- /*
- * Determine the size of the rest of the
- * unexpanded macro, including the NUL.
- */
-
- rsz = buf->sz - (cp - n1) - 3;
-
- /*
- * When shrinking, move before
- * releasing the storage.
- */
-
- if (asz < 3)
- memmove(cp + asz, cp + 3, rsz);
-
- /*
- * Resize the storage for the macro
- * and readjust the parse pointer.
- */
-
- buf->sz += asz - 3;
- n2 = mandoc_realloc(n1, buf->sz);
- cp = n2 + (cp - n1);
- n1 = n2;
-
- /*
- * When growing, make room
- * for the expanded argument.
- */
-
- if (asz > 3)
- memmove(cp + asz, cp + 3, rsz);
- }
-
- /* Copy the expanded argument, escaping quotes. */
-
- n2 = cp;
- for (i = ib; i <= ie; i++) {
- for (ap = arg[i]; *ap != '\0'; ap++) {
- if (*ap == '"') {
- memcpy(n2, "\\(dq", 4);
- n2 += 4;
- } else
- *n2++ = *ap;
- }
- if (i < ie)
- *n2++ = ' ';
- }
- }
-
- /*
- * Expand the number of arguments, if it is used.
- * This never makes the expanded macro longer.
- */
-
- for (cp = n1; *cp != '\0'; cp++) {
- if (cp[0] != '\\')
- continue;
- if (cp[1] == '\\') {
- cp++;
- continue;
- }
- if (strncmp(cp + 1, "n(.$", 4) == 0)
- esz = 5;
- else if (strncmp(cp + 1, "n[.$]", 5) == 0)
- esz = 6;
- else
- continue;
- asz = snprintf(cp, esz, "%d", argc);
- assert(asz < esz);
- rsz = buf->sz - (cp - n1) - esz;
- memmove(cp + asz, cp + esz, rsz);
- buf->sz -= esz - asz;
- n2 = mandoc_realloc(n1, buf->sz);
- cp = n2 + (cp - n1) + asz;
- n1 = n2;