+
+ if (state == &internal_state || s == NULL) {
+ int ret = charset_from_unicode(NULL, 0, p+plen, psize-plen,
+ charset, state, NULL);
+ if (ret > 0)
+ plen += ret;
+ }
+
+ for (q = p; q < p+plen; q++) {
+ if (q == p && (*q == '.' || *q == '\'') &&
+ (quote_props & QUOTE_INITCTRL)) {
+ /*
+ * Control character (. or ') at the start of a
+ * line. Quote it by putting \& (troff zero-width
+ * space) before it.
+ */
+ rdaddc(&out, '\\');
+ rdaddc(&out, '&');
+ } else if (*q == '\\') {
+ /*
+ * Quote backslashes by doubling them, always.
+ */
+ rdaddc(&out, '\\');
+ } else if (*q == '"' && (quote_props & QUOTE_QUOTES)) {
+ /*
+ * Double quote within double quotes. Quote it by
+ * doubling.
+ */
+ rdaddc(&out, '"');
+ }
+ rdaddc(&out, *q);