[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.121 and 1.122

version 1.121, 2010/10/11 15:46:19 version 1.122, 2010/11/29 12:22:28
Line 275  const struct valids mdoc_valids[MDOC_MAX] = {
Line 275  const struct valids mdoc_valids[MDOC_MAX] = {
         { NULL, NULL },                         /* Ta */          { NULL, NULL },                         /* Ta */
 };  };
   
   #define RSORD_MAX 14 /* Number of `Rs' blocks. */
   
   static  const enum mdoct rsord[RSORD_MAX] = {
           MDOC__A,
           MDOC__T,
           MDOC__B,
           MDOC__I,
           MDOC__J,
           MDOC__R,
           MDOC__N,
           MDOC__V,
           MDOC__P,
           MDOC__Q,
           MDOC__D,
           MDOC__O,
           MDOC__C,
           MDOC__U
   };
   
   
 int  int
 mdoc_valid_pre(struct mdoc *mdoc, struct mdoc_node *n)  mdoc_valid_pre(struct mdoc *mdoc, struct mdoc_node *n)
 {  {
Line 1340  post_st(POST_ARGS)
Line 1359  post_st(POST_ARGS)
 static int  static int
 post_rs(POST_ARGS)  post_rs(POST_ARGS)
 {  {
         struct mdoc_node        *nn;          struct mdoc_node *nn, *next, *prev;
           int               i, j;
   
         if (MDOC_BODY != mdoc->last->type)          if (MDOC_BODY != mdoc->last->type)
                 return(1);                  return(1);
   
         for (nn = mdoc->last->child; nn; nn = nn->next)          /*
                 switch (nn->tok) {           * Make sure only certain types of nodes are allowed within the
                 case(MDOC__U):           * the `Rs' body.  Delete offending nodes and raise a warning.
                         /* FALLTHROUGH */           * Do this before re-ordering for the sake of clarity.
                 case(MDOC__Q):           */
                         /* FALLTHROUGH */  
                 case(MDOC__C):          next = NULL;
                         /* FALLTHROUGH */          for (nn = mdoc->last->child; nn; nn = next) {
                 case(MDOC__A):                  for (i = 0; i < RSORD_MAX; i++)
                         /* FALLTHROUGH */                          if (nn->tok == rsord[i])
                 case(MDOC__B):                                  break;
                         /* FALLTHROUGH */  
                 case(MDOC__D):                  if (i < RSORD_MAX) {
                         /* FALLTHROUGH */                          next = nn->next;
                 case(MDOC__I):                          continue;
                         /* FALLTHROUGH */  
                 case(MDOC__J):  
                         /* FALLTHROUGH */  
                 case(MDOC__N):  
                         /* FALLTHROUGH */  
                 case(MDOC__O):  
                         /* FALLTHROUGH */  
                 case(MDOC__P):  
                         /* FALLTHROUGH */  
                 case(MDOC__R):  
                         /* FALLTHROUGH */  
                 case(MDOC__T):  
                         /* FALLTHROUGH */  
                 case(MDOC__V):  
                         break;  
                 default:  
                         mdoc_nmsg(mdoc, nn, MANDOCERR_SYNTCHILD);  
                         return(0);  
                 }                  }
   
                   next = nn->next;
                   mdoc_nmsg(mdoc, nn, MANDOCERR_CHILD);
                   mdoc_node_delete(mdoc, nn);
           }
   
           /*
            * The full `Rs' block needs special handling to order the
            * sub-elements according to `rsord'.  Pick through each element
            * and correctly order it.  This is a insertion sort.
            */
   
           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;
   
                   /*
                    * 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) {
                           /* Determine order of `prev'. */
                           for (j = 0; j < RSORD_MAX; j++)
                                   if (rsord[j] == prev->tok)
                                           break;
   
                           if (j <= i)
                                   break;
                   }
   
                   /*
                    * 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;
                   }
           }
   
         return(1);          return(1);
 }  }

Legend:
Removed from v.1.121  
changed lines
  Added in v.1.122

CVSweb