=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mandoc/mdoc_validate.c,v retrieving revision 1.183 retrieving revision 1.184 diff -c -r1.183 -r1.184 *** src/usr.bin/mandoc/mdoc_validate.c 2015/02/04 16:38:31 1.183 --- src/usr.bin/mandoc/mdoc_validate.c 2015/02/04 18:03:28 1.184 *************** *** 1,4 **** ! /* $OpenBSD: mdoc_validate.c,v 1.183 2015/02/04 16:38:31 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010-2015 Ingo Schwarze --- 1,4 ---- ! /* $OpenBSD: mdoc_validate.c,v 1.184 2015/02/04 18:03:28 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010-2015 Ingo Schwarze *************** *** 1649,1668 **** static void post_rs(POST_ARGS) { ! struct mdoc_node *nn, *next, *prev; int i, j; ! switch (mdoc->last->type) { ! case MDOC_HEAD: ! check_count(mdoc, MDOC_HEAD, CHECK_EQ, 0); return; ! case MDOC_BODY: ! if (mdoc->last->child) ! break; ! check_count(mdoc, MDOC_BODY, CHECK_GT, 0); return; - default: - return; } /* --- 1649,1666 ---- static void post_rs(POST_ARGS) { ! struct mdoc_node *np, *nch, *next, *prev; int i, j; ! np = mdoc->last; ! ! if (np->type != MDOC_BODY) return; ! ! if (np->child == NULL) { ! mandoc_msg(MANDOCERR_RS_EMPTY, mdoc->parse, ! np->line, np->pos, "Rs"); return; } /* *************** *** 1672,1709 **** */ next = NULL; ! for (nn = mdoc->last->child->next; nn; nn = next) { ! /* Determine order of `nn'. */ for (i = 0; i < RSORD_MAX; i++) ! if (rsord[i] == nn->tok) break; if (i == RSORD_MAX) { mandoc_msg(MANDOCERR_RS_BAD, ! mdoc->parse, nn->line, nn->pos, ! mdoc_macronames[nn->tok]); i = -1; ! } else if (MDOC__J == nn->tok || MDOC__B == nn->tok) ! mdoc->last->norm->Rs.quote_T++; /* ! * Remove `nn' from the chain. This somewhat * repeats mdoc_node_unlink(), but since we're * just re-ordering, there's no need for the * full unlink process. */ ! if (NULL != (next = nn->next)) ! next->prev = nn->prev; ! if (NULL != (prev = nn->prev)) ! prev->next = nn->next; ! nn->prev = nn->next = NULL; /* * Scan back until we reach a node that's ! * ordered before `nn'. */ for ( ; prev ; prev = prev->prev) { --- 1670,1707 ---- */ next = NULL; ! for (nch = np->child->next; nch != NULL; nch = next) { ! /* Determine order number of this child. */ for (i = 0; i < RSORD_MAX; i++) ! if (rsord[i] == nch->tok) break; if (i == RSORD_MAX) { mandoc_msg(MANDOCERR_RS_BAD, ! mdoc->parse, nch->line, nch->pos, ! mdoc_macronames[nch->tok]); i = -1; ! } else if (nch->tok == MDOC__J || nch->tok == MDOC__B) ! np->norm->Rs.quote_T++; /* ! * Remove this child from the chain. This somewhat * repeats mdoc_node_unlink(), but since we're * just re-ordering, there's no need for the * full unlink process. */ ! if ((next = nch->next) != NULL) ! next->prev = nch->prev; ! if ((prev = nch->prev) != NULL) ! prev->next = nch->next; ! nch->prev = nch->next = NULL; /* * Scan back until we reach a node that's ! * to be ordered before this child. */ for ( ; prev ; prev = prev->prev) { *************** *** 1719,1739 **** } /* ! * Set `nn' back into its correct place in front ! * of the `prev' node. */ ! nn->prev = prev; ! if (prev) { ! if (prev->next) ! prev->next->prev = nn; ! nn->next = prev->next; ! prev->next = nn; } else { ! mdoc->last->child->prev = nn; ! nn->next = mdoc->last->child; ! mdoc->last->child = nn; } } } --- 1717,1737 ---- } /* ! * Set this child back into its correct place ! * in front of the `prev' node. */ ! nch->prev = prev; ! if (prev == NULL) { ! np->child->prev = nch; ! nch->next = np->child; ! np->child = nch; } else { ! if (prev->next) ! prev->next->prev = nch; ! nch->next = prev->next; ! prev->next = nch; } } }