+ /* Remember the start of our own body. */
+
+ if (n->type == MDOC_BODY && atok == n->tok) {
+ if (n->end == ENDBODY_NOT)
+ body = n;
+ continue;
+ }
+
+ if (n->type != MDOC_BLOCK || n->tok == MDOC_Nm)
+ continue;
+
+ if (n->tok == MDOC_It) {
+ have_it = 1;
+ continue;
+ }
+
+ if (atok == n->tok) {
+ assert(body);
+
+ /*
+ * Found the start of our own block.
+ * When there is no pending sub block,
+ * just proceed to closing out.
+ */
+
+ if (later == NULL ||
+ (tok == MDOC_El && !have_it))
+ break;
+
+ /*
+ * When there is a pending sub block,
+ * postpone closing out the current block
+ * until the rew_sub() closing out the sub-block.
+ */
+
+ make_pending(later, tok, mdoc, line, ppos);
+
+ /*
+ * Mark the place where the formatting - but not
+ * the scope - of the current block ends.
+ */
+
+ mdoc_endbody_alloc(mdoc, line, ppos,
+ atok, body, ENDBODY_SPACE);
+
+ /*
+ * If a block closing macro taking arguments
+ * breaks another block, put the arguments
+ * into the end marker and remeber the
+ * end marker in order to close it out.
+ */
+
+ if (maxargs) {
+ endbody = mdoc->last;
+ mdoc->next = MDOC_NEXT_CHILD;
+ }
+ break;
+ }
+
+ /*
+ * When finding an open sub block, remember the last
+ * open explicit block, or, in case there are only
+ * implicit ones, the first open implicit block.
+ */
+
+ if (later == NULL ||
+ ! (mdoc_macros[later->tok].flags & MDOC_EXPLICIT))
+ later = n;
+ }
+ rew_sub(MDOC_BODY, mdoc, tok, line, ppos);
+
+ if ( ! (mdoc_macros[tok].flags & MDOC_PARSED)) {
+ if (buf[*pos] != '\0')
+ mandoc_vmsg(MANDOCERR_ARG_SKIP,
+ mdoc->parse, line, ppos,
+ "%s %s", mdoc_macronames[tok],
+ buf + *pos);
+ rew_sub(MDOC_BLOCK, mdoc, tok, line, ppos);
+ return;
+ }
+
+ if (maxargs && endbody == NULL) {
+ if (n == NULL) {
+ /*
+ * Stray .Ec without previous .Eo:
+ * Break the output line, ignore any arguments.
+ */
+ mdoc_elem_alloc(mdoc, line, ppos, MDOC_br, NULL);
+ rew_elem(mdoc, MDOC_br);
+ } else
+ mdoc_tail_alloc(mdoc, line, ppos, atok);