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

Diff for /mandoc/man_validate.c between version 1.122 and 1.125

version 1.122, 2016/01/08 17:48:09 version 1.125, 2017/05/05 02:06:19
Line 1 
Line 1 
 /*      $OpenBSD$ */  /*      $OpenBSD$ */
 /*  /*
  * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>   * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2010, 2012-2016 Ingo Schwarze <schwarze@openbsd.org>   * Copyright (c) 2010, 2012-2017 Ingo Schwarze <schwarze@openbsd.org>
  *   *
  * Permission to use, copy, modify, and distribute this software for any   * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above   * purpose with or without fee is hereby granted, provided that the above
Line 48  static void   check_text(CHKARGS);
Line 48  static void   check_text(CHKARGS);
 static  void      post_AT(CHKARGS);  static  void      post_AT(CHKARGS);
 static  void      post_IP(CHKARGS);  static  void      post_IP(CHKARGS);
 static  void      post_vs(CHKARGS);  static  void      post_vs(CHKARGS);
 static  void      post_ft(CHKARGS);  
 static  void      post_OP(CHKARGS);  static  void      post_OP(CHKARGS);
 static  void      post_TH(CHKARGS);  static  void      post_TH(CHKARGS);
 static  void      post_UC(CHKARGS);  static  void      post_UC(CHKARGS);
 static  void      post_UR(CHKARGS);  static  void      post_UR(CHKARGS);
   
 static  v_check man_valids[MAN_MAX] = {  static  const v_check __man_valids[MAN_MAX - MAN_TH] = {
         post_vs,    /* br */  
         post_TH,    /* TH */          post_TH,    /* TH */
         NULL,       /* SH */          NULL,       /* SH */
         NULL,       /* SS */          NULL,       /* SS */
Line 86  static v_check man_valids[MAN_MAX] = {
Line 84  static v_check man_valids[MAN_MAX] = {
         NULL,       /* PD */          NULL,       /* PD */
         post_AT,    /* AT */          post_AT,    /* AT */
         NULL,       /* in */          NULL,       /* in */
         post_ft,    /* ft */  
         post_OP,    /* OP */          post_OP,    /* OP */
         NULL,       /* EX */          NULL,       /* EX */
         NULL,       /* EE */          NULL,       /* EE */
Line 94  static v_check man_valids[MAN_MAX] = {
Line 91  static v_check man_valids[MAN_MAX] = {
         NULL,       /* UE */          NULL,       /* UE */
         NULL,       /* ll */          NULL,       /* ll */
 };  };
   static  const v_check *man_valids = __man_valids - MAN_TH;
   
   
 void  void
 man_node_validate(struct roff_man *man)  man_node_validate(struct roff_man *man)
 {  {
         struct roff_node *n;          struct roff_node *n;
         v_check         *cp;          const v_check    *cp;
   
         n = man->last;          n = man->last;
         man->last = man->last->child;          man->last = man->last->child;
Line 125  man_node_validate(struct roff_man *man)
Line 123  man_node_validate(struct roff_man *man)
         case ROFFT_TBL:          case ROFFT_TBL:
                 break;                  break;
         default:          default:
                   if (n->tok < ROFF_MAX) {
                           switch (n->tok) {
                           case ROFF_br:
                                   post_vs(man, n);
                                   break;
                           default:
                                   roff_validate(man);
                                   break;
                           }
                           break;
                   }
                   assert(n->tok >= MAN_TH && n->tok < MAN_MAX);
                 cp = man_valids + n->tok;                  cp = man_valids + n->tok;
                 if (*cp)                  if (*cp)
                         (*cp)(man, n);                          (*cp)(man, n);
Line 201  post_UR(CHKARGS)
Line 211  post_UR(CHKARGS)
 }  }
   
 static void  static void
 post_ft(CHKARGS)  
 {  
         char    *cp;  
         int      ok;  
   
         if (n->child == NULL)  
                 return;  
   
         ok = 0;  
         cp = n->child->string;  
         switch (*cp) {  
         case '1':  
         case '2':  
         case '3':  
         case '4':  
         case 'I':  
         case 'P':  
         case 'R':  
                 if ('\0' == cp[1])  
                         ok = 1;  
                 break;  
         case 'B':  
                 if ('\0' == cp[1] || ('I' == cp[1] && '\0' == cp[2]))  
                         ok = 1;  
                 break;  
         case 'C':  
                 if ('W' == cp[1] && '\0' == cp[2])  
                         ok = 1;  
                 break;  
         default:  
                 break;  
         }  
   
         if (0 == ok) {  
                 mandoc_vmsg(MANDOCERR_FT_BAD, man->parse,  
                     n->line, n->pos, "ft %s", cp);  
                 *cp = '\0';  
         }  
 }  
   
 static void  
 check_part(CHKARGS)  check_part(CHKARGS)
 {  {
   
         if (n->type == ROFFT_BODY && n->child == NULL)          if (n->type == ROFFT_BODY && n->child == NULL)
                 mandoc_msg(MANDOCERR_BLK_EMPTY, man->parse,                  mandoc_msg(MANDOCERR_BLK_EMPTY, man->parse,
                     n->line, n->pos, man_macronames[n->tok]);                      n->line, n->pos, roff_name[n->tok]);
 }  }
   
 static void  static void
Line 263  check_par(CHKARGS)
Line 232  check_par(CHKARGS)
                 if (n->child == NULL)                  if (n->child == NULL)
                         mandoc_vmsg(MANDOCERR_PAR_SKIP,                          mandoc_vmsg(MANDOCERR_PAR_SKIP,
                             man->parse, n->line, n->pos,                              man->parse, n->line, n->pos,
                             "%s empty", man_macronames[n->tok]);                              "%s empty", roff_name[n->tok]);
                 break;                  break;
         case ROFFT_HEAD:          case ROFFT_HEAD:
                 if (n->child != NULL)                  if (n->child != NULL)
                         mandoc_vmsg(MANDOCERR_ARG_SKIP,                          mandoc_vmsg(MANDOCERR_ARG_SKIP,
                             man->parse, n->line, n->pos,                              man->parse, n->line, n->pos, "%s %s%s",
                             "%s %s%s", man_macronames[n->tok],                              roff_name[n->tok], n->child->string,
                             n->child->string,  
                             n->child->next != NULL ? " ..." : "");                              n->child->next != NULL ? " ..." : "");
                 break;                  break;
         default:          default:
Line 291  post_IP(CHKARGS)
Line 259  post_IP(CHKARGS)
                 if (n->parent->head->child == NULL && n->child == NULL)                  if (n->parent->head->child == NULL && n->child == NULL)
                         mandoc_vmsg(MANDOCERR_PAR_SKIP,                          mandoc_vmsg(MANDOCERR_PAR_SKIP,
                             man->parse, n->line, n->pos,                              man->parse, n->line, n->pos,
                             "%s empty", man_macronames[n->tok]);                              "%s empty", roff_name[n->tok]);
                 break;                  break;
         default:          default:
                 break;                  break;
Line 479  post_vs(CHKARGS)
Line 447  post_vs(CHKARGS)
         case MAN_SH:          case MAN_SH:
         case MAN_SS:          case MAN_SS:
                 mandoc_vmsg(MANDOCERR_PAR_SKIP, man->parse, n->line, n->pos,                  mandoc_vmsg(MANDOCERR_PAR_SKIP, man->parse, n->line, n->pos,
                     "%s after %s", man_macronames[n->tok],                      "%s after %s", roff_name[n->tok],
                     man_macronames[n->parent->tok]);                      roff_name[n->parent->tok]);
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case TOKEN_NONE:          case TOKEN_NONE:
                 /*                  /*

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

CVSweb