[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.78 and 1.79

version 1.78, 2010/05/15 16:24:38 version 1.79, 2010/05/17 22:11:42
Line 26 
Line 26 
 #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  #include <string.h>
   
   #include "mandoc.h"
 #include "libmdoc.h"  #include "libmdoc.h"
 #include "libmandoc.h"  #include "libmandoc.h"
   
Line 321  warn_count(struct mdoc *m, const char *k, 
Line 322  warn_count(struct mdoc *m, const char *k, 
                 int want, const char *v, int has)                  int want, const char *v, int has)
 {  {
   
         return(mdoc_vwarn(m, m->last->line, m->last->pos,          return(mdoc_vmsg(m, MANDOCERR_ARGCOUNT,
                 "suggests %s %s %d (has %d)", v, k, want, has));                                  m->last->line, m->last->pos,
                                   "%s %s %d (have %d)", v, k, want, has));
 }  }
   
   
Line 331  err_count(struct mdoc *m, const char *k,
Line 333  err_count(struct mdoc *m, const char *k,
                 int want, const char *v, int has)                  int want, const char *v, int has)
 {  {
   
         return(mdoc_verr(m, m->last->line, m->last->pos,          mdoc_vmsg(m, MANDOCERR_SYNTARGCOUNT,
                 "requires %s %s %d (has %d)", v, k, want, has));                          m->last->line, m->last->pos,
                           "%s %s %d (have %d)",
                           v, k, want, has);
           return(0);
 }  }
   
   
Line 405  check_stdarg(PRE_ARGS)
Line 410  check_stdarg(PRE_ARGS)
         if (n->args && 1 == n->args->argc)          if (n->args && 1 == n->args->argc)
                 if (MDOC_Std == n->args->argv[0].arg)                  if (MDOC_Std == n->args->argv[0].arg)
                         return(1);                          return(1);
         return(mdoc_nwarn(mdoc, n, EARGVAL));          return(mdoc_nmsg(mdoc, n, MANDOCERR_NOARGV));
 }  }
   
   
Line 437  check_argv(struct mdoc *m, const struct mdoc_node *n, 
Line 442  check_argv(struct mdoc *m, const struct mdoc_node *n, 
                         return(0);                          return(0);
   
         if (MDOC_Std == v->arg) {          if (MDOC_Std == v->arg) {
                 /* `Nm' name must be set. */  
                 if (v->sz || m->meta.name)                  if (v->sz || m->meta.name)
                         return(1);                          return(1);
                 return(mdoc_nerr(m, n, ENAME));                  if ( ! mdoc_nmsg(m, n, MANDOCERR_NONAME))
                           return(0);
         }          }
   
         return(1);          return(1);
Line 455  check_text(struct mdoc *mdoc, int line, int pos, const
Line 460  check_text(struct mdoc *mdoc, int line, int pos, const
         for ( ; *p; p++, pos++) {          for ( ; *p; p++, pos++) {
                 if ('\t' == *p) {                  if ('\t' == *p) {
                         if ( ! (MDOC_LITERAL & mdoc->flags))                          if ( ! (MDOC_LITERAL & mdoc->flags))
                                 if ( ! mdoc_pwarn(mdoc, line, pos, EPRINT))                                  if ( ! mdoc_pmsg(mdoc, line, pos, MANDOCERR_BADCHAR))
                                         return(0);                                          return(0);
                 } else if ( ! isprint((u_char)*p))                  } else if ( ! isprint((u_char)*p))
                         if ( ! mdoc_pwarn(mdoc, line, pos, EPRINT))                          if ( ! mdoc_pmsg(mdoc, line, pos, MANDOCERR_BADCHAR))
                                 return(0);                                  return(0);
   
                 if ('\\' != *p)                  if ('\\' != *p)
Line 470  check_text(struct mdoc *mdoc, int line, int pos, const
Line 475  check_text(struct mdoc *mdoc, int line, int pos, const
                         pos += c - 1;                          pos += c - 1;
                         continue;                          continue;
                 }                  }
                 if ( ! (MDOC_IGN_ESCAPE & mdoc->pflags))  
                         return(mdoc_perr(mdoc, line, pos, EESCAPE));                  c = mdoc_pmsg(mdoc, line, pos, MANDOCERR_BADESCAPE);
                 if ( ! mdoc_pwarn(mdoc, line, pos, EESCAPE))                  if ( ! (MDOC_IGN_ESCAPE & mdoc->pflags) && ! c)
                         return(0);                          return(c);
         }          }
   
         return(1);          return(1);
Line 491  check_parent(PRE_ARGS, enum mdoct tok, enum mdoc_type 
Line 496  check_parent(PRE_ARGS, enum mdoct tok, enum mdoc_type 
                         (t == n->parent->type))                          (t == n->parent->type))
                 return(1);                  return(1);
   
         return(mdoc_verr(mdoc, n->line, n->pos, "require parent %s",          mdoc_vmsg(mdoc, MANDOCERR_SYNTCHILD,
                 MDOC_ROOT == t ? "<root>" : mdoc_macronames[tok]));                                  n->line, n->pos, "want parent %s",
                                   MDOC_ROOT == t ? "<root>" :
                                           mdoc_macronames[tok]);
           return(0);
 }  }
   
   
Line 515  pre_display(PRE_ARGS)
Line 523  pre_display(PRE_ARGS)
         if (NULL == node)          if (NULL == node)
                 return(1);                  return(1);
   
         return(mdoc_nerr(mdoc, n, ENESTDISP));          mdoc_nmsg(mdoc, n, MANDOCERR_NESTEDDISP);
           return(0);
 }  }
   
   
Line 526  pre_bl(PRE_ARGS)
Line 535  pre_bl(PRE_ARGS)
   
         if (MDOC_BLOCK != n->type)          if (MDOC_BLOCK != n->type)
                 return(1);                  return(1);
         if (NULL == n->args)          if (NULL == n->args) {
                 return(mdoc_nerr(mdoc, n, ELISTTYPE));                  mdoc_nmsg(mdoc, n, MANDOCERR_LISTTYPE);
                   return(0);
           }
   
         /* Make sure that only one type of list is specified.  */          /* Make sure that only one type of list is specified.  */
   
Line 567  pre_bl(PRE_ARGS)
Line 578  pre_bl(PRE_ARGS)
                          * FIXME: this should occur in mdoc_action.c.                           * FIXME: this should occur in mdoc_action.c.
                          */                           */
                         if (type >= 0) {                          if (type >= 0) {
                                 if ( ! mdoc_nwarn(mdoc, n, EMULTILIST))                                  if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_LISTREP))
                                         return(0);                                          return(0);
                                 mdoc_argn_free(n->args, pos);                                  mdoc_argn_free(n->args, pos);
                                 break;                                  break;
Line 575  pre_bl(PRE_ARGS)
Line 586  pre_bl(PRE_ARGS)
                         type = n->args->argv[pos].arg;                          type = n->args->argv[pos].arg;
                         break;                          break;
                 case (MDOC_Compact):                  case (MDOC_Compact):
                         if (type < 0 && ! mdoc_nwarn(mdoc, n, ENOTYPE))                          if (type < 0 && ! mdoc_nmsg(mdoc, n, MANDOCERR_LISTFIRST))
                                 return(0);                                  return(0);
                         break;                          break;
                 case (MDOC_Width):                  case (MDOC_Width):
                         if (width >= 0)                          if (width >= 0)
                                 return(mdoc_nerr(mdoc, n, EARGREP));                                  if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_ARGVREP))
                         if (type < 0 && ! mdoc_nwarn(mdoc, n, ENOTYPE))                                          return(0);
                           if (type < 0 && ! mdoc_nmsg(mdoc, n, MANDOCERR_LISTFIRST))
                                 return(0);                                  return(0);
                         width = n->args->argv[pos].arg;                          width = n->args->argv[pos].arg;
                         break;                          break;
                 case (MDOC_Offset):                  case (MDOC_Offset):
                         if (offset >= 0)                          if (offset >= 0)
                                 return(mdoc_nerr(mdoc, n, EARGREP));                                  if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_ARGVREP))
                         if (type < 0 && ! mdoc_nwarn(mdoc, n, ENOTYPE))                                          return(0);
                           if (type < 0 && ! mdoc_nmsg(mdoc, n, MANDOCERR_LISTFIRST))
                                 return(0);                                  return(0);
                         offset = n->args->argv[pos].arg;                          offset = n->args->argv[pos].arg;
                         break;                          break;
Line 596  pre_bl(PRE_ARGS)
Line 609  pre_bl(PRE_ARGS)
                         break;                          break;
                 }                  }
   
         if (type < 0)          if (type < 0) {
                 return(mdoc_nerr(mdoc, n, ELISTTYPE));                  mdoc_nmsg(mdoc, n, MANDOCERR_LISTTYPE);
                   return(0);
           }
   
         /*          /*
          * Validate the width field.  Some list types don't need width           * Validate the width field.  Some list types don't need width
Line 607  pre_bl(PRE_ARGS)
Line 622  pre_bl(PRE_ARGS)
   
         switch (type) {          switch (type) {
         case (MDOC_Tag):          case (MDOC_Tag):
                 if (width < 0 && ! mdoc_nwarn(mdoc, n, EMISSWIDTH))                  if (width < 0 && ! mdoc_nmsg(mdoc, n, MANDOCERR_NOWIDTHARG))
                         return(0);                          return(0);
                 break;                  break;
         case (MDOC_Column):          case (MDOC_Column):
Line 619  pre_bl(PRE_ARGS)
Line 634  pre_bl(PRE_ARGS)
         case (MDOC_Inset):          case (MDOC_Inset):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Item):          case (MDOC_Item):
                 if (width >= 0 && ! mdoc_nwarn(mdoc, n, ENOWIDTH))                  if (width >= 0 && ! mdoc_nmsg(mdoc, n, MANDOCERR_WIDTHARG))
                         return(0);                          return(0);
                 break;                  break;
         default:          default:
Line 637  pre_bd(PRE_ARGS)
Line 652  pre_bd(PRE_ARGS)
   
         if (MDOC_BLOCK != n->type)          if (MDOC_BLOCK != n->type)
                 return(1);                  return(1);
         if (NULL == n->args)          if (NULL == n->args) {
                 return(mdoc_nerr(mdoc, n, EDISPTYPE));                  mdoc_nmsg(mdoc, n, MANDOCERR_DISPTYPE);
                   return(0);
           }
   
         /* Make sure that only one type of display is specified.  */          /* Make sure that only one type of display is specified.  */
   
Line 657  pre_bd(PRE_ARGS)
Line 674  pre_bd(PRE_ARGS)
                 case (MDOC_Literal):                  case (MDOC_Literal):
                         if (0 == type++)                          if (0 == type++)
                                 break;                                  break;
                         return(mdoc_nerr(mdoc, n, EMULTIDISP));                          if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_DISPREP))
                                   return(0);
                           break;
                 default:                  default:
                         break;                          break;
                 }                  }
   
         if (type)          if (type)
                 return(1);                  return(1);
         return(mdoc_nerr(mdoc, n, EDISPTYPE));          mdoc_nmsg(mdoc, n, MANDOCERR_DISPTYPE);
           return(0);
 }  }
   
   
Line 694  pre_it(PRE_ARGS)
Line 714  pre_it(PRE_ARGS)
   
         if (MDOC_BLOCK != n->type)          if (MDOC_BLOCK != n->type)
                 return(1);                  return(1);
           /*
            * FIXME: this can probably be lifted if we make the It into
            * something else on-the-fly?
            */
         return(check_parent(mdoc, n, MDOC_Bl, MDOC_BODY));          return(check_parent(mdoc, n, MDOC_Bl, MDOC_BODY));
 }  }
   
Line 704  pre_an(PRE_ARGS)
Line 728  pre_an(PRE_ARGS)
   
         if (NULL == n->args || 1 == n->args->argc)          if (NULL == n->args || 1 == n->args->argc)
                 return(1);                  return(1);
         return(mdoc_verr(mdoc, n->line, n->pos,          mdoc_vmsg(mdoc, MANDOCERR_SYNTARGCOUNT,
                                 "only one argument allowed"));                                  n->line, n->pos,
                                   "line arguments == 1 (have %d)",
                                   n->args->argc);
           return(0);
 }  }
   
   
Line 724  pre_dt(PRE_ARGS)
Line 751  pre_dt(PRE_ARGS)
         /* FIXME: make sure is capitalised. */          /* FIXME: make sure is capitalised. */
   
         if (0 == mdoc->meta.date || mdoc->meta.os)          if (0 == mdoc->meta.date || mdoc->meta.os)
                 if ( ! mdoc_nwarn(mdoc, n, EPROLOOO))                  if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_PROLOGOOO))
                         return(0);                          return(0);
         if (mdoc->meta.title)          if (mdoc->meta.title)
                 if ( ! mdoc_nwarn(mdoc, n, EPROLREP))                  if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_PROLOGREP))
                         return(0);                          return(0);
         return(1);          return(1);
 }  }
Line 738  pre_os(PRE_ARGS)
Line 765  pre_os(PRE_ARGS)
 {  {
   
         if (NULL == mdoc->meta.title || 0 == mdoc->meta.date)          if (NULL == mdoc->meta.title || 0 == mdoc->meta.date)
                 if ( ! mdoc_nwarn(mdoc, n, EPROLOOO))                  if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_PROLOGOOO))
                         return(0);                          return(0);
         if (mdoc->meta.os)          if (mdoc->meta.os)
                 if ( ! mdoc_nwarn(mdoc, n, EPROLREP))                  if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_PROLOGREP))
                         return(0);                          return(0);
         return(1);          return(1);
 }  }
Line 752  pre_dd(PRE_ARGS)
Line 779  pre_dd(PRE_ARGS)
 {  {
   
         if (mdoc->meta.title || mdoc->meta.os)          if (mdoc->meta.title || mdoc->meta.os)
                 if ( ! mdoc_nwarn(mdoc, n, EPROLOOO))                  if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_PROLOGOOO))
                         return(0);                          return(0);
         if (mdoc->meta.date)          if (mdoc->meta.date)
                 if ( ! mdoc_nwarn(mdoc, n, EPROLREP))                  if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_PROLOGREP))
                         return(0);                          return(0);
         return(1);          return(1);
 }  }
Line 772  post_bf(POST_ARGS)
Line 799  post_bf(POST_ARGS)
   
         head = mdoc->last->head;          head = mdoc->last->head;
   
         if (mdoc->last->args && head->child)          if (mdoc->last->args && head->child) {
                 return(mdoc_nerr(mdoc, mdoc->last, ELINE));                  /* FIXME: this should provide a default. */
         else if (mdoc->last->args)                  mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_SYNTARGVCOUNT);
                   return(0);
           } else if (mdoc->last->args)
                 return(1);                  return(1);
   
         if (NULL == head->child || MDOC_TEXT != head->child->type)          if (NULL == head->child || MDOC_TEXT != head->child->type) {
                 return(mdoc_nerr(mdoc, mdoc->last, ELINE));                  /* FIXME: this should provide a default. */
                   mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_SYNTARGVCOUNT);
                   return(0);
           }
   
         p = head->child->string;          p = head->child->string;
   
Line 789  post_bf(POST_ARGS)
Line 821  post_bf(POST_ARGS)
         else if (0 == strcmp(p, "Sy"))          else if (0 == strcmp(p, "Sy"))
                 return(1);                  return(1);
   
         return(mdoc_nerr(mdoc, head, EFONT));          mdoc_nmsg(mdoc, head, MANDOCERR_FONTTYPE);
           return(0);
 }  }
   
   
Line 799  post_lb(POST_ARGS)
Line 832  post_lb(POST_ARGS)
   
         if (mdoc_a2lib(mdoc->last->child->string))          if (mdoc_a2lib(mdoc->last->child->string))
                 return(1);                  return(1);
         return(mdoc_nwarn(mdoc, mdoc->last, ELIB));          return(mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_BADLIB));
 }  }
   
   
Line 822  post_vt(POST_ARGS)
Line 855  post_vt(POST_ARGS)
   
         for (n = mdoc->last->child; n; n = n->next)          for (n = mdoc->last->child; n; n = n->next)
                 if (MDOC_TEXT != n->type)                  if (MDOC_TEXT != n->type)
                         if ( ! mdoc_nwarn(mdoc, n, EBADCHILD))                          if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_CHILD))
                                 return(0);                                  return(0);
   
         return(1);          return(1);
Line 837  post_nm(POST_ARGS)
Line 870  post_nm(POST_ARGS)
                 return(1);                  return(1);
         if (mdoc->meta.name)          if (mdoc->meta.name)
                 return(1);                  return(1);
         return(mdoc_nerr(mdoc, mdoc->last, ENAME));          return(mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NONAME));
 }  }
   
   
Line 847  post_at(POST_ARGS)
Line 880  post_at(POST_ARGS)
   
         if (NULL == mdoc->last->child)          if (NULL == mdoc->last->child)
                 return(1);                  return(1);
         if (MDOC_TEXT != mdoc->last->child->type)          assert(MDOC_TEXT == mdoc->last->child->type);
                 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_nwarn(mdoc, mdoc->last, EATT));          return(mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_BADATT));
 }  }
   
   
Line 862  post_an(POST_ARGS)
Line 894  post_an(POST_ARGS)
         if (mdoc->last->args) {          if (mdoc->last->args) {
                 if (NULL == mdoc->last->child)                  if (NULL == mdoc->last->child)
                         return(1);                          return(1);
                 return(mdoc_nerr(mdoc, mdoc->last, ENOLINE));                  return(mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_ARGCOUNT));
         }          }
   
         if (mdoc->last->child)          if (mdoc->last->child)
                 return(1);                  return(1);
         return(mdoc_nerr(mdoc, mdoc->last, ELINE));          return(mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NOARGS));
 }  }
   
   
Line 881  post_it(POST_ARGS)
Line 913  post_it(POST_ARGS)
                 return(1);                  return(1);
   
         n = mdoc->last->parent->parent;          n = mdoc->last->parent->parent;
         if (NULL == n->args)          if (NULL == n->args) {
                 return(mdoc_nerr(mdoc, mdoc->last, ELISTTYPE));                  mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_LISTTYPE);
                   return(0);
           }
   
         /* Some types require block-head, some not. */          /* Some types require block-head, some not. */
   
Line 919  post_it(POST_ARGS)
Line 953  post_it(POST_ARGS)
                         break;                          break;
                 }                  }
   
         if (-1 == type)          if (-1 == type) {
                 return(mdoc_nerr(mdoc, mdoc->last, ELISTTYPE));                  mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_LISTTYPE);
                   return(0);
           }
   
         switch (type) {          switch (type) {
         case (MDOC_Tag):          case (MDOC_Tag):
                 if (NULL == mdoc->last->head->child)                  if (NULL == mdoc->last->head->child)
                         if ( ! mdoc_nwarn(mdoc, mdoc->last, ELINE))                          if ( ! mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NOARGS))
                                 return(0);                                  return(0);
                 break;                  break;
         case (MDOC_Hang):          case (MDOC_Hang):
Line 936  post_it(POST_ARGS)
Line 972  post_it(POST_ARGS)
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Diag):          case (MDOC_Diag):
                 if (NULL == mdoc->last->head->child)                  if (NULL == mdoc->last->head->child)
                         if ( ! mdoc_nwarn(mdoc, mdoc->last, ELINE))                          if ( ! mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NOARGS))
                                 return(0);                                  return(0);
                 if (NULL == mdoc->last->body->child)                  if (NULL == mdoc->last->body->child)
                         if ( ! mdoc_nwarn(mdoc, mdoc->last, EMULTILINE))                          if ( ! mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NOBODY))
                                 return(0);                                  return(0);
                 break;                  break;
         case (MDOC_Bullet):          case (MDOC_Bullet):
Line 952  post_it(POST_ARGS)
Line 988  post_it(POST_ARGS)
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Item):          case (MDOC_Item):
                 if (mdoc->last->head->child)                  if (mdoc->last->head->child)
                         if ( ! mdoc_nwarn(mdoc, mdoc->last, ENOLINE))                          if ( ! mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_ARGSLOST))
                                 return(0);                                  return(0);
                 if (NULL == mdoc->last->body->child)                  if (NULL == mdoc->last->body->child)
                         if ( ! mdoc_nwarn(mdoc, mdoc->last, EMULTILINE))                          if ( ! mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NOBODY))
                                 return(0);                                  return(0);
                 break;                  break;
         case (MDOC_Column):          case (MDOC_Column):
                 if (NULL == mdoc->last->head->child)                  if (NULL == mdoc->last->head->child)
                         if ( ! mdoc_nwarn(mdoc, mdoc->last, ELINE))                          if ( ! mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NOARGS))
                                 return(0);                                  return(0);
                 if (mdoc->last->body->child)                  if (mdoc->last->body->child)
                         if ( ! mdoc_nwarn(mdoc, mdoc->last, ENOMULTILINE))                          if ( ! mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_BODYLOST))
                                 return(0);                                  return(0);
                 c = mdoc->last->child;                  c = mdoc->last->child;
                 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) {                  if (i < cols) {
                         if ( ! mdoc_vwarn(mdoc, mdoc->last->line,                          if ( ! mdoc_vmsg(mdoc, MANDOCERR_ARGCOUNT,
                                         mdoc->last->pos, "column "                                          mdoc->last->line,
                                         "mismatch: have %d, want %d",                                          mdoc->last->pos,
                                         i, cols))                                          "columns == %d (have %d)",
                                           cols, i))
                                 return(0);                                  return(0);
                         break;                          break;
                 } else if (i == cols || i == cols + 1)                  } else if (i == cols || i == cols + 1)
                         break;                          break;
   
                 return(mdoc_verr(mdoc, mdoc->last->line,                  mdoc_vmsg(mdoc, MANDOCERR_SYNTARGCOUNT,
                                 mdoc->last->pos, "column mismatch: "                                  mdoc->last->line, mdoc->last->pos,
                                 "have %d, want %d", i, cols));                                  "columns == %d (have %d)", cols, i);
                   return(0);
         default:          default:
                 break;                  break;
         }          }
Line 1004  post_bl_head(POST_ARGS) 
Line 1042  post_bl_head(POST_ARGS) 
                 a = &n->args->argv[i];                  a = &n->args->argv[i];
                 if (a->arg == MDOC_Column) {                  if (a->arg == MDOC_Column) {
                         if (a->sz && mdoc->last->nchild)                          if (a->sz && mdoc->last->nchild)
                                 return(mdoc_nerr(mdoc, n, ECOLMIS));                                  return(mdoc_nmsg(mdoc, n, MANDOCERR_COLUMNS));
                         return(1);                          return(1);
                 }                  }
         }          }
Line 1039  post_bl(POST_ARGS)
Line 1077  post_bl(POST_ARGS)
                         continue;                          continue;
                 if (MDOC_Sm == n->tok)                  if (MDOC_Sm == n->tok)
                         continue;                          continue;
                 return(mdoc_nerr(mdoc, n, EBADCHILD));                  mdoc_nmsg(mdoc, n, MANDOCERR_SYNTCHILD);
                   return(0);
         }          }
   
         return(1);          return(1);
Line 1064  ebool(struct mdoc *mdoc)
Line 1103  ebool(struct mdoc *mdoc)
   
         if (NULL == n)          if (NULL == n)
                 return(1);                  return(1);
         return(mdoc_nerr(mdoc, n, EBOOL));          return(mdoc_nmsg(mdoc, n, MANDOCERR_BADBOOL));
 }  }
   
   
Line 1073  post_root(POST_ARGS)
Line 1112  post_root(POST_ARGS)
 {  {
   
         if (NULL == mdoc->first->child)          if (NULL == mdoc->first->child)
                 return(mdoc_nerr(mdoc, mdoc->first, ENODAT));                  mdoc_nmsg(mdoc, mdoc->first, MANDOCERR_NODOCBODY);
         if ( ! (MDOC_PBODY & mdoc->flags))          else if ( ! (MDOC_PBODY & mdoc->flags))
                 return(mdoc_nerr(mdoc, mdoc->first, ENOPROLOGUE));                  mdoc_nmsg(mdoc, mdoc->first, MANDOCERR_NODOCPROLOG);
           else if (MDOC_BLOCK != mdoc->first->child->type)
                   mdoc_nmsg(mdoc, mdoc->first, MANDOCERR_NODOCBODY);
           else if (MDOC_Sh != mdoc->first->child->tok)
                   mdoc_nmsg(mdoc, mdoc->first, MANDOCERR_NODOCBODY);
           else
                   return(1);
   
         if (MDOC_BLOCK != mdoc->first->child->type)          return(0);
                 return(mdoc_nerr(mdoc, mdoc->first, ENODAT));  
         if (MDOC_Sh != mdoc->first->child->tok)  
                 return(mdoc_nerr(mdoc, mdoc->first, ENODAT));  
   
         return(1);  
 }  }
   
   
Line 1092  post_st(POST_ARGS)
Line 1132  post_st(POST_ARGS)
   
         if (mdoc_a2st(mdoc->last->child->string))          if (mdoc_a2st(mdoc->last->child->string))
                 return(1);                  return(1);
         return(mdoc_nwarn(mdoc, mdoc->last, EBADSTAND));          return(mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_BADSTANDARD));
 }  }
   
   
Line 1135  post_rs(POST_ARGS)
Line 1175  post_rs(POST_ARGS)
                 case(MDOC__V):                  case(MDOC__V):
                         break;                          break;
                 default:                  default:
                         return(mdoc_nerr(mdoc, nn, EBADCHILD));                          mdoc_nmsg(mdoc, nn, MANDOCERR_SYNTCHILD);
                           return(0);
                 }                  }
   
         return(1);          return(1);
Line 1170  post_sh_body(POST_ARGS)
Line 1211  post_sh_body(POST_ARGS)
          */           */
   
         if (NULL == (n = mdoc->last->child))          if (NULL == (n = mdoc->last->child))
                 return(mdoc_nwarn(mdoc, mdoc->last, ENAMESECINC));                  return(mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_BADNAMESEC));
   
         for ( ; n && n->next; n = n->next) {          for ( ; n && n->next; n = n->next) {
                 if (MDOC_ELEM == n->type && MDOC_Nm == n->tok)                  if (MDOC_ELEM == n->type && MDOC_Nm == n->tok)
                         continue;                          continue;
                 if (MDOC_TEXT == n->type)                  if (MDOC_TEXT == n->type)
                         continue;                          continue;
                 if ( ! mdoc_nwarn(mdoc, mdoc->last, ENAMESECINC))                  if ( ! mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_BADNAMESEC))
                         return(0);                          return(0);
         }          }
   
         assert(n);          assert(n);
         if (MDOC_BLOCK == n->type && MDOC_Nd == n->tok)          if (MDOC_BLOCK == n->type && MDOC_Nd == n->tok)
                 return(1);                  return(1);
         return(mdoc_nwarn(mdoc, mdoc->last, ENAMESECINC));          return(mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_BADNAMESEC));
 }  }
   
   
Line 1202  post_sh_head(POST_ARGS)
Line 1243  post_sh_head(POST_ARGS)
          * certain manual sections.           * certain manual sections.
          */           */
   
         buf[0] = 0;          buf[0] = '\0';
   
           /*
            * FIXME: yes, these can use a dynamic buffer, but I don't do so
            * in the interests of simplicity.
            */
   
         for (n = mdoc->last->child; n; n = n->next) {          for (n = mdoc->last->child; n; n = n->next) {
                 /* XXX - copied from compact(). */                  /* XXX - copied from compact(). */
                 assert(MDOC_TEXT == n->type);                  assert(MDOC_TEXT == n->type);
   
                 if (strlcat(buf, n->string, 64) >= 64)                  if (strlcat(buf, n->string, 64) >= 64) {
                         return(mdoc_nerr(mdoc, n, ETOOLONG));                          mdoc_nmsg(mdoc, n, MANDOCERR_MEM);
                           return(0);
                   }
                 if (NULL == n->next)                  if (NULL == n->next)
                         continue;                          continue;
                 if (strlcat(buf, " ", 64) >= 64)                  if (strlcat(buf, " ", 64) >= 64) {
                         return(mdoc_nerr(mdoc, n, ETOOLONG));                          mdoc_nmsg(mdoc, n, MANDOCERR_MEM);
                           return(0);
                   }
         }          }
   
         sec = mdoc_str2sec(buf);          sec = mdoc_str2sec(buf);
Line 1224  post_sh_head(POST_ARGS)
Line 1274  post_sh_head(POST_ARGS)
          */           */
   
         if (SEC_NAME != sec && SEC_NONE == mdoc->lastnamed)          if (SEC_NAME != sec && SEC_NONE == mdoc->lastnamed)
                 if ( ! mdoc_nwarn(mdoc, mdoc->last, ESECNAME))                  if ( ! mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NAMESECFIRST))
                         return(0);                          return(0);
   
         if (SEC_CUSTOM == sec)          if (SEC_CUSTOM == sec)
                 return(1);                  return(1);
   
         if (sec == mdoc->lastnamed)          if (sec == mdoc->lastnamed)
                 if ( ! mdoc_nwarn(mdoc, mdoc->last, ESECREP))                  if ( ! mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_SECREP))
                         return(0);                          return(0);
   
         if (sec < mdoc->lastnamed)          if (sec < mdoc->lastnamed)
                 if ( ! mdoc_nwarn(mdoc, mdoc->last, ESECOOO))                  if ( ! mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_SECOOO))
                         return(0);                          return(0);
   
         /*          /*
Line 1252  post_sh_head(POST_ARGS)
Line 1302  post_sh_head(POST_ARGS)
                         break;                          break;
                 if (*mdoc->meta.msec == '9')                  if (*mdoc->meta.msec == '9')
                         break;                          break;
                 return(mdoc_nwarn(mdoc, mdoc->last, EWRONGMSEC));                  return(mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_SECMSEC));
         default:          default:
                 break;                  break;
         }          }

Legend:
Removed from v.1.78  
changed lines
  Added in v.1.79

CVSweb