[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.246 and 1.250

version 1.246, 2014/09/07 00:05:28 version 1.250, 2014/10/11 21:14:16
Line 67  static void  check_text(struct mdoc *, int, int, char 
Line 67  static void  check_text(struct mdoc *, int, int, char 
 static  void     check_argv(struct mdoc *,  static  void     check_argv(struct mdoc *,
                         struct mdoc_node *, struct mdoc_argv *);                          struct mdoc_node *, struct mdoc_argv *);
 static  void     check_args(struct mdoc *, struct mdoc_node *);  static  void     check_args(struct mdoc *, struct mdoc_node *);
   static  int      child_an(const struct mdoc_node *);
 static  enum mdoc_sec   a2sec(const char *);  static  enum mdoc_sec   a2sec(const char *);
 static  size_t          macro2len(enum mdoct);  static  size_t          macro2len(enum mdoct);
   
Line 99  static int  post_en(POST_ARGS);
Line 100  static int  post_en(POST_ARGS);
 static  int      post_es(POST_ARGS);  static  int      post_es(POST_ARGS);
 static  int      post_eoln(POST_ARGS);  static  int      post_eoln(POST_ARGS);
 static  int      post_ex(POST_ARGS);  static  int      post_ex(POST_ARGS);
   static  int      post_fa(POST_ARGS);
   static  int      post_fn(POST_ARGS);
   static  int      post_fname(POST_ARGS);
 static  int      post_fo(POST_ARGS);  static  int      post_fo(POST_ARGS);
 static  int      post_hyph(POST_ARGS);  static  int      post_hyph(POST_ARGS);
 static  int      post_hyphtext(POST_ARGS);  static  int      post_hyphtext(POST_ARGS);
Line 114  static int  post_par(POST_ARGS);
Line 118  static int  post_par(POST_ARGS);
 static  int      post_root(POST_ARGS);  static  int      post_root(POST_ARGS);
 static  int      post_rs(POST_ARGS);  static  int      post_rs(POST_ARGS);
 static  int      post_sh(POST_ARGS);  static  int      post_sh(POST_ARGS);
 static  int      post_sh_body(POST_ARGS);  
 static  int      post_sh_head(POST_ARGS);  static  int      post_sh_head(POST_ARGS);
   static  int      post_sh_name(POST_ARGS);
   static  int      post_sh_see_also(POST_ARGS);
   static  int      post_sh_authors(POST_ARGS);
 static  int      post_st(POST_ARGS);  static  int      post_st(POST_ARGS);
 static  int      post_vt(POST_ARGS);  static  int      post_vt(POST_ARGS);
 static  int      pre_an(PRE_ARGS);  static  int      pre_an(PRE_ARGS);
Line 154  static const struct valids mdoc_valids[MDOC_MAX] = {
Line 160  static const struct valids mdoc_valids[MDOC_MAX] = {
         { NULL, NULL },                         /* Er */          { NULL, NULL },                         /* Er */
         { NULL, NULL },                         /* Ev */          { NULL, NULL },                         /* Ev */
         { pre_std, post_ex },                   /* Ex */          { pre_std, post_ex },                   /* Ex */
         { NULL, NULL },                         /* Fa */          { NULL, post_fa },                      /* Fa */
         { NULL, ewarn_ge1 },                    /* Fd */          { NULL, ewarn_ge1 },                    /* Fd */
         { NULL, NULL },                         /* Fl */          { NULL, NULL },                         /* Fl */
         { NULL, NULL },                         /* Fn */          { NULL, post_fn },                      /* Fn */
         { NULL, NULL },                         /* Ft */          { NULL, NULL },                         /* Ft */
         { NULL, NULL },                         /* Ic */          { NULL, NULL },                         /* Ic */
         { NULL, ewarn_eq1 },                    /* In */          { NULL, ewarn_eq1 },                    /* In */
Line 996  post_eoln(POST_ARGS)
Line 1002  post_eoln(POST_ARGS)
 }  }
   
 static int  static int
   post_fname(POST_ARGS)
   {
           const struct mdoc_node *n;
           size_t pos;
   
           n = mdoc->last->child;
           pos = strcspn(n->string, "()");
           if (n->string[pos] != '\0')
                   mandoc_msg(MANDOCERR_FN_PAREN, mdoc->parse,
                       n->line, n->pos + pos, n->string);
           return(1);
   }
   
   static int
   post_fn(POST_ARGS)
   {
   
           post_fname(mdoc);
           post_fa(mdoc);
           return(1);
   }
   
   static int
 post_fo(POST_ARGS)  post_fo(POST_ARGS)
 {  {
   
         hwarn_eq1(mdoc);          hwarn_eq1(mdoc);
         bwarn_ge1(mdoc);          bwarn_ge1(mdoc);
           if (mdoc->last->type == MDOC_HEAD)
                   post_fname(mdoc);
         return(1);          return(1);
 }  }
   
 static int  static int
   post_fa(POST_ARGS)
   {
           const struct mdoc_node *n;
           const char *cp;
   
           for (n = mdoc->last->child; n != NULL; n = n->next) {
                   for (cp = n->string; *cp != '\0'; cp++) {
                           /* Ignore callbacks and alterations. */
                           if (*cp == '(' || *cp == '{')
                                   break;
                           if (*cp != ',')
                                   continue;
                           mandoc_msg(MANDOCERR_FA_COMMA, mdoc->parse,
                               n->line, n->pos + (cp - n->string),
                               n->string);
                           break;
                   }
           }
           return(1);
   }
   
   static int
 post_vt(POST_ARGS)  post_vt(POST_ARGS)
 {  {
         const struct mdoc_node *n;          const struct mdoc_node *n;
Line 1847  post_sh(POST_ARGS)
Line 1900  post_sh(POST_ARGS)
   
         post_ignpar(mdoc);          post_ignpar(mdoc);
   
         if (MDOC_HEAD == mdoc->last->type)          switch (mdoc->last->type) {
           case MDOC_HEAD:
                 return(post_sh_head(mdoc));                  return(post_sh_head(mdoc));
         if (MDOC_BODY == mdoc->last->type)          case MDOC_BODY:
                 return(post_sh_body(mdoc));                  switch (mdoc->lastsec)  {
                   case SEC_NAME:
                           return(post_sh_name(mdoc));
                   case SEC_SEE_ALSO:
                           return(post_sh_see_also(mdoc));
                   case SEC_AUTHORS:
                           return(post_sh_authors(mdoc));
                   default:
                           break;
                   }
                   break;
           default:
                   break;
           }
   
         return(1);          return(1);
 }  }
   
 static int  static int
 post_sh_body(POST_ARGS)  post_sh_name(POST_ARGS)
 {  {
         struct mdoc_node *n;          struct mdoc_node *n;
   
         if (SEC_NAME != mdoc->lastsec)  
                 return(1);  
   
         /*          /*
          * Warn if the NAME section doesn't contain the `Nm' and `Nd'           * Warn if the NAME section doesn't contain the `Nm' and `Nd'
          * macros (can have multiple `Nm' and one `Nd').  Note that the           * macros (can have multiple `Nm' and one `Nd').  Note that the
Line 1890  post_sh_body(POST_ARGS)
Line 1954  post_sh_body(POST_ARGS)
   
         mandoc_msg(MANDOCERR_NAMESEC_BAD, mdoc->parse,          mandoc_msg(MANDOCERR_NAMESEC_BAD, mdoc->parse,
             n->line, n->pos, mdoc_macronames[n->tok]);              n->line, n->pos, mdoc_macronames[n->tok]);
           return(1);
   }
   
   static int
   post_sh_see_also(POST_ARGS)
   {
           const struct mdoc_node  *n;
           const char              *name, *sec;
           const char              *lastname, *lastsec, *lastpunct;
           int                      cmp;
   
           n = mdoc->last->child;
           lastname = lastsec = lastpunct = NULL;
           while (n != NULL) {
                   if (n->tok != MDOC_Xr || n->nchild < 2)
                           break;
   
                   /* Process one .Xr node. */
   
                   name = n->child->string;
                   sec = n->child->next->string;
                   if (lastsec != NULL) {
                           if (lastpunct[0] != ',' || lastpunct[1] != '\0')
                                   mandoc_vmsg(MANDOCERR_XR_PUNCT,
                                       mdoc->parse, n->line, n->pos,
                                       "%s before %s(%s)", lastpunct,
                                       name, sec);
                           cmp = strcmp(lastsec, sec);
                           if (cmp > 0)
                                   mandoc_vmsg(MANDOCERR_XR_ORDER,
                                       mdoc->parse, n->line, n->pos,
                                       "%s(%s) after %s(%s)", name,
                                       sec, lastname, lastsec);
                           else if (cmp == 0 && strcmp(lastname, name) > 0)
                                   mandoc_vmsg(MANDOCERR_XR_ORDER,
                                       mdoc->parse, n->line, n->pos,
                                       "%s after %s", name, lastname);
                   }
                   lastname = name;
                   lastsec = sec;
   
                   /* Process the following node. */
   
                   n = n->next;
                   if (n == NULL)
                           break;
                   if (n->tok == MDOC_Xr) {
                           lastpunct = "none";
                           continue;
                   }
                   if (n->type != MDOC_TEXT)
                           break;
                   for (name = n->string; *name != '\0'; name++)
                           if (isalpha((const unsigned char)*name))
                                   return(1);
                   lastpunct = n->string;
                   if (n->next == NULL)
                           mandoc_vmsg(MANDOCERR_XR_PUNCT, mdoc->parse,
                               n->line, n->pos, "%s after %s(%s)",
                               lastpunct, lastname, lastsec);
                   n = n->next;
           }
           return(1);
   }
   
   static int
   child_an(const struct mdoc_node *n)
   {
   
           for (n = n->child; n != NULL; n = n->next)
                   if ((n->tok == MDOC_An && n->nchild) || child_an(n))
                           return(1);
           return(0);
   }
   
   static int
   post_sh_authors(POST_ARGS)
   {
   
           if ( ! child_an(mdoc->last))
                   mandoc_msg(MANDOCERR_AN_MISSING, mdoc->parse,
                       mdoc->last->line, mdoc->last->pos, NULL);
         return(1);          return(1);
 }  }
   

Legend:
Removed from v.1.246  
changed lines
  Added in v.1.250

CVSweb