[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.233 and 1.237

version 1.233, 2014/07/30 12:58:21 version 1.237, 2014/07/31 00:41:10
Line 66  struct valids {
Line 66  struct valids {
   
 static  int      check_count(struct mdoc *, enum mdoc_type,  static  int      check_count(struct mdoc *, enum mdoc_type,
                         enum check_lvl, enum check_ineq, int);                          enum check_lvl, enum check_ineq, int);
 static  int      check_parent(PRE_ARGS, enum mdoct, enum mdoc_type);  
 static  void     check_text(struct mdoc *, int, int, char *);  static  void     check_text(struct mdoc *, int, int, char *);
 static  void     check_argv(struct mdoc *,  static  void     check_argv(struct mdoc *,
                         struct mdoc_node *, struct mdoc_argv *);                          struct mdoc_node *, struct mdoc_argv *);
Line 124  static int  pre_bl(PRE_ARGS);
Line 123  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_it(PRE_ARGS);  
 static  int      pre_literal(PRE_ARGS);  static  int      pre_literal(PRE_ARGS);
 static  int      pre_obsolete(PRE_ARGS);  static  int      pre_obsolete(PRE_ARGS);
 static  int      pre_os(PRE_ARGS);  static  int      pre_os(PRE_ARGS);
 static  int      pre_par(PRE_ARGS);  static  int      pre_par(PRE_ARGS);
 static  int      pre_sh(PRE_ARGS);  
 static  int      pre_ss(PRE_ARGS);  
 static  int      pre_std(PRE_ARGS);  static  int      pre_std(PRE_ARGS);
   
 static  v_post   posts_an[] = { post_an, NULL };  static  v_post   posts_an[] = { post_an, NULL };
Line 176  static v_pre  pres_d1[] = { pre_display, NULL };
Line 172  static v_pre  pres_d1[] = { pre_display, NULL };
 static  v_pre    pres_dl[] = { pre_literal, pre_display, NULL };  static  v_pre    pres_dl[] = { pre_literal, 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_it[] = { pre_it, pre_par, NULL };  static  v_pre    pres_it[] = { pre_par, NULL };
 static  v_pre    pres_obsolete[] = { pre_obsolete, NULL };  static  v_pre    pres_obsolete[] = { pre_obsolete, NULL };
 static  v_pre    pres_os[] = { pre_os, NULL };  static  v_pre    pres_os[] = { pre_os, NULL };
 static  v_pre    pres_pp[] = { pre_par, NULL };  static  v_pre    pres_pp[] = { pre_par, NULL };
 static  v_pre    pres_sh[] = { pre_sh, NULL };  
 static  v_pre    pres_ss[] = { pre_ss, NULL };  
 static  v_pre    pres_std[] = { pre_std, NULL };  static  v_pre    pres_std[] = { pre_std, NULL };
   
 static  const struct valids mdoc_valids[MDOC_MAX] = {  static  const struct valids mdoc_valids[MDOC_MAX] = {
Line 189  static const struct valids mdoc_valids[MDOC_MAX] = {
Line 183  static const struct valids mdoc_valids[MDOC_MAX] = {
         { pres_dd, posts_dd },                  /* Dd */          { pres_dd, posts_dd },                  /* Dd */
         { pres_dt, posts_dt },                  /* Dt */          { pres_dt, posts_dt },                  /* Dt */
         { pres_os, posts_os },                  /* Os */          { pres_os, posts_os },                  /* Os */
         { pres_sh, posts_sh },                  /* Sh */          { NULL, posts_sh },                     /* Sh */
         { pres_ss, posts_ss },                  /* Ss */          { NULL, posts_ss },                     /* Ss */
         { pres_pp, posts_pp },                  /* Pp */          { pres_pp, posts_pp },                  /* Pp */
         { pres_d1, posts_d1 },                  /* D1 */          { pres_d1, posts_d1 },                  /* D1 */
         { pres_dl, posts_dl },                  /* Dl */          { pres_dl, posts_dl },                  /* Dl */
Line 550  check_text(struct mdoc *mdoc, int ln, int pos, char *p
Line 544  check_text(struct mdoc *mdoc, int ln, int pos, char *p
 }  }
   
 static int  static int
 check_parent(PRE_ARGS, enum mdoct tok, enum mdoc_type t)  
 {  
   
         assert(n->parent);  
         if ((MDOC_ROOT == t || tok == n->parent->tok) &&  
                         (t == n->parent->type))  
                 return(1);  
   
         mandoc_vmsg(MANDOCERR_SYNTCHILD, mdoc->parse,  
             n->line, n->pos, "want parent %s",  
             MDOC_ROOT == t ? "<root>" : mdoc_macronames[tok]);  
         return(0);  
 }  
   
   
 static int  
 pre_display(PRE_ARGS)  pre_display(PRE_ARGS)
 {  {
         struct mdoc_node *node;          struct mdoc_node *node;
Line 858  pre_bd(PRE_ARGS)
Line 836  pre_bd(PRE_ARGS)
 }  }
   
 static int  static int
 pre_ss(PRE_ARGS)  
 {  
   
         if (MDOC_BLOCK != n->type)  
                 return(1);  
         return(check_parent(mdoc, n, MDOC_Sh, MDOC_BODY));  
 }  
   
 static int  
 pre_sh(PRE_ARGS)  
 {  
   
         if (MDOC_BLOCK != n->type)  
                 return(1);  
         return(check_parent(mdoc, n, MDOC_MAX, MDOC_ROOT));  
 }  
   
 static int  
 pre_it(PRE_ARGS)  
 {  
   
         if (MDOC_BLOCK != n->type)  
                 return(1);  
   
         return(check_parent(mdoc, n, MDOC_Bl, MDOC_BODY));  
 }  
   
 static int  
 pre_an(PRE_ARGS)  pre_an(PRE_ARGS)
 {  {
         int              i;          int              i;
Line 1260  post_it(POST_ARGS)
Line 1210  post_it(POST_ARGS)
         int               i, cols;          int               i, cols;
         enum mdoc_list    lt;          enum mdoc_list    lt;
         struct mdoc_node *nbl, *nit, *nch;          struct mdoc_node *nbl, *nit, *nch;
         enum mandocerr    er;  
   
         nit = mdoc->last;          nit = mdoc->last;
         if (MDOC_BLOCK != nit->type)          if (MDOC_BLOCK != nit->type)
Line 1311  post_it(POST_ARGS)
Line 1260  post_it(POST_ARGS)
                         if (MDOC_BODY == nch->type)                          if (MDOC_BODY == nch->type)
                                 i++;                                  i++;
   
                 if (i < cols)                  if (i < cols || i > cols + 1)
                         er = MANDOCERR_ARGCOUNT;                          mandoc_vmsg(MANDOCERR_ARGCOUNT,
                 else if (i == cols || i == cols + 1)                              mdoc->parse, nit->line, nit->pos,
                         break;                              "columns == %d (have %d)", cols, i);
                 else                  break;
                         er = MANDOCERR_SYNTARGCOUNT;  
   
                 mandoc_vmsg(er, mdoc->parse, nit->line, nit->pos,  
                     "columns == %d (have %d)", cols, i);  
                 return(MANDOCERR_ARGCOUNT == er);  
         default:          default:
                 abort();                  abort();
         }          }
Line 1507  static int
Line 1451  static int
 post_bl_head(POST_ARGS)  post_bl_head(POST_ARGS)
 {  {
         struct mdoc_node *np, *nn, *nnp;          struct mdoc_node *np, *nn, *nnp;
           struct mdoc_argv *argv;
         int               i, j;          int               i, j;
   
         if (LIST_column != mdoc->last->norm->Bl.type)          if (LIST_column != mdoc->last->norm->Bl.type)
Line 1514  post_bl_head(POST_ARGS)
Line 1459  post_bl_head(POST_ARGS)
                 return(hwarn_eq0(mdoc));                  return(hwarn_eq0(mdoc));
   
         /*          /*
          * Convert old-style lists, where the column width specifiers           * Append old-style lists, where the column width specifiers
          * trail as macro parameters, to the new-style ("normal-form")           * trail as macro parameters, to the new-style ("normal-form")
          * lists where they're argument values following -column.           * lists where they're argument values following -column.
          */           */
   
         /* First, disallow both types and allow normal-form. */          if (mdoc->last->child == NULL)
   
         /*  
          * TODO: technically, we can accept both and just merge the two  
          * lists, but I'll leave that for another day.  
          */  
   
         if (mdoc->last->norm->Bl.ncols && mdoc->last->nchild) {  
                 mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_COLUMNS);  
                 return(0);  
         } else if (NULL == mdoc->last->child)  
                 return(1);                  return(1);
   
         np = mdoc->last->parent;          np = mdoc->last->parent;
Line 1540  post_bl_head(POST_ARGS)
Line 1475  post_bl_head(POST_ARGS)
                         break;                          break;
   
         assert(j < (int)np->args->argc);          assert(j < (int)np->args->argc);
         assert(0 == np->args->argv[j].sz);  
   
         /*          /*
          * Accommodate for new-style groff column syntax.  Shuffle the           * Accommodate for new-style groff column syntax.  Shuffle the
Line 1548  post_bl_head(POST_ARGS)
Line 1482  post_bl_head(POST_ARGS)
          * column field.  Then, delete the head children.           * column field.  Then, delete the head children.
          */           */
   
         np->args->argv[j].sz = (size_t)mdoc->last->nchild;          argv = np->args->argv + j;
         np->args->argv[j].value = mandoc_reallocarray(NULL,          i = argv->sz;
             (size_t)mdoc->last->nchild, sizeof(char *));          argv->sz += mdoc->last->nchild;
           argv->value = mandoc_reallocarray(argv->value,
               argv->sz, sizeof(char *));
   
         mdoc->last->norm->Bl.ncols = np->args->argv[j].sz;          mdoc->last->norm->Bl.ncols = argv->sz;
         mdoc->last->norm->Bl.cols = (void *)np->args->argv[j].value;          mdoc->last->norm->Bl.cols = (void *)argv->value;
   
         for (i = 0, nn = mdoc->last->child; nn; i++) {          for (nn = mdoc->last->child; nn; i++) {
                 np->args->argv[j].value[i] = nn->string;                  argv->value[i] = nn->string;
                 nn->string = NULL;                  nn->string = NULL;
                 nnp = nn;                  nnp = nn;
                 nn = nn->next;                  nn = nn->next;
Line 1683  ebool(struct mdoc *mdoc)
Line 1619  ebool(struct mdoc *mdoc)
 static int  static int
 post_root(POST_ARGS)  post_root(POST_ARGS)
 {  {
         int               ret;  
         struct mdoc_node *n;          struct mdoc_node *n;
   
         ret = 1;          /* Add missing prologue data. */
   
         /* Check that we have a finished prologue. */  
   
         if ( ! (MDOC_PBODY & mdoc->flags)) {          if ( ! (MDOC_PBODY & mdoc->flags)) {
                 ret = 0;                  mandoc_msg(MANDOCERR_PROLOG_BAD, mdoc->parse, 0, 0, "EOF");
                 mdoc_nmsg(mdoc, mdoc->first, MANDOCERR_NODOCPROLOG);                  if (mdoc->meta.date == NULL)
                           mdoc->meta.date = mdoc->quick ?
                               mandoc_strdup("") :
                               mandoc_normdate(mdoc->parse, NULL, 0, 0);
                   if (mdoc->meta.title == NULL)
                           mdoc->meta.title = mandoc_strdup("UNKNOWN");
                   if (mdoc->meta.vol == NULL)
                           mdoc->meta.vol = mandoc_strdup("LOCAL");
                   if (mdoc->meta.arch == NULL)
                           mdoc->meta.msec = mandoc_strdup("1");
                   if (mdoc->meta.os == NULL)
                           mdoc->meta.os = mandoc_strdup("UNKNOWN");
         }          }
   
         n = mdoc->first;          n = mdoc->first;
Line 1707  post_root(POST_ARGS)
Line 1651  post_root(POST_ARGS)
                     n->child->line, n->child->pos,                      n->child->line, n->child->pos,
                     mdoc_macronames[n->child->tok]);                      mdoc_macronames[n->child->tok]);
   
         return(ret);          return(1);
 }  }
   
 static int  static int

Legend:
Removed from v.1.233  
changed lines
  Added in v.1.237

CVSweb