[BACK]Return to mdoc_validate.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Diff for /mandoc/mdoc_validate.c between version 1.267 and 1.268

version 1.267, 2015/02/04 16:38:56 version 1.268, 2015/02/04 18:03:47
Line 1658  post_st(POST_ARGS)
Line 1658  post_st(POST_ARGS)
 static void  static void
 post_rs(POST_ARGS)  post_rs(POST_ARGS)
 {  {
         struct mdoc_node *nn, *next, *prev;          struct mdoc_node *np, *nch, *next, *prev;
         int               i, j;          int               i, j;
   
         switch (mdoc->last->type) {          np = mdoc->last;
         case MDOC_HEAD:  
                 check_count(mdoc, MDOC_HEAD, CHECK_EQ, 0);          if (np->type != MDOC_BODY)
                 return;                  return;
         case MDOC_BODY:  
                 if (mdoc->last->child)          if (np->child == NULL) {
                         break;                  mandoc_msg(MANDOCERR_RS_EMPTY, mdoc->parse,
                 check_count(mdoc, MDOC_BODY, CHECK_GT, 0);                      np->line, np->pos, "Rs");
                 return;                  return;
         default:  
                 return;  
         }          }
   
         /*          /*
Line 1681  post_rs(POST_ARGS)
Line 1679  post_rs(POST_ARGS)
          */           */
   
         next = NULL;          next = NULL;
         for (nn = mdoc->last->child->next; nn; nn = next) {          for (nch = np->child->next; nch != NULL; nch = next) {
                 /* Determine order of `nn'. */                  /* Determine order number of this child. */
                 for (i = 0; i < RSORD_MAX; i++)                  for (i = 0; i < RSORD_MAX; i++)
                         if (rsord[i] == nn->tok)                          if (rsord[i] == nch->tok)
                                 break;                                  break;
   
                 if (i == RSORD_MAX) {                  if (i == RSORD_MAX) {
                         mandoc_msg(MANDOCERR_RS_BAD,                          mandoc_msg(MANDOCERR_RS_BAD,
                             mdoc->parse, nn->line, nn->pos,                              mdoc->parse, nch->line, nch->pos,
                             mdoc_macronames[nn->tok]);                              mdoc_macronames[nch->tok]);
                         i = -1;                          i = -1;
                 } else if (MDOC__J == nn->tok || MDOC__B == nn->tok)                  } else if (nch->tok == MDOC__J || nch->tok == MDOC__B)
                         mdoc->last->norm->Rs.quote_T++;                          np->norm->Rs.quote_T++;
   
                 /*                  /*
                  * Remove `nn' from the chain.  This somewhat                   * Remove this child from the chain.  This somewhat
                  * repeats mdoc_node_unlink(), but since we're                   * repeats mdoc_node_unlink(), but since we're
                  * just re-ordering, there's no need for the                   * just re-ordering, there's no need for the
                  * full unlink process.                   * full unlink process.
                  */                   */
   
                 if (NULL != (next = nn->next))                  if ((next = nch->next) != NULL)
                         next->prev = nn->prev;                          next->prev = nch->prev;
   
                 if (NULL != (prev = nn->prev))                  if ((prev = nch->prev) != NULL)
                         prev->next = nn->next;                          prev->next = nch->next;
   
                 nn->prev = nn->next = NULL;                  nch->prev = nch->next = NULL;
   
                 /*                  /*
                  * Scan back until we reach a node that's                   * Scan back until we reach a node that's
                  * ordered before `nn'.                   * to be ordered before this child.
                  */                   */
   
                 for ( ; prev ; prev = prev->prev) {                  for ( ; prev ; prev = prev->prev) {
Line 1728  post_rs(POST_ARGS)
Line 1726  post_rs(POST_ARGS)
                 }                  }
   
                 /*                  /*
                  * Set `nn' back into its correct place in front                   * Set this child back into its correct place
                  * of the `prev' node.                   * in front of the `prev' node.
                  */                   */
   
                 nn->prev = prev;                  nch->prev = prev;
   
                 if (prev) {                  if (prev == NULL) {
                         if (prev->next)                          np->child->prev = nch;
                                 prev->next->prev = nn;                          nch->next = np->child;
                         nn->next = prev->next;                          np->child = nch;
                         prev->next = nn;  
                 } else {                  } else {
                         mdoc->last->child->prev = nn;                          if (prev->next)
                         nn->next = mdoc->last->child;                                  prev->next->prev = nch;
                         mdoc->last->child = nn;                          nch->next = prev->next;
                           prev->next = nch;
                 }                  }
         }          }
 }  }

Legend:
Removed from v.1.267  
changed lines
  Added in v.1.268

CVSweb