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

Diff for /mandoc/Attic/validate.c between version 1.18 and 1.21

version 1.18, 2009/01/08 14:55:59 version 1.21, 2009/01/09 14:45:44
Line 32  struct valids {
Line 32  struct valids {
 };  };
   
   
 static  int     pre_sh(struct mdoc *, struct mdoc_node *);  static  int     pre_prologue(struct mdoc *, struct mdoc_node *);
   static  int     pre_prologue(struct mdoc *, struct mdoc_node *);
   static  int     pre_prologue(struct mdoc *, struct mdoc_node *);
 static  int     post_headchild_err_ge1(struct mdoc *);  static  int     post_headchild_err_ge1(struct mdoc *);
 static  int     post_headchild_err_le8(struct mdoc *);  static  int     post_elemchild_err_ge1(struct mdoc *);
 static  int     post_bodychild_warn_ge1(struct mdoc *);  static  int     post_bodychild_warn_ge1(struct mdoc *);
   static  int     post_sh(struct mdoc *);
   
 static v_post   posts_sh[] = { post_headchild_err_ge1,  static  v_post  posts_sh[] = { post_headchild_err_ge1,
                         post_bodychild_warn_ge1,                          post_bodychild_warn_ge1, post_sh, NULL };
                         post_headchild_err_le8, NULL };  static  v_post  posts_dd[] = { post_elemchild_err_ge1, NULL };
   
   
 const   struct valids mdoc_valids[MDOC_MAX] = {  const   struct valids mdoc_valids[MDOC_MAX] = {
         { NULL, NULL }, /* \" */          { NULL, NULL }, /* \" */
         { NULL, NULL }, /* Dd */ /* TODO */          { pre_prologue, posts_dd }, /* Dd */
         { NULL, NULL }, /* Dt */ /* TODO */          { pre_prologue, NULL }, /* Dt */
         { NULL, NULL }, /* Os */ /* TODO */          { pre_prologue, NULL }, /* Os */
         { pre_sh, posts_sh }, /* Sh */ /* FIXME: preceding Pp. */          { NULL, posts_sh }, /* Sh */ /* FIXME: preceding Pp. */
         { NULL, NULL }, /* Ss */ /* FIXME: preceding Pp. */          { NULL, NULL }, /* Ss */ /* FIXME: preceding Pp. */
         { NULL, NULL }, /* Pp */          { NULL, NULL }, /* Pp */
         { NULL, NULL }, /* D1 */          { NULL, NULL }, /* D1 */
Line 166  post_bodychild_warn_ge1(struct mdoc *mdoc)
Line 169  post_bodychild_warn_ge1(struct mdoc *mdoc)
   
   
 static int  static int
   post_elemchild_err_ge1(struct mdoc *mdoc)
   {
   
           assert(MDOC_ELEM == mdoc->last->type);
           if (mdoc->last->child)
                   return(1);
           return(mdoc_err(mdoc, ERR_ARGS_GE1));
   }
   
   
   static int
 post_headchild_err_ge1(struct mdoc *mdoc)  post_headchild_err_ge1(struct mdoc *mdoc)
 {  {
   
Line 178  post_headchild_err_ge1(struct mdoc *mdoc)
Line 192  post_headchild_err_ge1(struct mdoc *mdoc)
   
   
 static int  static int
 post_headchild_err_le8(struct mdoc *mdoc)  pre_prologue(struct mdoc *mdoc, struct mdoc_node *node)
 {  {
   
           if (SEC_PROLOGUE != mdoc->sec_lastn)
                   return(mdoc_verr(mdoc, node, ERR_SEC_NPROLOGUE));
           assert(MDOC_ELEM == node->type);
   
           /* Check for ordering. */
   
           switch (node->data.elem.tok) {
           case (MDOC_Os):
                   if (mdoc->meta.title[0] && mdoc->meta.date)
                           break;
                   return(mdoc_verr(mdoc, node, ERR_SEC_PROLOGUE_OO));
           case (MDOC_Dt):
                   if (0 == mdoc->meta.title[0] && mdoc->meta.date)
                           break;
                   return(mdoc_verr(mdoc, node, ERR_SEC_PROLOGUE_OO));
           case (MDOC_Dd):
                   if (0 == mdoc->meta.title[0] && 0 == mdoc->meta.date)
                           break;
                   return(mdoc_verr(mdoc, node, ERR_SEC_PROLOGUE_OO));
           default:
                   abort();
                   /* NOTREACHED */
           }
   
           /* Check for repetition. */
   
           switch (node->data.elem.tok) {
           case (MDOC_Os):
                   if (0 == mdoc->meta.os[0])
                           return(1);
                   break;
           case (MDOC_Dd):
                   if (0 == mdoc->meta.date)
                           return(1);
                   break;
           case (MDOC_Dt):
                   if (0 == mdoc->meta.title[0])
                           return(1);
                   break;
           default:
                   abort();
                   /* NOTREACHED */
           }
   
           return(mdoc_verr(mdoc, node, ERR_SEC_PROLOGUE_REP));
   }
   
   
   /*
    * Warn if sections (those that are with a known title, such as NAME,
    * DESCRIPTION, and so forth) are out of the conventional order.
    */
   static int
   post_sh(struct mdoc *mdoc)
   {
           enum mdoc_sec     sec;
         int               i;          int               i;
         struct mdoc_node *n;          struct mdoc_node *n;
           char             *args[MDOC_LINEARG_MAX];
   
         if (MDOC_HEAD != mdoc->last->type)          if (MDOC_HEAD != mdoc->last->type)
                 return(1);                  return(1);
         for (i = 0, n = mdoc->last->child; n; n = n->next, i++)  
                 /* Do nothing. */ ;          assert(MDOC_Sh == mdoc->last->data.head.tok);
         if (i <= 8)  
                 return(1);  
         return(mdoc_err(mdoc, ERR_ARGS_LE8));  
 }  
   
           n = mdoc->last->child;
           assert(n);
   
 static int          for (i = 0; n && i < MDOC_LINEARG_MAX; n = n->next, i++) {
 pre_sh(struct mdoc *mdoc, struct mdoc_node *node)                  assert(MDOC_TEXT == n->type);
 {                  assert(NULL == n->child);
                   assert(n->data.text.string);
                   args[i] = n->data.text.string;
           }
   
         return(1);          sec = mdoc_atosec((size_t)i, (const char **)args);
           if (SEC_CUSTOM == sec)
                   return(1);
           if (sec > mdoc->sec_lastn)
                   return(1);
   
           if (sec == mdoc->sec_lastn)
                   return(mdoc_warn(mdoc, WARN_SEC_REP));
           return(mdoc_warn(mdoc, WARN_SEC_OO));
 }  }
   
   
Line 208  mdoc_valid_pre(struct mdoc *mdoc, struct mdoc_node *no
Line 289  mdoc_valid_pre(struct mdoc *mdoc, struct mdoc_node *no
   
         switch (node->type) {          switch (node->type) {
         case (MDOC_BODY):          case (MDOC_BODY):
                 t = mdoc->last->data.body.tok;                  t = node->data.body.tok;
                 break;                  break;
         case (MDOC_ELEM):          case (MDOC_ELEM):
                 t = mdoc->last->data.elem.tok;                  t = node->data.elem.tok;
                 break;                  break;
         case (MDOC_BLOCK):          case (MDOC_BLOCK):
                 t = mdoc->last->data.block.tok;                  t = node->data.block.tok;
                 break;                  break;
         case (MDOC_HEAD):          case (MDOC_HEAD):
                 t = mdoc->last->data.head.tok;                  t = node->data.head.tok;
                 break;                  break;
         default:          default:
                 return(1);                  return(1);

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.21

CVSweb