[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.103 and 1.104

version 1.103, 2010/07/01 21:44:47 version 1.104, 2010/07/01 22:56:17
Line 154  const struct valids mdoc_valids[MDOC_MAX] = {
Line 154  const struct valids mdoc_valids[MDOC_MAX] = {
         { NULL, posts_notext },                 /* Pp */          { NULL, posts_notext },                 /* 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_bk },                       /* Bd */          { pres_bd, posts_bd_bk },               /* Bd */
         { NULL, NULL },                         /* Ed */          { NULL, NULL },                         /* Ed */
         { pres_bl, posts_bl },                  /* Bl */          { pres_bl, posts_bl },                  /* Bl */
         { NULL, NULL },                         /* El */          { NULL, NULL },                         /* El */
Line 537  pre_display(PRE_ARGS)
Line 537  pre_display(PRE_ARGS)
 static int  static int
 pre_bl(PRE_ARGS)  pre_bl(PRE_ARGS)
 {  {
         int              i, comp, dup;          int               i, comp, dup;
         const char      *offs, *width;          const char       *offs, *width;
         enum mdoc_list   lt;          enum mdoc_list    lt;
           struct mdoc_node *np;
   
         if (MDOC_BLOCK != n->type) {          if (MDOC_BLOCK != n->type) {
                 assert(n->parent);                  if (ENDBODY_NOT != n->end) {
                 if (ENDBODY_NOT != n->end)                          assert(n->pending);
                         return(1);                          np = n->pending->parent;
                 assert(MDOC_BLOCK == n->parent->type);                  } else
                 assert(MDOC_Bl == n->parent->tok);                          np = n->parent;
                 assert(LIST__NONE != n->parent->data.Bl.type);  
                 memcpy(&n->data.Bl, &n->parent->data.Bl,                  assert(np);
                                 sizeof(struct mdoc_bl));                  assert(MDOC_BLOCK == np->type);
                   assert(MDOC_Bl == np->tok);
                   assert(np->data.Bl);
                   n->data.Bl = np->data.Bl;
                 return(1);                  return(1);
         }          }
   
Line 559  pre_bl(PRE_ARGS)
Line 563  pre_bl(PRE_ARGS)
          * ones.  If we find no list type, we default to LIST_item.           * ones.  If we find no list type, we default to LIST_item.
          */           */
   
         assert(LIST__NONE == n->data.Bl.type);          assert(NULL == n->data.Bl);
           n->data.Bl = mandoc_calloc(1, sizeof(struct mdoc_bl));
   
         /* LINTED */          /* LINTED */
         for (i = 0; n->args && i < (int)n->args->argc; i++) {          for (i = 0; n->args && i < (int)n->args->argc; i++) {
Line 603  pre_bl(PRE_ARGS)
Line 608  pre_bl(PRE_ARGS)
                         break;                          break;
                 /* Set list arguments. */                  /* Set list arguments. */
                 case (MDOC_Compact):                  case (MDOC_Compact):
                         dup = n->data.Bl.comp;                          dup = n->data.Bl->comp;
                         comp = 1;                          comp = 1;
                         break;                          break;
                 case (MDOC_Width):                  case (MDOC_Width):
                         dup = (NULL != n->data.Bl.width);                          dup = (NULL != n->data.Bl->width);
                         width = n->args->argv[i].value[0];                          width = n->args->argv[i].value[0];
                         break;                          break;
                 case (MDOC_Offset):                  case (MDOC_Offset):
                         /* NB: this can be empty! */                          /* NB: this can be empty! */
                         if (n->args->argv[i].sz) {                          if (n->args->argv[i].sz) {
                                 offs = n->args->argv[i].value[0];                                  offs = n->args->argv[i].value[0];
                                 dup = (NULL != n->data.Bl.offs);                                  dup = (NULL != n->data.Bl->offs);
                                 break;                                  break;
                         }                          }
                         if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_IGNARGV))                          if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_IGNARGV))
Line 628  pre_bl(PRE_ARGS)
Line 633  pre_bl(PRE_ARGS)
                         return(0);                          return(0);
   
                 if (comp && ! dup)                  if (comp && ! dup)
                         n->data.Bl.comp = comp;                          n->data.Bl->comp = comp;
                 if (offs && ! dup)                  if (offs && ! dup)
                         n->data.Bl.offs = offs;                          n->data.Bl->offs = offs;
                 if (width && ! dup)                  if (width && ! dup)
                         n->data.Bl.width = width;                          n->data.Bl->width = width;
   
                 /* Check: multiple list types. */                  /* Check: multiple list types. */
   
                 if (LIST__NONE != lt && n->data.Bl.type != LIST__NONE)                  if (LIST__NONE != lt && n->data.Bl->type != LIST__NONE)
                         if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_LISTREP))                          if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_LISTREP))
                                 return(0);                                  return(0);
   
                 /* Assign list type. */                  /* Assign list type. */
   
                 if (LIST__NONE != lt && n->data.Bl.type == LIST__NONE)                  if (LIST__NONE != lt && n->data.Bl->type == LIST__NONE)
                         n->data.Bl.type = lt;                          n->data.Bl->type = lt;
   
                 /* The list type should come first. */                  /* The list type should come first. */
   
                 if (n->data.Bl.type == LIST__NONE)                  if (n->data.Bl->type == LIST__NONE)
                         if (n->data.Bl.width ||                          if (n->data.Bl->width ||
                                         n->data.Bl.offs ||                                          n->data.Bl->offs ||
                                         n->data.Bl.comp)                                          n->data.Bl->comp)
                                 if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_LISTFIRST))                                  if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_LISTFIRST))
                                         return(0);                                          return(0);
   
Line 659  pre_bl(PRE_ARGS)
Line 664  pre_bl(PRE_ARGS)
   
         /* Allow lists to default to LIST_item. */          /* Allow lists to default to LIST_item. */
   
         if (LIST__NONE == n->data.Bl.type) {          if (LIST__NONE == n->data.Bl->type) {
                 if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_LISTTYPE))                  if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_LISTTYPE))
                         return(0);                          return(0);
                 n->data.Bl.type = LIST_item;                  n->data.Bl->type = LIST_item;
         }          }
   
         /*          /*
Line 671  pre_bl(PRE_ARGS)
Line 676  pre_bl(PRE_ARGS)
          * and must also be warned.           * and must also be warned.
          */           */
   
         switch (n->data.Bl.type) {          switch (n->data.Bl->type) {
         case (LIST_tag):          case (LIST_tag):
                 if (n->data.Bl.width)                  if (n->data.Bl->width)
                         break;                          break;
                 if (mdoc_nmsg(mdoc, n, MANDOCERR_NOWIDTHARG))                  if (mdoc_nmsg(mdoc, n, MANDOCERR_NOWIDTHARG))
                         break;                          break;
Line 687  pre_bl(PRE_ARGS)
Line 692  pre_bl(PRE_ARGS)
         case (LIST_inset):          case (LIST_inset):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (LIST_item):          case (LIST_item):
                 if (NULL == n->data.Bl.width)                  if (NULL == n->data.Bl->width)
                         break;                          break;
                 if (mdoc_nmsg(mdoc, n, MANDOCERR_WIDTHARG))                  if (mdoc_nmsg(mdoc, n, MANDOCERR_WIDTHARG))
                         break;                          break;
Line 703  pre_bl(PRE_ARGS)
Line 708  pre_bl(PRE_ARGS)
 static int  static int
 pre_bd(PRE_ARGS)  pre_bd(PRE_ARGS)
 {  {
         int              i, dup, comp;          int               i, dup, comp;
         enum mdoc_disp   dt;          enum mdoc_disp    dt;
         const char      *offs;          const char       *offs;
           struct mdoc_node *np;
   
         if (MDOC_BLOCK != n->type) {          if (MDOC_BLOCK != n->type) {
                 assert(n->parent);                  if (ENDBODY_NOT != n->end) {
                 assert(MDOC_BLOCK == n->parent->type);                          assert(n->pending);
                 assert(MDOC_Bd == n->parent->tok);                          np = n->pending->parent;
                 assert(DISP__NONE != n->parent->data.Bd.type);                  } else
                 memcpy(&n->data.Bd, &n->parent->data.Bd,                          np = n->parent;
                                 sizeof(struct mdoc_bd));  
                   assert(np);
                   assert(MDOC_BLOCK == np->type);
                   assert(MDOC_Bd == np->tok);
                   assert(np->data.Bd);
                   n->data.Bd = np->data.Bd;
                 return(1);                  return(1);
         }          }
   
         assert(DISP__NONE == n->data.Bd.type);          assert(NULL == n->data.Bd);
           n->data.Bd = mandoc_calloc(1, sizeof(struct mdoc_bd));
   
         /* LINTED */          /* LINTED */
         for (i = 0; n->args && i < (int)n->args->argc; i++) {          for (i = 0; n->args && i < (int)n->args->argc; i++) {
Line 748  pre_bd(PRE_ARGS)
Line 760  pre_bd(PRE_ARGS)
                         /* NB: this can be empty! */                          /* NB: this can be empty! */
                         if (n->args->argv[i].sz) {                          if (n->args->argv[i].sz) {
                                 offs = n->args->argv[i].value[0];                                  offs = n->args->argv[i].value[0];
                                 dup = (NULL != n->data.Bd.offs);                                  dup = (NULL != n->data.Bd->offs);
                                 break;                                  break;
                         }                          }
                         if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_IGNARGV))                          if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_IGNARGV))
Line 756  pre_bd(PRE_ARGS)
Line 768  pre_bd(PRE_ARGS)
                         break;                          break;
                 case (MDOC_Compact):                  case (MDOC_Compact):
                         comp = 1;                          comp = 1;
                         dup = n->data.Bd.comp;                          dup = n->data.Bd->comp;
                         break;                          break;
                 default:                  default:
                         abort();                          abort();
Line 771  pre_bd(PRE_ARGS)
Line 783  pre_bd(PRE_ARGS)
                 /* Make our auxiliary assignments. */                  /* Make our auxiliary assignments. */
   
                 if (offs && ! dup)                  if (offs && ! dup)
                         n->data.Bd.offs = offs;                          n->data.Bd->offs = offs;
                 if (comp && ! dup)                  if (comp && ! dup)
                         n->data.Bd.comp = comp;                          n->data.Bd->comp = comp;
   
                 /* Check whether a type has already been assigned. */                  /* Check whether a type has already been assigned. */
   
                 if (DISP__NONE != dt && n->data.Bd.type != DISP__NONE)                  if (DISP__NONE != dt && n->data.Bd->type != DISP__NONE)
                         if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_DISPREP))                          if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_DISPREP))
                                 return(0);                                  return(0);
   
                 /* Make our type assignment. */                  /* Make our type assignment. */
   
                 if (DISP__NONE != dt && n->data.Bd.type == DISP__NONE)                  if (DISP__NONE != dt && n->data.Bd->type == DISP__NONE)
                         n->data.Bd.type = dt;                          n->data.Bd->type = dt;
         }          }
   
         if (DISP__NONE == n->data.Bd.type) {          if (DISP__NONE == n->data.Bd->type) {
                 if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_DISPTYPE))                  if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_DISPTYPE))
                         return(0);                          return(0);
                 n->data.Bd.type = DISP_ragged;                  n->data.Bd->type = DISP_ragged;
         }          }
   
         return(1);          return(1);
Line 1053  post_it(POST_ARGS)
Line 1065  post_it(POST_ARGS)
                 return(1);                  return(1);
   
         n = mdoc->last->parent->parent;          n = mdoc->last->parent->parent;
         lt = n->data.Bl.type;          assert(n->data.Bl);
           lt = n->data.Bl->type;
   
         if (LIST__NONE == lt) {          if (LIST__NONE == lt) {
                 mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_LISTTYPE);                  mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_LISTTYPE);
Line 1145  post_bl_head(POST_ARGS) 
Line 1158  post_bl_head(POST_ARGS) 
         assert(mdoc->last->parent);          assert(mdoc->last->parent);
         n = mdoc->last->parent;          n = mdoc->last->parent;
   
         if (LIST_column == n->data.Bl.type) {          if (LIST_column == n->data.Bl->type) {
                 for (i = 0; i < (int)n->args->argc; i++)                  for (i = 0; i < (int)n->args->argc; i++)
                         if (MDOC_Column == n->args->argv[i].arg)                          if (MDOC_Column == n->args->argv[i].arg)
                                 break;                                  break;

Legend:
Removed from v.1.103  
changed lines
  Added in v.1.104

CVSweb