[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.325 and 1.330

version 1.325, 2017/05/05 13:17:55 version 1.330, 2017/06/01 15:25:39
Line 53  typedef void (*v_post)(POST_ARGS);
Line 53  typedef void (*v_post)(POST_ARGS);
   
 static  int      build_list(struct roff_man *, int);  static  int      build_list(struct roff_man *, int);
 static  void     check_text(struct roff_man *, int, int, char *);  static  void     check_text(struct roff_man *, int, int, char *);
   static  void     check_bsd(struct roff_man *, int, int, char *);
 static  void     check_argv(struct roff_man *,  static  void     check_argv(struct roff_man *,
                         struct roff_node *, struct mdoc_argv *);                          struct roff_node *, struct mdoc_argv *);
 static  void     check_args(struct roff_man *, struct roff_node *);  static  void     check_args(struct roff_man *, struct roff_node *);
Line 105  static void  post_sh_authors(POST_ARGS);
Line 106  static void  post_sh_authors(POST_ARGS);
 static  void     post_sm(POST_ARGS);  static  void     post_sm(POST_ARGS);
 static  void     post_st(POST_ARGS);  static  void     post_st(POST_ARGS);
 static  void     post_std(POST_ARGS);  static  void     post_std(POST_ARGS);
   static  void     post_useless(POST_ARGS);
 static  void     post_xr(POST_ARGS);  static  void     post_xr(POST_ARGS);
 static  void     post_xx(POST_ARGS);  static  void     post_xx(POST_ARGS);
   
Line 201  static const v_post __mdoc_valids[MDOC_MAX - MDOC_Dd] 
Line 203  static const v_post __mdoc_valids[MDOC_MAX - MDOC_Dd] 
         post_sm,        /* Sm */          post_sm,        /* Sm */
         post_hyph,      /* Sx */          post_hyph,      /* Sx */
         NULL,           /* Sy */          NULL,           /* Sy */
         NULL,           /* Tn */          post_useless,   /* Tn */
         post_xx,        /* Ux */          post_xx,        /* Ux */
         NULL,           /* Xc */          NULL,           /* Xc */
         NULL,           /* Xo */          NULL,           /* Xo */
Line 227  static const v_post __mdoc_valids[MDOC_MAX - MDOC_Dd] 
Line 229  static const v_post __mdoc_valids[MDOC_MAX - MDOC_Dd] 
         post_en,        /* En */          post_en,        /* En */
         post_xx,        /* Dx */          post_xx,        /* Dx */
         NULL,           /* %Q */          NULL,           /* %Q */
         post_par,       /* sp */  
         NULL,           /* %U */          NULL,           /* %U */
         NULL,           /* Ta */          NULL,           /* Ta */
 };  };
Line 302  mdoc_node_validate(struct roff_man *mdoc)
Line 303  mdoc_node_validate(struct roff_man *mdoc)
                 if (n->sec != SEC_SYNOPSIS ||                  if (n->sec != SEC_SYNOPSIS ||
                     (n->parent->tok != MDOC_Cd && n->parent->tok != MDOC_Fd))                      (n->parent->tok != MDOC_Cd && n->parent->tok != MDOC_Fd))
                         check_text(mdoc, n->line, n->pos, n->string);                          check_text(mdoc, n->line, n->pos, n->string);
                   if (n->parent->tok == MDOC_Sh ||
                       n->parent->tok == MDOC_Ss ||
                       n->parent->tok == MDOC_It)
                           check_bsd(mdoc, n->line, n->pos, n->string);
                 break;                  break;
         case ROFFT_EQN:          case ROFFT_EQN:
         case ROFFT_TBL:          case ROFFT_TBL:
Line 328  mdoc_node_validate(struct roff_man *mdoc)
Line 333  mdoc_node_validate(struct roff_man *mdoc)
                 if (n->tok < ROFF_MAX) {                  if (n->tok < ROFF_MAX) {
                         switch(n->tok) {                          switch(n->tok) {
                         case ROFF_br:                          case ROFF_br:
                           case ROFF_sp:
                                 post_par(mdoc);                                  post_par(mdoc);
                                 break;                                  break;
                         default:                          default:
Line 383  check_text(struct roff_man *mdoc, int ln, int pos, cha
Line 389  check_text(struct roff_man *mdoc, int ln, int pos, cha
 }  }
   
 static void  static void
   check_bsd(struct roff_man *mdoc, int ln, int pos, char *p)
   {
           const char      *cp;
   
           if ((cp = strstr(p, "OpenBSD")) != NULL)
                   mandoc_msg(MANDOCERR_BX, mdoc->parse,
                       ln, pos + (cp - p), "Ox");
           if ((cp = strstr(p, "NetBSD")) != NULL)
                   mandoc_msg(MANDOCERR_BX, mdoc->parse,
                       ln, pos + (cp - p), "Nx");
           if ((cp = strstr(p, "FreeBSD")) != NULL)
                   mandoc_msg(MANDOCERR_BX, mdoc->parse,
                       ln, pos + (cp - p), "Fx");
           if ((cp = strstr(p, "DragonFly")) != NULL)
                   mandoc_msg(MANDOCERR_BX, mdoc->parse,
                       ln, pos + (cp - p), "Dx");
   }
   
   static void
 post_bl_norm(POST_ARGS)  post_bl_norm(POST_ARGS)
 {  {
         struct roff_node *n;          struct roff_node *n;
Line 671  post_eoln(POST_ARGS)
Line 696  post_eoln(POST_ARGS)
 {  {
         struct roff_node        *n;          struct roff_node        *n;
   
           post_useless(mdoc);
         n = mdoc->last;          n = mdoc->last;
         if (n->child != NULL)          if (n->child != NULL)
                 mandoc_vmsg(MANDOCERR_ARG_SKIP, mdoc->parse, n->line,                  mandoc_vmsg(MANDOCERR_ARG_SKIP, mdoc->parse, n->line,
Line 866  post_obsolete(POST_ARGS)
Line 892  post_obsolete(POST_ARGS)
                     n->line, n->pos, roff_name[n->tok]);                      n->line, n->pos, roff_name[n->tok]);
 }  }
   
   static void
   post_useless(POST_ARGS)
   {
           struct roff_node *n;
   
           n = mdoc->last;
           mandoc_msg(MANDOCERR_MACRO_USELESS, mdoc->parse,
               n->line, n->pos, roff_name[n->tok]);
   }
   
 /*  /*
  * Block macros.   * Block macros.
  */   */
Line 1040  static void
Line 1076  static void
 post_nd(POST_ARGS)  post_nd(POST_ARGS)
 {  {
         struct roff_node        *n;          struct roff_node        *n;
           size_t                   sz;
   
         n = mdoc->last;          n = mdoc->last;
   
Line 1053  post_nd(POST_ARGS)
Line 1090  post_nd(POST_ARGS)
         if (n->child == NULL)          if (n->child == NULL)
                 mandoc_msg(MANDOCERR_ND_EMPTY, mdoc->parse,                  mandoc_msg(MANDOCERR_ND_EMPTY, mdoc->parse,
                     n->line, n->pos, "Nd");                      n->line, n->pos, "Nd");
           else if (n->last->type == ROFFT_TEXT &&
               (sz = strlen(n->last->string)) != 0 &&
               n->last->string[sz - 1] == '.')
                   mandoc_msg(MANDOCERR_ND_DOT, mdoc->parse,
                       n->last->line, n->last->pos + sz - 1, NULL);
   
         post_hyph(mdoc);          post_hyph(mdoc);
 }  }
Line 1879  post_sh_see_also(POST_ARGS)
Line 1921  post_sh_see_also(POST_ARGS)
                         if (isalpha((const unsigned char)*name))                          if (isalpha((const unsigned char)*name))
                                 return;                                  return;
                 lastpunct = n->string;                  lastpunct = n->string;
                 if (n->next == NULL)                  if (n->next == NULL || n->next->tok == MDOC_Rs)
                         mandoc_vmsg(MANDOCERR_XR_PUNCT, mdoc->parse,                          mandoc_vmsg(MANDOCERR_XR_PUNCT, mdoc->parse,
                             n->line, n->pos, "%s after %s(%s)",                              n->line, n->pos, "%s after %s(%s)",
                             lastpunct, lastname, lastsec);                              lastpunct, lastname, lastsec);
Line 2096  post_par(POST_ARGS)
Line 2138  post_par(POST_ARGS)
         struct roff_node *np;          struct roff_node *np;
   
         np = mdoc->last;          np = mdoc->last;
         if (np->tok != ROFF_br && np->tok != MDOC_sp)          if (np->tok != ROFF_br && np->tok != ROFF_sp)
                 post_prevpar(mdoc);                  post_prevpar(mdoc);
   
         if (np->tok == MDOC_sp) {          if (np->tok == ROFF_sp) {
                 if (np->child != NULL && np->child->next != NULL)                  if (np->child != NULL && np->child->next != NULL)
                         mandoc_vmsg(MANDOCERR_ARG_EXCESS, mdoc->parse,                          mandoc_vmsg(MANDOCERR_ARG_EXCESS, mdoc->parse,
                             np->child->next->line, np->child->next->pos,                              np->child->next->line, np->child->next->pos,
Line 2115  post_par(POST_ARGS)
Line 2157  post_par(POST_ARGS)
                         return;                          return;
         } else if (np->tok != MDOC_Pp && np->tok != MDOC_Lp &&          } else if (np->tok != MDOC_Pp && np->tok != MDOC_Lp &&
             (mdoc->last->tok != ROFF_br ||              (mdoc->last->tok != ROFF_br ||
              (np->tok != MDOC_sp && np->tok != ROFF_br)))               (np->tok != ROFF_sp && np->tok != ROFF_br)))
                 return;                  return;
   
         mandoc_vmsg(MANDOCERR_PAR_SKIP, mdoc->parse,          mandoc_vmsg(MANDOCERR_PAR_SKIP, mdoc->parse,
Line 2264  static void
Line 2306  static void
 post_bx(POST_ARGS)  post_bx(POST_ARGS)
 {  {
         struct roff_node        *n, *nch;          struct roff_node        *n, *nch;
           const char              *macro;
   
         n = mdoc->last;          n = mdoc->last;
         nch = n->child;          nch = n->child;
   
         if (nch != NULL) {          if (nch != NULL) {
                   macro = !strcmp(nch->string, "Open") ? "Ox" :
                       !strcmp(nch->string, "Net") ? "Nx" :
                       !strcmp(nch->string, "Free") ? "Fx" :
                       !strcmp(nch->string, "DragonFly") ? "Dx" : NULL;
                   if (macro != NULL)
                           mandoc_msg(MANDOCERR_BX, mdoc->parse,
                               n->line, n->pos, macro);
                 mdoc->last = nch;                  mdoc->last = nch;
                 nch = nch->next;                  nch = nch->next;
                 mdoc->next = ROFF_NEXT_SIBLING;                  mdoc->next = ROFF_NEXT_SIBLING;

Legend:
Removed from v.1.325  
changed lines
  Added in v.1.330

CVSweb