[BACK]Return to tree.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Diff for /mandoc/tree.c between version 1.9 and 1.10

version 1.9, 2009/03/19 16:20:37 version 1.10, 2009/03/23 15:20:51
Line 22 
Line 22 
 #include <stdlib.h>  #include <stdlib.h>
   
 #include "mdoc.h"  #include "mdoc.h"
   #include "man.h"
   
 static  void    tree_body(const struct mdoc_node *, int);  static  void    tree_mdoc(const struct mdoc_node *, int);
   static  void    tree_man(const struct man_node *, int);
   
   
 /* ARGSUSED */  /* ARGSUSED */
 int  int
 tree_run(void *arg, const struct mdoc *mdoc)  tree_run(void *arg, const struct man *man,
                   const struct mdoc *mdoc)
 {  {
   
         tree_body(mdoc_node(mdoc), 0);          if (man)
                   tree_man(man_node(man), 0);
           if (mdoc)
                   tree_mdoc(mdoc_node(mdoc), 0);
         return(1);          return(1);
 }  }
   
   
 static void  static void
 tree_body(const struct mdoc_node *n, int indent)  tree_mdoc(const struct mdoc_node *n, int indent)
 {  {
         const char       *p, *t;          const char       *p, *t;
         int               i, j;          int               i, j;
Line 131  tree_body(const struct mdoc_node *n, int indent)
Line 137  tree_body(const struct mdoc_node *n, int indent)
         (void)printf(" %d:%d\n", n->line, n->pos);          (void)printf(" %d:%d\n", n->line, n->pos);
   
         if (n->child)          if (n->child)
                 tree_body(n->child, indent + 1);                  tree_mdoc(n->child, indent + 1);
         if (n->next)          if (n->next)
                 tree_body(n->next, indent);                  tree_mdoc(n->next, indent);
 }  }
   
   
   static void
   tree_man(const struct man_node *n, int indent)
   {
           const char       *p, *t;
           int               i;
   
           switch (n->type) {
           case (MAN_ROOT):
                   t = "root";
                   break;
           case (MAN_ELEM):
                   t = "elem";
                   break;
           case (MAN_TEXT):
                   t = "text";
                   break;
           default:
                   abort();
                   /* NOTREACHED */
           }
   
           switch (n->type) {
           case (MAN_TEXT):
                   p = n->string;
                   break;
           case (MAN_ELEM):
                   p = man_macronames[n->tok];
                   break;
           case (MAN_ROOT):
                   p = "root";
                   break;
           default:
                   abort();
                   /* NOTREACHED */
           }
   
           for (i = 0; i < indent; i++)
                   (void)printf("    ");
           (void)printf("%s (%s) %d:%d\n", p, t, n->line, n->pos);
   
           if (n->child)
                   tree_man(n->child, indent + 1);
           if (n->next)
                   tree_man(n->next, indent);
   }

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

CVSweb