[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.96 and 1.103

version 1.96, 2010/06/12 11:58:22 version 1.103, 2010/07/01 21:44:47
Line 107  static int  pre_ss(PRE_ARGS);
Line 107  static int  pre_ss(PRE_ARGS);
   
 static  v_post   posts_an[] = { post_an, NULL };  static  v_post   posts_an[] = { post_an, NULL };
 static  v_post   posts_at[] = { post_at, NULL };  static  v_post   posts_at[] = { post_at, NULL };
 static  v_post   posts_bd[] = { hwarn_eq0, bwarn_ge1, NULL };  static  v_post   posts_bd_bk[] = { hwarn_eq0, bwarn_ge1, NULL };
 static  v_post   posts_bf[] = { hwarn_le1, post_bf, NULL };  static  v_post   posts_bf[] = { hwarn_le1, post_bf, NULL };
 static  v_post   posts_bl[] = { bwarn_ge1, post_bl, NULL };  static  v_post   posts_bl[] = { bwarn_ge1, post_bl, NULL };
 static  v_post   posts_bool[] = { eerr_eq1, ebool, NULL };  static  v_post   posts_bool[] = { eerr_eq1, ebool, NULL };
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 },                  /* 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 245  const struct valids mdoc_valids[MDOC_MAX] = {
Line 245  const struct valids mdoc_valids[MDOC_MAX] = {
         { NULL, NULL },                         /* Fc */          { NULL, NULL },                         /* Fc */
         { NULL, NULL },                         /* Oo */          { NULL, NULL },                         /* Oo */
         { NULL, NULL },                         /* Oc */          { NULL, NULL },                         /* Oc */
         { NULL, posts_wline },                  /* Bk */          { NULL, posts_bd_bk },                  /* Bk */
         { NULL, NULL },                         /* Ek */          { NULL, NULL },                         /* Ek */
         { NULL, posts_eoln },                   /* Bt */          { NULL, posts_eoln },                   /* Bt */
         { NULL, NULL },                         /* Hf */          { NULL, NULL },                         /* Hf */
Line 458  check_text(struct mdoc *mdoc, int line, int pos, char 
Line 458  check_text(struct mdoc *mdoc, int line, int pos, char 
 {  {
         int              c;          int              c;
   
           /*
            * FIXME: we absolutely cannot let \b get through or it will
            * destroy some assumptions in terms of format.
            */
   
         for ( ; *p; p++, pos++) {          for ( ; *p; p++, pos++) {
                 if ('\t' == *p) {                  if ('\t' == *p) {
                         if ( ! (MDOC_LITERAL & mdoc->flags))                          if ( ! (MDOC_LITERAL & mdoc->flags))
Line 532  pre_display(PRE_ARGS)
Line 537  pre_display(PRE_ARGS)
 static int  static int
 pre_bl(PRE_ARGS)  pre_bl(PRE_ARGS)
 {  {
         int              i, width, offs, cmpt, dupl;          int              i, comp, dup;
           const char      *offs, *width;
         enum mdoc_list   lt;          enum mdoc_list   lt;
   
         if (MDOC_BLOCK != n->type) {          if (MDOC_BLOCK != n->type) {
                 assert(n->parent);                  assert(n->parent);
                   if (ENDBODY_NOT != n->end)
                           return(1);
                 assert(MDOC_BLOCK == n->parent->type);                  assert(MDOC_BLOCK == n->parent->type);
                 assert(MDOC_Bl == n->parent->tok);                  assert(MDOC_Bl == n->parent->tok);
                 assert(LIST__NONE != n->parent->data.Bl.type);                  assert(LIST__NONE != n->parent->data.Bl.type);
Line 552  pre_bl(PRE_ARGS)
Line 560  pre_bl(PRE_ARGS)
          */           */
   
         assert(LIST__NONE == n->data.Bl.type);          assert(LIST__NONE == n->data.Bl.type);
         offs = width = cmpt = -1;  
   
         /* LINTED */          /* LINTED */
         for (i = 0; n->args && i < (int)n->args->argc; i++) {          for (i = 0; n->args && i < (int)n->args->argc; i++) {
                 lt = LIST__NONE;                  lt = LIST__NONE;
                 dupl = 0;                  dup = comp = 0;
                   width = offs = NULL;
                 switch (n->args->argv[i].arg) {                  switch (n->args->argv[i].arg) {
                 /* Set list types. */                  /* Set list types. */
                 case (MDOC_Bullet):                  case (MDOC_Bullet):
Line 595  pre_bl(PRE_ARGS)
Line 603  pre_bl(PRE_ARGS)
                         break;                          break;
                 /* Set list arguments. */                  /* Set list arguments. */
                 case (MDOC_Compact):                  case (MDOC_Compact):
                         if (cmpt >= 0)                          dup = n->data.Bl.comp;
                                 dupl++;                          comp = 1;
                         cmpt = i;  
                         break;                          break;
                 case (MDOC_Width):                  case (MDOC_Width):
                         if (width >= 0)                          dup = (NULL != n->data.Bl.width);
                                 dupl++;                          width = n->args->argv[i].value[0];
                         width = i;  
                         break;                          break;
                 case (MDOC_Offset):                  case (MDOC_Offset):
                         if (offs >= 0)                          /* NB: this can be empty! */
                                 dupl++;                          if (n->args->argv[i].sz) {
                         offs = i;                                  offs = n->args->argv[i].value[0];
                                   dup = (NULL != n->data.Bl.offs);
                                   break;
                           }
                           if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_IGNARGV))
                                   return(0);
                         break;                          break;
                 }                  }
   
                 /* Check: duplicate auxiliary arguments. */                  /* Check: duplicate auxiliary arguments. */
   
                 if (dupl)                  if (dup && ! mdoc_nmsg(mdoc, n, MANDOCERR_ARGVREP))
                         if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_ARGVREP))                          return(0);
                                 return(0);  
   
                   if (comp && ! dup)
                           n->data.Bl.comp = comp;
                   if (offs && ! dup)
                           n->data.Bl.offs = offs;
                   if (width && ! dup)
                           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)
Line 631  pre_bl(PRE_ARGS)
Line 648  pre_bl(PRE_ARGS)
                 /* 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 (width >= 0 || offs >= 0 || cmpt >= 0)                          if (n->data.Bl.width ||
                                           n->data.Bl.offs ||
                                           n->data.Bl.comp)
                                 if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_LISTFIRST))                                  if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_LISTFIRST))
                                         return(0);                                          return(0);
   
Line 654  pre_bl(PRE_ARGS)
Line 673  pre_bl(PRE_ARGS)
   
         switch (n->data.Bl.type) {          switch (n->data.Bl.type) {
         case (LIST_tag):          case (LIST_tag):
                 if (width >= 0)                  if (n->data.Bl.width)
                         break;                          break;
                 if (mdoc_nmsg(mdoc, n, MANDOCERR_NOWIDTHARG))                  if (mdoc_nmsg(mdoc, n, MANDOCERR_NOWIDTHARG))
                         break;                          break;
Line 668  pre_bl(PRE_ARGS)
Line 687  pre_bl(PRE_ARGS)
         case (LIST_inset):          case (LIST_inset):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (LIST_item):          case (LIST_item):
                 if (width < 0)                  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 794  pre_sh(PRE_ARGS)
Line 813  pre_sh(PRE_ARGS)
   
         if (MDOC_BLOCK != n->type)          if (MDOC_BLOCK != n->type)
                 return(1);                  return(1);
   
           mdoc->regs->regs[(int)REG_nS].set = 0;
         return(check_parent(mdoc, n, MDOC_MAX, MDOC_ROOT));          return(check_parent(mdoc, n, MDOC_MAX, MDOC_ROOT));
 }  }
   

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

CVSweb