[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.72 and 1.77

version 1.72, 2010/05/12 08:41:17 version 1.77, 2010/05/14 17:54:26
Line 1 
Line 1 
 /*      $Id$ */  /*      $Id$ */
 /*  /*
  * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>   * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
  *   *
  * 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 23 
Line 23 
 #include <assert.h>  #include <assert.h>
 #include <ctype.h>  #include <ctype.h>
 #include <limits.h>  #include <limits.h>
 #include <stdarg.h>  
 #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  #include <string.h>
   
Line 45  struct valids {
Line 44  struct valids {
 };  };
   
 static  int      check_parent(PRE_ARGS, enum mdoct, enum mdoc_type);  static  int      check_parent(PRE_ARGS, enum mdoct, enum mdoc_type);
 static  int      check_msec(PRE_ARGS, ...);  
 static  int      check_sec(PRE_ARGS, ...);  
 static  int      check_stdarg(PRE_ARGS);  static  int      check_stdarg(PRE_ARGS);
 static  int      check_text(struct mdoc *, int, int, const char *);  static  int      check_text(struct mdoc *, int, int, const char *);
 static  int      check_argv(struct mdoc *,  static  int      check_argv(struct mdoc *,
Line 100  static int  pre_bl(PRE_ARGS);
Line 97  static int  pre_bl(PRE_ARGS);
 static  int      pre_dd(PRE_ARGS);  static  int      pre_dd(PRE_ARGS);
 static  int      pre_display(PRE_ARGS);  static  int      pre_display(PRE_ARGS);
 static  int      pre_dt(PRE_ARGS);  static  int      pre_dt(PRE_ARGS);
 static  int      pre_ex(PRE_ARGS);  
 static  int      pre_fd(PRE_ARGS);  
 static  int      pre_it(PRE_ARGS);  static  int      pre_it(PRE_ARGS);
 static  int      pre_lb(PRE_ARGS);  
 static  int      pre_os(PRE_ARGS);  static  int      pre_os(PRE_ARGS);
 static  int      pre_rv(PRE_ARGS);  static  int      pre_rv(PRE_ARGS);
 static  int      pre_sh(PRE_ARGS);  static  int      pre_sh(PRE_ARGS);
Line 139  static v_pre  pres_d1[] = { pre_display, NULL };
Line 133  static v_pre  pres_d1[] = { pre_display, NULL };
 static  v_pre    pres_dd[] = { pre_dd, NULL };  static  v_pre    pres_dd[] = { pre_dd, NULL };
 static  v_pre    pres_dt[] = { pre_dt, NULL };  static  v_pre    pres_dt[] = { pre_dt, NULL };
 static  v_pre    pres_er[] = { NULL, NULL };  static  v_pre    pres_er[] = { NULL, NULL };
 static  v_pre    pres_ex[] = { pre_ex, NULL };  static  v_pre    pres_ex[] = { NULL, NULL };
 static  v_pre    pres_fd[] = { pre_fd, NULL };  static  v_pre    pres_fd[] = { NULL, NULL };
 static  v_pre    pres_it[] = { pre_it, NULL };  static  v_pre    pres_it[] = { pre_it, NULL };
 static  v_pre    pres_lb[] = { pre_lb, NULL };  static  v_pre    pres_lb[] = { NULL, NULL };
 static  v_pre    pres_os[] = { pre_os, NULL };  static  v_pre    pres_os[] = { pre_os, NULL };
 static  v_pre    pres_rv[] = { pre_rv, NULL };  static  v_pre    pres_rv[] = { pre_rv, NULL };
 static  v_pre    pres_sh[] = { pre_sh, NULL };  static  v_pre    pres_sh[] = { pre_sh, NULL };
Line 416  check_stdarg(PRE_ARGS)
Line 410  check_stdarg(PRE_ARGS)
   
   
 static int  static int
 check_sec(PRE_ARGS, ...)  
 {  
         enum mdoc_sec    sec;  
         va_list          ap;  
   
         va_start(ap, n);  
   
         for (;;) {  
                 /* LINTED */  
                 sec = (enum mdoc_sec)va_arg(ap, int);  
                 if (SEC_CUSTOM == sec)  
                         break;  
                 if (sec != mdoc->lastsec)  
                         continue;  
                 va_end(ap);  
                 return(1);  
         }  
   
         va_end(ap);  
         return(mdoc_nwarn(mdoc, n, EBADSEC));  
 }  
   
   
 static int  
 check_msec(PRE_ARGS, ...)  
 {  
         va_list          ap;  
         int              msec;  
   
         va_start(ap, n);  
         for (;;) {  
                 /* LINTED */  
                 if (0 == (msec = va_arg(ap, int)))  
                         break;  
                 if (msec != mdoc->meta.msec)  
                         continue;  
                 va_end(ap);  
                 return(1);  
         }  
   
         va_end(ap);  
         return(mdoc_nwarn(mdoc, n, EBADMSEC));  
 }  
   
   
 static int  
 check_args(struct mdoc *m, const struct mdoc_node *n)  check_args(struct mdoc *m, const struct mdoc_node *n)
 {  {
         int              i;          int              i;
Line 762  pre_an(PRE_ARGS)
Line 710  pre_an(PRE_ARGS)
   
   
 static int  static int
 pre_lb(PRE_ARGS)  
 {  
   
         return(check_sec(mdoc, n, SEC_LIBRARY, SEC_CUSTOM));  
 }  
   
   
 static int  
 pre_rv(PRE_ARGS)  pre_rv(PRE_ARGS)
 {  {
   
Line 778  pre_rv(PRE_ARGS)
Line 718  pre_rv(PRE_ARGS)
   
   
 static int  static int
 pre_ex(PRE_ARGS)  
 {  
   
         if ( ! check_msec(mdoc, n, 1, 6, 8, 0))  
                 return(0);  
         return(check_stdarg(mdoc, n));  
 }  
   
   
 static int  
 pre_dt(PRE_ARGS)  pre_dt(PRE_ARGS)
 {  {
   
Line 921  post_at(POST_ARGS)
Line 851  post_at(POST_ARGS)
                 return(mdoc_nerr(mdoc, mdoc->last, EATT));                  return(mdoc_nerr(mdoc, mdoc->last, EATT));
         if (mdoc_a2att(mdoc->last->child->string))          if (mdoc_a2att(mdoc->last->child->string))
                 return(1);                  return(1);
         return(mdoc_nerr(mdoc, mdoc->last, EATT));          return(mdoc_nwarn(mdoc, mdoc->last, EATT));
 }  }
   
   
Line 1039  post_it(POST_ARGS)
Line 969  post_it(POST_ARGS)
                 for (i = 0; c && MDOC_HEAD == c->type; c = c->next)                  for (i = 0; c && MDOC_HEAD == c->type; c = c->next)
                         i++;                          i++;
   
                 if (i < cols || i == (cols + 1)) {                  if (i < cols) {
                         if ( ! mdoc_vwarn(mdoc, mdoc->last->line,                          if ( ! mdoc_vwarn(mdoc, mdoc->last->line,
                                         mdoc->last->pos, "column "                                          mdoc->last->pos, "column "
                                         "mismatch: have %d, want %d",                                          "mismatch: have %d, want %d",
                                         i, cols))                                          i, cols))
                                 return(0);                                  return(0);
                         break;                          break;
                 } else if (i == cols)                  } else if (i == cols || i == cols + 1)
                         break;                          break;
   
                 return(mdoc_verr(mdoc, mdoc->last->line,                  return(mdoc_verr(mdoc, mdoc->last->line,
Line 1162  post_st(POST_ARGS)
Line 1092  post_st(POST_ARGS)
   
         if (mdoc_a2st(mdoc->last->child->string))          if (mdoc_a2st(mdoc->last->child->string))
                 return(1);                  return(1);
         return(mdoc_nerr(mdoc, mdoc->last, EBADSTAND));          return(mdoc_nwarn(mdoc, mdoc->last, EBADSTAND));
 }  }
   
   
Line 1329  post_sh_head(POST_ARGS)
Line 1259  post_sh_head(POST_ARGS)
         }          }
   
         return(1);          return(1);
 }  
   
   
 static int  
 pre_fd(PRE_ARGS)  
 {  
   
         return(check_sec(mdoc, n, SEC_SYNOPSIS, SEC_CUSTOM));  
 }  }

Legend:
Removed from v.1.72  
changed lines
  Added in v.1.77

CVSweb