+pset(const char *buf, int pos, struct curparse *curp,
+ struct man **man, struct mdoc **mdoc)
+{
+ int i;
+
+ /*
+ * Try to intuit which kind of manual parser should be used. If
+ * passed in by command-line (-man, -mdoc), then use that
+ * explicitly. If passed as -mandoc, then try to guess from the
+ * line: either skip dot-lines, use -mdoc when finding `.Dt', or
+ * default to -man, which is more lenient.
+ */
+
+ if (buf[0] == '.') {
+ for (i = 1; buf[i]; i++)
+ if (' ' != buf[i] && '\t' != buf[i])
+ break;
+ if (0 == buf[i])
+ return(1);
+ }
+
+ switch (curp->inttype) {
+ case (INTT_MDOC):
+ if (NULL == curp->mdoc)
+ curp->mdoc = mdoc_init(curp);
+ if (NULL == (*mdoc = curp->mdoc))
+ return(0);
+ curp->lastmdoc = *mdoc;
+ return(1);
+ case (INTT_MAN):
+ if (NULL == curp->man)
+ curp->man = man_init(curp);
+ if (NULL == (*man = curp->man))
+ return(0);
+ curp->lastman = *man;
+ return(1);
+ default:
+ break;
+ }
+
+ if (pos >= 3 && 0 == memcmp(buf, ".Dd", 3)) {
+ if (NULL == curp->mdoc)
+ curp->mdoc = mdoc_init(curp);
+ if (NULL == (*mdoc = curp->mdoc))
+ return(0);
+ curp->lastmdoc = *mdoc;
+ return(1);
+ }
+
+ if (NULL == curp->man)
+ curp->man = man_init(curp);
+ if (NULL == (*man = curp->man))
+ return(0);
+ curp->lastman = *man;
+ return(1);
+}
+
+
+static int
+moptions(enum intt *tflags, char *arg)
+{
+
+ if (0 == strcmp(arg, "doc"))
+ *tflags = INTT_MDOC;
+ else if (0 == strcmp(arg, "andoc"))
+ *tflags = INTT_AUTO;
+ else if (0 == strcmp(arg, "an"))
+ *tflags = INTT_MAN;
+ else {
+ fprintf(stderr, "%s: Bad argument\n", arg);
+ return(0);
+ }
+
+ return(1);
+}
+
+
+static int
+toptions(struct curparse *curp, char *arg)