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

Diff for /mandoc/Attic/validate.c between version 1.50 and 1.51

version 1.50, 2009/02/21 21:00:06 version 1.51, 2009/02/22 14:31:08
Line 34  typedef int (*v_post)(struct mdoc *);
Line 34  typedef int (*v_post)(struct mdoc *);
   
 /* FIXME: some sections should only occur in specific msecs. */  /* FIXME: some sections should only occur in specific msecs. */
 /* FIXME: ignoring Pp. */  /* FIXME: ignoring Pp. */
   /* FIXME: .Ef arguments */
 /* FIXME: math symbols. */  /* FIXME: math symbols. */
 /* FIXME: valid character-escape checks!!!! */  /* FIXME: valid character-escape checks. */
 /* FIXME: make sure required sections are included (NAME, ...). */  /* FIXME: .Fd only in synopsis section. */
   
 struct  valids {  struct  valids {
         v_pre   *pre;          v_pre   *pre;
Line 45  struct valids {
Line 46  struct valids {
   
 /* Utility checks. */  /* Utility checks. */
   
 static  int     pre_check_parent(struct mdoc *, struct mdoc_node *,  static  int     check_parent(struct mdoc *, struct mdoc_node *,
                         int, enum mdoc_type);                          int, enum mdoc_type);
 static  int     pre_check_msecs(struct mdoc *, struct mdoc_node *,  static  int     check_msec(struct mdoc *, struct mdoc_node *,
                         int, enum mdoc_msec *);                          int, enum mdoc_msec *);
 static  int     pre_check_stdarg(struct mdoc *, struct mdoc_node *);  static  int     check_stdarg(struct mdoc *, struct mdoc_node *);
 static  int     post_check_children_count(struct mdoc *);  static  int     err_child_lt(struct mdoc *, const char *, int);
 static  int     post_check_children_lt(struct mdoc *, const char *, int);  static  int     err_child_gt(struct mdoc *, const char *, int);
 static  int     post_check_children_gt(struct mdoc *, const char *, int);  static  int     warn_child_gt(struct mdoc *, const char *, int);
 static  int     post_check_children_wgt(struct mdoc *, const char *, int);  static  int     err_child_eq(struct mdoc *, const char *, int);
 static  int     post_check_children_eq(struct mdoc *, const char *, int);  static  int     warn_child_eq(struct mdoc *, const char *, int);
 static  int     post_check_children_weq(struct mdoc *, const char *, int);  
   
   /* Utility auxiliaries. */
   
   static  inline int count_child(struct mdoc *);
   static  inline int warn_count(struct mdoc *, const char *,
                           int, const char *, int);
   static  inline int err_count(struct mdoc *, const char *,
                           int, const char *, int);
   
 /* Specific pre-child-parse routines. */  /* Specific pre-child-parse routines. */
   
 static  int     pre_display(struct mdoc *, struct mdoc_node *);  static  int     pre_display(struct mdoc *, struct mdoc_node *);
Line 146  static v_post posts_bk[] = { herr_eq0, bwarn_ge1, NULL
Line 154  static v_post posts_bk[] = { herr_eq0, bwarn_ge1, NULL
 /* Per-macro pre- and post-child-check routine collections. */  /* Per-macro pre- and post-child-check routine collections. */
   
 const   struct valids mdoc_valids[MDOC_MAX] = {  const   struct valids mdoc_valids[MDOC_MAX] = {
         { NULL, NULL }, /* \" */          { NULL, NULL },                         /* \" */
         { pres_prologue, posts_text }, /* Dd */          { pres_prologue, posts_text },          /* Dd */
         { pres_prologue, NULL }, /* Dt */          { pres_prologue, NULL },                /* Dt */
         { pres_prologue, NULL }, /* Os */          { pres_prologue, NULL },                /* Os */
         { pres_sh, posts_sh }, /* Sh */          { pres_sh, posts_sh },                  /* Sh */
         { pres_ss, posts_ss }, /* Ss */          { pres_ss, posts_ss },                  /* Ss */
         { NULL, posts_pp }, /* Pp */          { NULL, posts_pp },                     /* Pp */
         { pres_d1, posts_wline }, /* D1 */          { pres_d1, posts_wline },               /* D1 */
         { pres_d1, posts_wline }, /* Dl */          { pres_d1, posts_wline },               /* Dl */
         { pres_bd, posts_bd }, /* Bd */          { pres_bd, posts_bd },                  /* Bd */
         { NULL, NULL }, /* Ed */          { NULL, NULL },                         /* Ed */
         { pres_bl, posts_bl }, /* Bl */          { pres_bl, posts_bl },                  /* Bl */
         { NULL, NULL }, /* El */          { NULL, NULL },                         /* El */
         { pres_it, posts_it }, /* It */          { pres_it, posts_it },                  /* It */
         { NULL, posts_text }, /* Ad */          { NULL, posts_text },                   /* Ad */
         { pres_an, posts_an }, /* An */          { pres_an, posts_an },                  /* An */
         { NULL, NULL }, /* Ar */          { NULL, NULL },                         /* Ar */
         { pres_cd, posts_text }, /* Cd */          { pres_cd, posts_text },                /* Cd */
         { NULL, NULL }, /* Cm */          { NULL, NULL },                         /* Cm */
         { NULL, posts_text }, /* Dv */          { NULL, posts_text },                   /* Dv */
         { pres_er, posts_text }, /* Er */          { pres_er, posts_text },                /* Er */
         { NULL, posts_text }, /* Ev */          { NULL, posts_text },                   /* Ev */
         { pres_ex, posts_ex }, /* Ex */          { pres_ex, posts_ex },                  /* Ex */
         { NULL, posts_text }, /* Fa */          { NULL, posts_text },                   /* Fa */
         /* FIXME: only in SYNOPSIS section. */          { NULL, posts_wtext },                  /* Fd */
         { NULL, posts_wtext }, /* Fd */          { NULL, NULL },                         /* Fl */
         { NULL, NULL }, /* Fl */          { NULL, posts_text },                   /* Fn */
         { NULL, posts_text }, /* Fn */          { NULL, posts_wtext },                  /* Ft */
         { NULL, posts_wtext }, /* Ft */          { NULL, posts_text },                   /* Ic */
         { NULL, posts_text }, /* Ic */          { NULL, posts_in },                     /* In */
         { NULL, posts_in }, /* In */          { NULL, posts_text },                   /* Li */
         { NULL, posts_text }, /* Li */          { NULL, posts_wtext },                  /* Nd */
         { NULL, posts_wtext }, /* Nd */          { NULL, posts_nm },                     /* Nm */
         { NULL, posts_nm }, /* Nm */          { NULL, posts_wline },                  /* Op */
         { NULL, posts_wline }, /* Op */          { NULL, NULL },                         /* Ot */
         { NULL, NULL }, /* Ot */          { NULL, NULL },                         /* Pa */
         { NULL, NULL }, /* Pa */          { pres_rv, posts_notext },              /* Rv */
         { pres_rv, posts_notext }, /* Rv */          { pres_st, posts_notext },              /* St */
         { pres_st, posts_notext }, /* St */          { NULL, posts_text },                   /* Va */
         { NULL, posts_text }, /* Va */          { NULL, posts_text },                   /* Vt */
         { NULL, posts_text }, /* Vt */          { NULL, posts_xr },                     /* Xr */
         { NULL, posts_xr }, /* Xr */          { NULL, posts_text },                   /* %A */
         { NULL, posts_text }, /* %A */          { NULL, posts_text },                   /* %B */
         { NULL, posts_text }, /* %B */          { NULL, posts_text },                   /* %D */
         { NULL, posts_text }, /* %D */          { NULL, posts_text },                   /* %I */
         { NULL, posts_text }, /* %I */          { NULL, posts_text },                   /* %J */
         { NULL, posts_text }, /* %J */          { NULL, posts_text },                   /* %N */
         { NULL, posts_text }, /* %N */          { NULL, posts_text },                   /* %O */
         { NULL, posts_text }, /* %O */          { NULL, posts_text },                   /* %P */
         { NULL, posts_text }, /* %P */          { NULL, posts_text },                   /* %R */
         { NULL, posts_text }, /* %R */          { NULL, posts_text },                   /* %T */
         { NULL, posts_text }, /* %T */          { NULL, posts_text },                   /* %V */
         { NULL, posts_text }, /* %V */          { NULL, NULL },                         /* Ac */
         { NULL, NULL }, /* Ac */          { NULL, NULL },                         /* Ao */
         { NULL, NULL }, /* Ao */          { NULL, posts_wline },                  /* Aq */
         { NULL, posts_wline }, /* Aq */          { NULL, posts_at },                     /* At */
         { NULL, posts_at }, /* At */          { NULL, NULL },                         /* Bc */
         { NULL, NULL }, /* Bc */          { NULL, posts_bf },                     /* Bf */
         { NULL, posts_bf }, /* Bf */          { NULL, NULL },                         /* Bo */
         { NULL, NULL }, /* Bo */          { NULL, posts_wline },                  /* Bq */
         { NULL, posts_wline }, /* Bq */          { NULL, NULL },                         /* Bsx */
         { NULL, NULL }, /* Bsx */          { NULL, NULL },                         /* Bx */
         { NULL, NULL }, /* Bx */          { NULL, posts_bool },                   /* Db */
         { NULL, posts_bool }, /* Db */          { NULL, NULL },                         /* Dc */
         { NULL, NULL }, /* Dc */          { NULL, NULL },                         /* Do */
         { NULL, NULL }, /* Do */          { NULL, posts_wline },                  /* Dq */
         { NULL, posts_wline }, /* Dq */          { NULL, NULL },                         /* Ec */
         { NULL, NULL }, /* Ec */          { NULL, NULL },                         /* Ef */
         { NULL, NULL }, /* Ef */ /* -symbolic, etc. */          { NULL, posts_text },                   /* Em */
         { NULL, posts_text }, /* Em */          { NULL, NULL },                         /* Eo */
         { NULL, NULL }, /* Eo */          { NULL, NULL },                         /* Fx */
         { NULL, NULL }, /* Fx */          { NULL, posts_text },                   /* Ms */
         { NULL, posts_text }, /* Ms */          { NULL, posts_notext },                 /* No */
         { NULL, posts_notext }, /* No */          { NULL, posts_notext },                 /* Ns */
         { NULL, posts_notext }, /* Ns */          { NULL, NULL },                         /* Nx */
         { NULL, NULL }, /* Nx */          { NULL, NULL },                         /* Ox */
         { NULL, NULL }, /* Ox */          { NULL, NULL },                         /* Pc */
         { NULL, NULL }, /* Pc */          { NULL, NULL },                         /* Pf */
         { NULL, NULL }, /* Pf */          { NULL, NULL },                         /* Po */
         { NULL, NULL }, /* Po */          { NULL, posts_wline },                  /* Pq */
         { NULL, posts_wline }, /* Pq */          { NULL, NULL },                         /* Qc */
         { NULL, NULL }, /* Qc */          { NULL, posts_wline },                  /* Ql */
         { NULL, posts_wline }, /* Ql */          { NULL, NULL },                         /* Qo */
         { NULL, NULL }, /* Qo */          { NULL, posts_wline },                  /* Qq */
         { NULL, posts_wline }, /* Qq */          { NULL, NULL },                         /* Re */
         { NULL, NULL }, /* Re */          { NULL, posts_rs },                     /* Rs */
         { NULL, posts_rs }, /* Rs */          { NULL, NULL },                         /* Sc */
         { NULL, NULL }, /* Sc */          { NULL, NULL },                         /* So */
         { NULL, NULL }, /* So */          { NULL, posts_wline },                  /* Sq */
         { NULL, posts_wline }, /* Sq */          { NULL, posts_bool },                   /* Sm */
         { NULL, posts_bool }, /* Sm */          { NULL, posts_text },                   /* Sx */
         { NULL, posts_text }, /* Sx */          { NULL, posts_text },                   /* Sy */
         { NULL, posts_text }, /* Sy */          { NULL, posts_text },                   /* Tn */
         { NULL, posts_text }, /* Tn */          { NULL, NULL },                         /* Ux */
         { NULL, NULL }, /* Ux */          { NULL, NULL },                         /* Xc */
         { NULL, NULL }, /* Xc */          { NULL, NULL },                         /* Xo */
         { NULL, NULL }, /* Xo */          { NULL, posts_fo },                     /* Fo */
         { NULL, posts_fo }, /* Fo */          { NULL, NULL },                         /* Fc */
         { NULL, NULL }, /* Fc */          { NULL, NULL },                         /* Oo */
         { NULL, NULL }, /* Oo */          { NULL, NULL },                         /* Oc */
         { NULL, NULL }, /* Oc */          { NULL, posts_bk },                     /* Bk */
         { NULL, posts_bk }, /* Bk */          { NULL, NULL },                         /* Ek */
         { NULL, NULL }, /* Ek */          { NULL, posts_notext },                 /* Bt */
         { NULL, posts_notext }, /* Bt */          { NULL, NULL },                         /* Hf */
         { NULL, NULL }, /* Hf */          { NULL, NULL },                         /* Fr */
         { NULL, NULL }, /* Fr */          { NULL, posts_notext },                 /* Ud */
         { NULL, posts_notext }, /* Ud */  
 };  };
   
   
 static int  static inline int
 post_check_children_count(struct mdoc *mdoc)  warn_count(struct mdoc *m, const char *k,
                   int want, const char *v, int has)
 {  {
         struct mdoc_node *n;  
           return(mdoc_warn(m, WARN_SYNTAX, "suggests %s %d %s "
                                   "(has %d)", v, want, k, has));
   }
   
   
   static inline int
   err_count(struct mdoc *m, const char *k,
                   int want, const char *v, int has)
   {
   
           return(mdoc_err(m, "requires %s %d %s (has %d)",
                                   v, want, k, has));
   }
   
   
   static inline int
   count_child(struct mdoc *mdoc)
   {
         int               i;          int               i;
           struct mdoc_node *n;
   
         for (i = 0, n = mdoc->last->child; n; n = n->next, i++)          for (i = 0, n = mdoc->last->child; n; n = n->next, i++)
                 /* Do nothing */ ;                  /* Do nothing */ ;
Line 269  post_check_children_count(struct mdoc *mdoc)
Line 296  post_check_children_count(struct mdoc *mdoc)
   
   
 static int  static int
 post_check_children_wgt(struct mdoc *mdoc, const char *p, int sz)  warn_child_gt(struct mdoc *mdoc, const char *p, int sz)
 {  {
         int               i;          int               i;
   
         if ((i = post_check_children_count(mdoc)) > sz)          if ((i = count_child(mdoc)) > sz)
                 return(1);                  return(1);
         return(mdoc_warn(mdoc, WARN_SYNTAX, "macro suggests more "          return(warn_count(mdoc, ">", sz, p, i));
                                 "than %d %s (has %d)", sz, p, i));  
 }  }
   
   
 static int  static int
 post_check_children_gt(struct mdoc *mdoc, const char *p, int sz)  err_child_gt(struct mdoc *mdoc, const char *p, int sz)
 {  {
         int               i;          int               i;
   
         if ((i = post_check_children_count(mdoc)) > sz)          if ((i = count_child(mdoc)) > sz)
                 return(1);                  return(1);
         return(mdoc_err(mdoc, "macro requires more than %d "          return(err_count(mdoc, ">", sz, p, i));
                                 "%s (has %d)", sz, p, i));  
 }  }
   
   
 static int  static int
 post_check_children_weq(struct mdoc *mdoc, const char *p, int sz)  warn_child_eq(struct mdoc *mdoc, const char *p, int sz)
 {  {
         int               i;          int               i;
   
         if ((i = post_check_children_count(mdoc)) == sz)          if ((i = count_child(mdoc)) == sz)
                 return(1);                  return(1);
         return(mdoc_warn(mdoc, WARN_SYNTAX, "macro suggests %d "          return(warn_count(mdoc, "==", sz, p, i));
                                 "%s (has %d)", sz, p, i));  
 }  }
   
   
 static int  static int
 post_check_children_eq(struct mdoc *mdoc, const char *p, int sz)  err_child_eq(struct mdoc *mdoc, const char *p, int sz)
 {  {
         int               i;          int               i;
   
         if ((i = post_check_children_count(mdoc)) == sz)          if ((i = count_child(mdoc)) == sz)
                 return(1);                  return(1);
         return(mdoc_err(mdoc, "macro requires %d %s "          return(err_count(mdoc, "==", sz, p, i));
                                 "(have %d)", sz, p, i));  
 }  }
   
   
 static int  static int
 post_check_children_lt(struct mdoc *mdoc, const char *p, int sz)  err_child_lt(struct mdoc *mdoc, const char *p, int sz)
 {  {
         int               i;          int               i;
   
         if ((i = post_check_children_count(mdoc)) < sz)          if ((i = count_child(mdoc)) < sz)
                 return(1);                  return(1);
         return(mdoc_err(mdoc, "macro requires less than %d "          return(err_count(mdoc, "<", sz, p, i));
                                 "%s (have %d)", sz, p, i));  
 }  }
   
   
 static int  static int
 pre_check_stdarg(struct mdoc *mdoc, struct mdoc_node *node)  check_stdarg(struct mdoc *mdoc, struct mdoc_node *node)
 {  {
   
         if (1 == node->data.elem.argc &&          if (MDOC_Std == node->data.elem.argv[0].arg &&
                         MDOC_Std == node->data.elem.argv[0].arg)                          1 == node->data.elem.argc)
                 return(1);                  return(1);
   
         return(mdoc_nwarn(mdoc, node, WARN_COMPAT,          return(mdoc_nwarn(mdoc, node, WARN_COMPAT,
                                 "macro suggests single `%s' argument",                                  "macro suggests single `%s' argument",
                                 mdoc_argnames[MDOC_Std]));                                  mdoc_argnames[MDOC_Std]));
Line 342  pre_check_stdarg(struct mdoc *mdoc, struct mdoc_node *
Line 365  pre_check_stdarg(struct mdoc *mdoc, struct mdoc_node *
   
   
 static int  static int
 pre_check_msecs(struct mdoc *mdoc, struct mdoc_node *node,  check_msec(struct mdoc *mdoc, struct mdoc_node *node,
                 int sz, enum mdoc_msec *msecs)                  int sz, enum mdoc_msec *msecs)
 {  {
         int              i;          int              i;
Line 356  pre_check_msecs(struct mdoc *mdoc, struct mdoc_node *n
Line 379  pre_check_msecs(struct mdoc *mdoc, struct mdoc_node *n
   
   
 static int  static int
 pre_check_parent(struct mdoc *mdoc, struct mdoc_node *node,  check_parent(struct mdoc *mdoc, struct mdoc_node *n,
                 int tok, enum mdoc_type type)                  int tok, enum mdoc_type t)
 {  {
   
         if (type != node->parent->type)          assert(n->parent);
                 return(mdoc_nerr(mdoc, node, "invalid macro parent class %s, expected %s",          if ((MDOC_ROOT == t || tok == n->parent->tok) &&
                                         mdoc_type2a(node->parent->type),                          (t == n->parent->type))
                                         mdoc_type2a(type)));                  return(1);
         if (MDOC_ROOT != type && tok != node->parent->tok)  
                 return(mdoc_nerr(mdoc, node, "invalid macro parent `%s', expected `%s'",          return(mdoc_nerr(mdoc, n, "require parent %s (have %s)",
                                         mdoc_macronames[node->parent->tok],                          MDOC_ROOT == t ? "<root>" :
                                         mdoc_macronames[tok]));                          mdoc_macronames[tok],
         return(1);                          MDOC_ROOT == n->parent->type ? "<root>" :
                           mdoc_macronames[n->parent->type]));
 }  }
   
   
Line 378  bwarn_ge1(struct mdoc *mdoc)
Line 402  bwarn_ge1(struct mdoc *mdoc)
   
         if (MDOC_BODY != mdoc->last->type)          if (MDOC_BODY != mdoc->last->type)
                 return(1);                  return(1);
         return(post_check_children_wgt(mdoc, "body children", 0));          return(warn_child_gt(mdoc, "multi-line parameters", 0));
 }  }
   
   
Line 387  ewarn_eq1(struct mdoc *mdoc)
Line 411  ewarn_eq1(struct mdoc *mdoc)
 {  {
   
         assert(MDOC_ELEM == mdoc->last->type);          assert(MDOC_ELEM == mdoc->last->type);
         return(post_check_children_weq(mdoc, "parameters", 1));          return(warn_child_eq(mdoc, "line parameters", 1));
 }  }
   
   
Line 396  ewarn_eq0(struct mdoc *mdoc)
Line 420  ewarn_eq0(struct mdoc *mdoc)
 {  {
   
         assert(MDOC_ELEM == mdoc->last->type);          assert(MDOC_ELEM == mdoc->last->type);
         return(post_check_children_weq(mdoc, "parameters", 0));          return(warn_child_eq(mdoc, "line parameters", 0));
 }  }
   
   
Line 405  ewarn_ge1(struct mdoc *mdoc)
Line 429  ewarn_ge1(struct mdoc *mdoc)
 {  {
   
         assert(MDOC_ELEM == mdoc->last->type);          assert(MDOC_ELEM == mdoc->last->type);
         return(post_check_children_wgt(mdoc, "parameters", 0));          return(warn_child_gt(mdoc, "line parameters", 0));
 }  }
   
   
Line 414  eerr_eq1(struct mdoc *mdoc)
Line 438  eerr_eq1(struct mdoc *mdoc)
 {  {
   
         assert(MDOC_ELEM == mdoc->last->type);          assert(MDOC_ELEM == mdoc->last->type);
         return(post_check_children_eq(mdoc, "parameters", 1));          return(err_child_eq(mdoc, "line parameters", 1));
 }  }
   
   
Line 423  eerr_le2(struct mdoc *mdoc)
Line 447  eerr_le2(struct mdoc *mdoc)
 {  {
   
         assert(MDOC_ELEM == mdoc->last->type);          assert(MDOC_ELEM == mdoc->last->type);
         return(post_check_children_lt(mdoc, "parameters", 3));          return(err_child_lt(mdoc, "line parameters", 3));
 }  }
   
   
Line 432  eerr_le1(struct mdoc *mdoc)
Line 456  eerr_le1(struct mdoc *mdoc)
 {  {
   
         assert(MDOC_ELEM == mdoc->last->type);          assert(MDOC_ELEM == mdoc->last->type);
         return(post_check_children_lt(mdoc, "parameters", 2));          return(err_child_lt(mdoc, "line parameters", 2));
 }  }
   
   
Line 441  eerr_eq0(struct mdoc *mdoc)
Line 465  eerr_eq0(struct mdoc *mdoc)
 {  {
   
         assert(MDOC_ELEM == mdoc->last->type);          assert(MDOC_ELEM == mdoc->last->type);
         return(post_check_children_eq(mdoc, "parameters", 0));          return(err_child_eq(mdoc, "line parameters", 0));
 }  }
   
   
Line 450  eerr_ge1(struct mdoc *mdoc)
Line 474  eerr_ge1(struct mdoc *mdoc)
 {  {
   
         assert(MDOC_ELEM == mdoc->last->type);          assert(MDOC_ELEM == mdoc->last->type);
         return(post_check_children_gt(mdoc, "parameters", 0));          return(err_child_gt(mdoc, "line parameters", 0));
 }  }
   
   
Line 460  herr_eq0(struct mdoc *mdoc)
Line 484  herr_eq0(struct mdoc *mdoc)
   
         if (MDOC_HEAD != mdoc->last->type)          if (MDOC_HEAD != mdoc->last->type)
                 return(1);                  return(1);
         return(post_check_children_eq(mdoc, "parameters", 0));          return(err_child_eq(mdoc, "line parameters", 0));
 }  }
   
   
Line 469  herr_le1(struct mdoc *mdoc)
Line 493  herr_le1(struct mdoc *mdoc)
 {  {
         if (MDOC_HEAD != mdoc->last->type)          if (MDOC_HEAD != mdoc->last->type)
                 return(1);                  return(1);
         return(post_check_children_lt(mdoc, "parameters", 2));          return(err_child_lt(mdoc, "line parameters", 2));
 }  }
   
   
Line 479  herr_ge1(struct mdoc *mdoc)
Line 503  herr_ge1(struct mdoc *mdoc)
   
         if (MDOC_HEAD != mdoc->last->type)          if (MDOC_HEAD != mdoc->last->type)
                 return(1);                  return(1);
         return(post_check_children_gt(mdoc, "parameters", 0));          return(err_child_gt(mdoc, "line parameters", 0));
 }  }
   
   
Line 613  pre_ss(struct mdoc *mdoc, struct mdoc_node *node)
Line 637  pre_ss(struct mdoc *mdoc, struct mdoc_node *node)
   
         if (MDOC_BLOCK != node->type)          if (MDOC_BLOCK != node->type)
                 return(1);                  return(1);
         return(pre_check_parent(mdoc, node, MDOC_Sh, MDOC_BODY));          return(check_parent(mdoc, node, MDOC_Sh, MDOC_BODY));
 }  }
   
   
Line 623  pre_sh(struct mdoc *mdoc, struct mdoc_node *node)
Line 647  pre_sh(struct mdoc *mdoc, struct mdoc_node *node)
   
         if (MDOC_BLOCK != node->type)          if (MDOC_BLOCK != node->type)
                 return(1);                  return(1);
         return(pre_check_parent(mdoc, node, -1, MDOC_ROOT));          return(check_parent(mdoc, node, -1, MDOC_ROOT));
 }  }
   
   
Line 661  pre_rv(struct mdoc *mdoc, struct mdoc_node *node)
Line 685  pre_rv(struct mdoc *mdoc, struct mdoc_node *node)
   
         msecs[0] = MSEC_2;          msecs[0] = MSEC_2;
         msecs[1] = MSEC_3;          msecs[1] = MSEC_3;
         if ( ! pre_check_msecs(mdoc, node, 2, msecs))          if ( ! check_msec(mdoc, node, 2, msecs))
                 return(0);                  return(0);
         return(pre_check_stdarg(mdoc, node));          return(check_stdarg(mdoc, node));
 }  }
   
   
Line 678  pre_ex(struct mdoc *mdoc, struct mdoc_node *node)
Line 702  pre_ex(struct mdoc *mdoc, struct mdoc_node *node)
         msecs[0] = MSEC_1;          msecs[0] = MSEC_1;
         msecs[1] = MSEC_6;          msecs[1] = MSEC_6;
         msecs[2] = MSEC_8;          msecs[2] = MSEC_8;
         if ( ! pre_check_msecs(mdoc, node, 3, msecs))          if ( ! check_msec(mdoc, node, 3, msecs))
                 return(0);                  return(0);
         return(pre_check_stdarg(mdoc, node));          return(check_stdarg(mdoc, node));
 }  }
   
   
Line 690  pre_er(struct mdoc *mdoc, struct mdoc_node *node)
Line 714  pre_er(struct mdoc *mdoc, struct mdoc_node *node)
         enum mdoc_msec   msecs[1];          enum mdoc_msec   msecs[1];
   
         msecs[0] = MSEC_2;          msecs[0] = MSEC_2;
         return(pre_check_msecs(mdoc, node, 1, msecs));          return(check_msec(mdoc, node, 1, msecs));
 }  }
   
   
Line 700  pre_cd(struct mdoc *mdoc, struct mdoc_node *node)
Line 724  pre_cd(struct mdoc *mdoc, struct mdoc_node *node)
         enum mdoc_msec   msecs[1];          enum mdoc_msec   msecs[1];
   
         msecs[0] = MSEC_4;          msecs[0] = MSEC_4;
         return(pre_check_msecs(mdoc, node, 1, msecs));          return(check_msec(mdoc, node, 1, msecs));
 }  }
   
   
Line 713  pre_it(struct mdoc *mdoc, struct mdoc_node *node)
Line 737  pre_it(struct mdoc *mdoc, struct mdoc_node *node)
   
         if (MDOC_BLOCK != node->type)          if (MDOC_BLOCK != node->type)
                 return(1);                  return(1);
         return(pre_check_parent(mdoc, node, MDOC_Bl, MDOC_BODY));          return(check_parent(mdoc, node, MDOC_Bl, MDOC_BODY));
 }  }
   
   
Line 1102  post_sh_body(struct mdoc *mdoc)
Line 1126  post_sh_body(struct mdoc *mdoc)
         struct mdoc_node *n;          struct mdoc_node *n;
   
         assert(MDOC_Sh == mdoc->last->tok);          assert(MDOC_Sh == mdoc->last->tok);
           assert(MDOC_BODY == mdoc->last->type);
         if (SEC_NAME != mdoc->lastnamed)          if (SEC_NAME != mdoc->lastnamed)
                 return(1);                  return(1);
   
           /*
            * Warn if the NAME section doesn't contain the `Nm' and `Nd'
            * macros (can have multiple `Nm' and one `Nd').  Note that the
            * children of the BODY declaration can also be "text".
            */
   
         if (NULL == (n = mdoc->last->child))          if (NULL == (n = mdoc->last->child))
                 return(mdoc_err(mdoc, "section NAME must contain %s as the first body child", mdoc_macronames[MDOC_Nm]));                  return(mdoc_warn(mdoc, WARN_COMPAT, "section NAME "
         if (MDOC_ELEM != n->type || MDOC_Nm != n->tok)                                          "should contain %s and %s",
                 return(mdoc_err(mdoc, "section NAME must contain %s as the first body child", mdoc_macronames[MDOC_Nm]));                                          mdoc_macronames[MDOC_Nm],
         if (NULL == (n = n->next))                                          mdoc_macronames[MDOC_Nd]));
                 return(mdoc_err(mdoc, "section NAME must contain %s as the second body child", mdoc_macronames[MDOC_Nd]));  
         if (MDOC_ELEM != n->type || MDOC_Nd != n->tok)          for ( ; n && n->next; n = n->next) {
                 return(mdoc_err(mdoc, "section NAME must contain %s as the second body child", mdoc_macronames[MDOC_Nd]));                  if (MDOC_ELEM == n->type && MDOC_Nm == n->tok)
         if (NULL == (n = n->next))                          continue;
                   if (MDOC_TEXT == n->type)
                           continue;
                   if ( ! (mdoc_nwarn(mdoc, n, WARN_COMPAT, "section "
                                           "NAME should contain %s as "
                                           "initial body child",
                                           mdoc_macronames[MDOC_Nm])))
                           return(0);
           }
   
           if (MDOC_ELEM == n->type && MDOC_Nd == n->tok)
                 return(1);                  return(1);
   
         return(mdoc_warn(mdoc, WARN_SYNTAX, "section NAME usually limited to %s and %s body children",          return(mdoc_warn(mdoc, WARN_COMPAT, "section NAME should "
                                 mdoc_macronames[MDOC_Nm], mdoc_macronames[MDOC_Nd]));                                  "contain %s as the last child",
                                   mdoc_macronames[MDOC_Nd]));
 }  }
   
   

Legend:
Removed from v.1.50  
changed lines
  Added in v.1.51

CVSweb