[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.316 and 1.317

version 1.316, 2017/01/10 23:36:34 version 1.317, 2017/01/11 17:39:53
Line 51  enum check_ineq {
Line 51  enum check_ineq {
   
 typedef void    (*v_post)(POST_ARGS);  typedef void    (*v_post)(POST_ARGS);
   
   static  int      build_list(struct roff_man *, int);
 static  void     check_text(struct roff_man *, int, int, char *);  static  void     check_text(struct roff_man *, int, int, char *);
 static  void     check_argv(struct roff_man *,  static  void     check_argv(struct roff_man *,
                         struct roff_node *, struct mdoc_argv *);                          struct roff_node *, struct mdoc_argv *);
Line 95  static void  post_par(POST_ARGS);
Line 96  static void  post_par(POST_ARGS);
 static  void     post_prevpar(POST_ARGS);  static  void     post_prevpar(POST_ARGS);
 static  void     post_root(POST_ARGS);  static  void     post_root(POST_ARGS);
 static  void     post_rs(POST_ARGS);  static  void     post_rs(POST_ARGS);
   static  void     post_rv(POST_ARGS);
 static  void     post_sh(POST_ARGS);  static  void     post_sh(POST_ARGS);
 static  void     post_sh_head(POST_ARGS);  static  void     post_sh_head(POST_ARGS);
 static  void     post_sh_name(POST_ARGS);  static  void     post_sh_name(POST_ARGS);
Line 143  static v_post mdoc_valids[MDOC_MAX] = {
Line 145  static v_post mdoc_valids[MDOC_MAX] = {
         NULL,           /* Op */          NULL,           /* Op */
         post_obsolete,  /* Ot */          post_obsolete,  /* Ot */
         post_defaults,  /* Pa */          post_defaults,  /* Pa */
         post_std,       /* Rv */          post_rv,        /* Rv */
         post_st,        /* St */          post_st,        /* St */
         NULL,           /* Va */          NULL,           /* Va */
         NULL,           /* Vt */          NULL,           /* Vt */
Line 621  post_bd(POST_ARGS)
Line 623  post_bd(POST_ARGS)
         }          }
 }  }
   
   /*
    * Stand-alone line macros.
    */
   
 static void  static void
 post_an_norm(POST_ARGS)  post_an_norm(POST_ARGS)
 {  {
Line 649  post_an_norm(POST_ARGS)
Line 655  post_an_norm(POST_ARGS)
 }  }
   
 static void  static void
   post_eoln(POST_ARGS)
   {
           struct roff_node        *n;
   
           n = mdoc->last;
           if (n->child != NULL)
                   mandoc_vmsg(MANDOCERR_ARG_SKIP, mdoc->parse,
                       n->line, n->pos, "%s %s",
                       mdoc_macronames[n->tok], n->child->string);
   
           while (n->child != NULL)
                   roff_node_delete(mdoc, n->child);
   
           roff_word_alloc(mdoc, n->line, n->pos, n->tok == MDOC_Bt ?
               "is currently in beta test." : "currently under development.");
           mdoc->last->flags |= NODE_EOS | NODE_NOSRC;
           mdoc->last = n;
   }
   
   static int
   build_list(struct roff_man *mdoc, int tok)
   {
           struct roff_node        *n;
           int                      ic;
   
           n = mdoc->last->next;
           for (ic = 1;; ic++) {
                   roff_elem_alloc(mdoc, n->line, n->pos, tok);
                   mdoc->last->flags |= NODE_NOSRC;
                   mdoc_node_relink(mdoc, n);
                   n = mdoc->last = mdoc->last->parent;
                   mdoc->next = ROFF_NEXT_SIBLING;
                   if (n->next == NULL)
                           return ic;
                   if (ic > 1 || n->next->next != NULL) {
                           roff_word_alloc(mdoc, n->line, n->pos, ",");
                           mdoc->last->flags |= NODE_DELIMC | NODE_NOSRC;
                   }
                   n = mdoc->last->next;
                   if (n->next == NULL) {
                           roff_word_alloc(mdoc, n->line, n->pos, "and");
                           mdoc->last->flags |= NODE_NOSRC;
                   }
           }
   }
   
   static void
   post_ex(POST_ARGS)
   {
           struct roff_node        *n;
           int                      ic;
   
           post_std(mdoc);
   
           n = mdoc->last;
           mdoc->next = ROFF_NEXT_CHILD;
           roff_word_alloc(mdoc, n->line, n->pos, "The");
           mdoc->last->flags |= NODE_NOSRC;
   
           if (mdoc->last->next != NULL)
                   ic = build_list(mdoc, MDOC_Nm);
           else if (mdoc->meta.name != NULL) {
                   roff_elem_alloc(mdoc, n->line, n->pos, MDOC_Nm);
                   mdoc->last->flags |= NODE_NOSRC;
                   roff_word_alloc(mdoc, n->line, n->pos, mdoc->meta.name);
                   mdoc->last->flags |= NODE_NOSRC;
                   mdoc->last = mdoc->last->parent;
                   mdoc->next = ROFF_NEXT_SIBLING;
                   ic = 1;
           } else {
                   mandoc_msg(MANDOCERR_EX_NONAME, mdoc->parse,
                       n->line, n->pos, "Ex");
                   ic = 0;
           }
   
           roff_word_alloc(mdoc, n->line, n->pos,
               ic > 1 ? "utilities exit\\~0" : "utility exits\\~0");
           mdoc->last->flags |= NODE_NOSRC;
           roff_word_alloc(mdoc, n->line, n->pos,
               "on success, and\\~>0 if an error occurs.");
           mdoc->last->flags |= NODE_EOS | NODE_NOSRC;
           mdoc->last = n;
   }
   
   static void
   post_lb(POST_ARGS)
   {
           struct roff_node        *n;
           const char              *p;
   
           n = mdoc->last;
           assert(n->child->type == ROFFT_TEXT);
           mdoc->next = ROFF_NEXT_CHILD;
   
           if ((p = mdoc_a2lib(n->child->string)) != NULL) {
                   n->child->flags |= NODE_NOPRT;
                   roff_word_alloc(mdoc, n->line, n->pos, p);
                   mdoc->last->flags = NODE_NOSRC;
                   mdoc->last = n;
                   return;
           }
   
           roff_word_alloc(mdoc, n->line, n->pos, "library");
           mdoc->last->flags = NODE_NOSRC;
           roff_word_alloc(mdoc, n->line, n->pos, "\\(Lq");
           mdoc->last->flags = NODE_DELIMO | NODE_NOSRC;
           mdoc->last = mdoc->last->next;
           roff_word_alloc(mdoc, n->line, n->pos, "\\(Rq");
           mdoc->last->flags = NODE_DELIMC | NODE_NOSRC;
           mdoc->last = n;
   }
   
   static void
   post_rv(POST_ARGS)
   {
           struct roff_node        *n;
           int                      ic;
   
           post_std(mdoc);
   
           n = mdoc->last;
           mdoc->next = ROFF_NEXT_CHILD;
           if (n->child != NULL) {
                   roff_word_alloc(mdoc, n->line, n->pos, "The");
                   mdoc->last->flags |= NODE_NOSRC;
                   ic = build_list(mdoc, MDOC_Fn);
                   roff_word_alloc(mdoc, n->line, n->pos,
                       ic > 1 ? "functions return" : "function returns");
                   mdoc->last->flags |= NODE_NOSRC;
                   roff_word_alloc(mdoc, n->line, n->pos,
                       "the value\\~0 if successful;");
           } else
                   roff_word_alloc(mdoc, n->line, n->pos, "Upon successful "
                       "completion, the value\\~0 is returned;");
           mdoc->last->flags |= NODE_NOSRC;
   
           roff_word_alloc(mdoc, n->line, n->pos, "otherwise "
               "the value\\~\\-1 is returned and the global variable");
           mdoc->last->flags |= NODE_NOSRC;
           roff_elem_alloc(mdoc, n->line, n->pos, MDOC_Va);
           mdoc->last->flags |= NODE_NOSRC;
           roff_word_alloc(mdoc, n->line, n->pos, "errno");
           mdoc->last->flags |= NODE_NOSRC;
           mdoc->last = mdoc->last->parent;
           mdoc->next = ROFF_NEXT_SIBLING;
           roff_word_alloc(mdoc, n->line, n->pos,
               "is set to indicate the error.");
           mdoc->last->flags |= NODE_EOS | NODE_NOSRC;
           mdoc->last = n;
   }
   
   static void
 post_std(POST_ARGS)  post_std(POST_ARGS)
 {  {
         struct roff_node *n;          struct roff_node *n;
Line 663  post_std(POST_ARGS)
Line 821  post_std(POST_ARGS)
 }  }
   
 static void  static void
   post_st(POST_ARGS)
   {
           struct roff_node         *n, *nch;
           const char               *p;
   
           n = mdoc->last;
           nch = n->child;
           assert(nch->type == ROFFT_TEXT);
   
           if ((p = mdoc_a2st(nch->string)) == NULL) {
                   mandoc_vmsg(MANDOCERR_ST_BAD, mdoc->parse,
                       nch->line, nch->pos, "St %s", nch->string);
                   roff_node_delete(mdoc, n);
                   return;
           }
   
           nch->flags |= NODE_NOPRT;
           mdoc->next = ROFF_NEXT_CHILD;
           roff_word_alloc(mdoc, nch->line, nch->pos, p);
           mdoc->last->flags |= NODE_NOSRC;
           mdoc->last= n;
   }
   
   static void
 post_obsolete(POST_ARGS)  post_obsolete(POST_ARGS)
 {  {
         struct roff_node *n;          struct roff_node *n;
Line 673  post_obsolete(POST_ARGS)
Line 855  post_obsolete(POST_ARGS)
                     n->line, n->pos, mdoc_macronames[n->tok]);                      n->line, n->pos, mdoc_macronames[n->tok]);
 }  }
   
   /*
    * Block macros.
    */
   
 static void  static void
 post_bf(POST_ARGS)  post_bf(POST_ARGS)
 {  {
Line 739  post_bf(POST_ARGS)
Line 925  post_bf(POST_ARGS)
 }  }
   
 static void  static void
 post_lb(POST_ARGS)  
 {  
         struct roff_node        *n;  
         const char              *stdlibname;  
         char                    *libname;  
   
         n = mdoc->last->child;  
         assert(n->type == ROFFT_TEXT);  
   
         if (NULL == (stdlibname = mdoc_a2lib(n->string)))  
                 mandoc_asprintf(&libname,  
                     "library \\(Lq%s\\(Rq", n->string);  
         else  
                 libname = mandoc_strdup(stdlibname);  
   
         free(n->string);  
         n->string = libname;  
 }  
   
 static void  
 post_eoln(POST_ARGS)  
 {  
         const struct roff_node *n;  
   
         n = mdoc->last;  
         if (n->child != NULL)  
                 mandoc_vmsg(MANDOCERR_ARG_SKIP,  
                     mdoc->parse, n->line, n->pos,  
                     "%s %s", mdoc_macronames[n->tok],  
                     n->child->string);  
 }  
   
 static void  
 post_fname(POST_ARGS)  post_fname(POST_ARGS)
 {  {
         const struct roff_node  *n;          const struct roff_node  *n;
Line 1449  post_root(POST_ARGS)
Line 1602  post_root(POST_ARGS)
 }  }
   
 static void  static void
 post_st(POST_ARGS)  
 {  
         struct roff_node         *n, *nch;  
         const char               *p;  
   
         n = mdoc->last;  
         nch = n->child;  
   
         assert(nch->type == ROFFT_TEXT);  
   
         if ((p = mdoc_a2st(nch->string)) == NULL) {  
                 mandoc_vmsg(MANDOCERR_ST_BAD, mdoc->parse,  
                     nch->line, nch->pos, "St %s", nch->string);  
                 roff_node_delete(mdoc, n);  
         } else {  
                 free(nch->string);  
                 nch->string = mandoc_strdup(p);  
         }  
 }  
   
 static void  
 post_rs(POST_ARGS)  post_rs(POST_ARGS)
 {  {
         struct roff_node *np, *nch, *next, *prev;          struct roff_node *np, *nch, *next, *prev;
Line 2201  post_os(POST_ARGS)
Line 2333  post_os(POST_ARGS)
         }          }
         mdoc->meta.os = mandoc_strdup(defbuf);          mdoc->meta.os = mandoc_strdup(defbuf);
 #endif /*!OSNAME*/  #endif /*!OSNAME*/
 }  
   
 /*  
  * If no argument is provided,  
  * fill in the name of the current manual page.  
  */  
 static void  
 post_ex(POST_ARGS)  
 {  
         struct roff_node *n;  
   
         post_std(mdoc);  
   
         n = mdoc->last;  
         if (n->child != NULL)  
                 return;  
   
         if (mdoc->meta.name == NULL) {  
                 mandoc_msg(MANDOCERR_EX_NONAME, mdoc->parse,  
                     n->line, n->pos, "Ex");  
                 return;  
         }  
   
         mdoc->next = ROFF_NEXT_CHILD;  
         roff_word_alloc(mdoc, n->line, n->pos, mdoc->meta.name);  
         mdoc->last = n;  
 }  }
   
 enum roff_sec  enum roff_sec

Legend:
Removed from v.1.316  
changed lines
  Added in v.1.317

CVSweb