+ for (j = 0; r->last->end[j]; j++, i++)
+ if ((*bufp)[i] != r->last->end[j])
+ break;
+
+ if ('\0' == r->last->end[j] &&
+ ('\0' == (*bufp)[i] ||
+ ' ' == (*bufp)[i] ||
+ '\t' == (*bufp)[i])) {
+ roffnode_pop(r);
+ roffnode_cleanscope(r);
+ wtf = 1;
+ }
+ }
+
+ ppos = pos;
+ if (ROFF_MAX == (t = roff_parse(*bufp, &pos))) {
+ /*
+ * This is some of groff's stranger behaviours. If we
+ * encountered a custom end-scope tag and that tag also
+ * happens to be a "real" macro, then we need to try
+ * interpreting it again as a real macro. If it's not,
+ * then return ignore. Else continue.
+ */
+ if (wtf)
+ return(ROFF_IGN);
+ else if (NULL == r->last)
+ return(ROFF_CONT);
+
+ /* FIXME: this assumes that we ignore!? */
+ return(ROFF_IGN);
+ }
+
+ assert(roffs[t].proc);
+ return((*roffs[t].proc)
+ (r, t, bufp, szp, ln, ppos, pos, offs));
+}
+
+
+int
+roff_endparse(struct roff *r)
+{
+
+ if (NULL == r->last)
+ return(1);
+ return((*r->msg)(MANDOCERR_SCOPEEXIT, r->data, r->last->line,
+ r->last->col, NULL));