[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.253 and 1.254

version 1.253, 2014/10/13 14:05:32 version 1.254, 2014/10/30 20:10:02
Line 70  static void  check_args(struct mdoc *, struct mdoc_nod
Line 70  static void  check_args(struct mdoc *, struct mdoc_nod
 static  int      child_an(const struct mdoc_node *);  static  int      child_an(const struct mdoc_node *);
 static  enum mdoc_sec   a2sec(const char *);  static  enum mdoc_sec   a2sec(const char *);
 static  size_t          macro2len(enum mdoct);  static  size_t          macro2len(enum mdoct);
   static  void     rewrite_macro2len(char **);
   
 static  int      ebool(POST_ARGS);  static  int      ebool(POST_ARGS);
 static  int      berr_ge1(POST_ARGS);  static  int      berr_ge1(POST_ARGS);
Line 88  static int  post_bf(POST_ARGS);
Line 89  static int  post_bf(POST_ARGS);
 static  int      post_bk(POST_ARGS);  static  int      post_bk(POST_ARGS);
 static  int      post_bl(POST_ARGS);  static  int      post_bl(POST_ARGS);
 static  int      post_bl_block(POST_ARGS);  static  int      post_bl_block(POST_ARGS);
 static  int      post_bl_block_width(POST_ARGS);  
 static  int      post_bl_block_tag(POST_ARGS);  static  int      post_bl_block_tag(POST_ARGS);
 static  int      post_bl_head(POST_ARGS);  static  int      post_bl_head(POST_ARGS);
 static  int      post_bx(POST_ARGS);  static  int      post_bx(POST_ARGS);
Line 597  pre_bl(PRE_ARGS)
Line 597  pre_bl(PRE_ARGS)
                                     mdoc->parse, argv->line,                                      mdoc->parse, argv->line,
                                     argv->pos, "Bl -width %s",                                      argv->pos, "Bl -width %s",
                                     argv->value[0]);                                      argv->value[0]);
                           rewrite_macro2len(argv->value);
                         n->norm->Bl.width = argv->value[0];                          n->norm->Bl.width = argv->value[0];
                         break;                          break;
                 case MDOC_Offset:                  case MDOC_Offset:
Line 611  pre_bl(PRE_ARGS)
Line 612  pre_bl(PRE_ARGS)
                                     mdoc->parse, argv->line,                                      mdoc->parse, argv->line,
                                     argv->pos, "Bl -offset %s",                                      argv->pos, "Bl -offset %s",
                                     argv->value[0]);                                      argv->value[0]);
                           rewrite_macro2len(argv->value);
                         n->norm->Bl.offs = argv->value[0];                          n->norm->Bl.offs = argv->value[0];
                         break;                          break;
                 default:                  default:
Line 758  pre_bd(PRE_ARGS)
Line 760  pre_bd(PRE_ARGS)
                                     mdoc->parse, argv->line,                                      mdoc->parse, argv->line,
                                     argv->pos, "Bd -offset %s",                                      argv->pos, "Bd -offset %s",
                                     argv->value[0]);                                      argv->value[0]);
                           rewrite_macro2len(argv->value);
                         n->norm->Bd.offs = argv->value[0];                          n->norm->Bd.offs = argv->value[0];
                         break;                          break;
                 case MDOC_Compact:                  case MDOC_Compact:
Line 1336  post_bl_block(POST_ARGS)
Line 1339  post_bl_block(POST_ARGS)
                 if ( ! post_bl_block_tag(mdoc))                  if ( ! post_bl_block_tag(mdoc))
                         return(0);                          return(0);
                 assert(n->norm->Bl.width);                  assert(n->norm->Bl.width);
         } else if (NULL != n->norm->Bl.width) {  
                 if ( ! post_bl_block_width(mdoc))  
                         return(0);  
                 assert(n->norm->Bl.width);  
         }          }
   
         for (ni = n->body->child; ni; ni = ni->next) {          for (ni = n->body->child; ni; ni = ni->next) {
Line 1379  post_bl_block(POST_ARGS)
Line 1378  post_bl_block(POST_ARGS)
         return(1);          return(1);
 }  }
   
 static int  /*
 post_bl_block_width(POST_ARGS)   * If the argument of -offset or -width is a macro,
    * replace it with the associated default width.
    */
   void
   rewrite_macro2len(char **arg)
 {  {
         size_t            width;          size_t            width;
         int               i;  
         enum mdoct        tok;          enum mdoct        tok;
         struct mdoc_node *n;  
         char              buf[24];  
   
         n = mdoc->last;          if (*arg == NULL)
                   return;
         /*          else if ( ! strcmp(*arg, "Ds"))
          * Calculate the real width of a list from the -width string,  
          * which may contain a macro (with a known default width), a  
          * literal string, or a scaling width.  
          *  
          * If the value to -width is a macro, then we re-write it to be  
          * the macro's width as set in share/tmac/mdoc/doc-common.  
          */  
   
         if (0 == strcmp(n->norm->Bl.width, "Ds"))  
                 width = 6;                  width = 6;
         else if (MDOC_MAX == (tok = mdoc_hash_find(n->norm->Bl.width)))          else if ((tok = mdoc_hash_find(*arg)) == MDOC_MAX)
                 return(1);                  return;
         else          else
                 width = macro2len(tok);                  width = macro2len(tok);
   
         /* The value already exists: free and reallocate it. */          free(*arg);
           mandoc_asprintf(arg, "%zun", width);
         assert(n->args);  
   
         for (i = 0; i < (int)n->args->argc; i++)  
                 if (MDOC_Width == n->args->argv[i].arg)  
                         break;  
   
         assert(i < (int)n->args->argc);  
   
         (void)snprintf(buf, sizeof(buf), "%un", (unsigned int)width);  
         free(n->args->argv[i].value[0]);  
         n->args->argv[i].value[0] = mandoc_strdup(buf);  
   
         /* Set our width! */  
         n->norm->Bl.width = n->args->argv[i].value[0];  
         return(1);  
 }  }
   
 static int  static int
Line 1437  post_bl_block_tag(POST_ARGS)
Line 1413  post_bl_block_tag(POST_ARGS)
          * Calculate the -width for a `Bl -tag' list if it hasn't been           * Calculate the -width for a `Bl -tag' list if it hasn't been
          * provided.  Uses the first head macro.  NOTE AGAIN: this is           * provided.  Uses the first head macro.  NOTE AGAIN: this is
          * ONLY if the -width argument has NOT been provided.  See           * ONLY if the -width argument has NOT been provided.  See
          * post_bl_block_width() for converting the -width string.           * rewrite_macro2len() for converting the -width string.
          */           */
   
         sz = 10;          sz = 10;

Legend:
Removed from v.1.253  
changed lines
  Added in v.1.254

CVSweb