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

Diff for /mandoc/tree.c between version 1.17 and 1.27

version 1.17, 2009/10/26 17:05:44 version 1.27, 2011/01/01 14:09:21
Line 1 
Line 1 
 /*      $Id$ */  /*      $Id$ */
 /*  /*
  * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>   * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
  *   *
  * Permission to use, copy, modify, and distribute this software for any   * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above   * purpose with or without fee is hereby granted, provided that the above
Line 14 
Line 14 
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF   * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.   * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */   */
   #ifdef HAVE_CONFIG_H
   #include "config.h"
   #endif
   
 #include <assert.h>  #include <assert.h>
 #include <err.h>  
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
 #include <time.h>  #include <time.h>
   
   #include "mandoc.h"
 #include "mdoc.h"  #include "mdoc.h"
 #include "man.h"  #include "man.h"
 #include "main.h"  #include "main.h"
Line 54  print_mdoc(const struct mdoc_node *n, int indent)
Line 58  print_mdoc(const struct mdoc_node *n, int indent)
         size_t            argc, sz;          size_t            argc, sz;
         char            **params;          char            **params;
         struct mdoc_argv *argv;          struct mdoc_argv *argv;
           const struct tbl_dat *dp;
   
         argv = NULL;          argv = NULL;
         argc = sz = 0;          argc = sz = 0;
Line 70  print_mdoc(const struct mdoc_node *n, int indent)
Line 75  print_mdoc(const struct mdoc_node *n, int indent)
                 t = "block-head";                  t = "block-head";
                 break;                  break;
         case (MDOC_BODY):          case (MDOC_BODY):
                 t = "block-body";                  if (n->end)
                           t = "body-end";
                   else
                           t = "block-body";
                 break;                  break;
         case (MDOC_TAIL):          case (MDOC_TAIL):
                 t = "block-tail";                  t = "block-tail";
Line 81  print_mdoc(const struct mdoc_node *n, int indent)
Line 89  print_mdoc(const struct mdoc_node *n, int indent)
         case (MDOC_TEXT):          case (MDOC_TEXT):
                 t = "text";                  t = "text";
                 break;                  break;
           case (MDOC_TBL):
                   t = "tbl";
                   break;
         default:          default:
                 abort();                  abort();
                 /* NOTREACHED */                  /* NOTREACHED */
         }          }
   
           p = NULL;
   
         switch (n->type) {          switch (n->type) {
         case (MDOC_TEXT):          case (MDOC_TEXT):
                 p = n->string;                  p = n->string;
Line 113  print_mdoc(const struct mdoc_node *n, int indent)
Line 126  print_mdoc(const struct mdoc_node *n, int indent)
                         argc = n->args->argc;                          argc = n->args->argc;
                 }                  }
                 break;                  break;
           case (MDOC_TBL):
                   break;
         case (MDOC_ROOT):          case (MDOC_ROOT):
                 p = "root";                  p = "root";
                 break;                  break;
Line 122  print_mdoc(const struct mdoc_node *n, int indent)
Line 137  print_mdoc(const struct mdoc_node *n, int indent)
         }          }
   
         for (i = 0; i < indent; i++)          for (i = 0; i < indent; i++)
                 (void)printf("    ");                  putchar('\t');
         (void)printf("%s (%s)", p, t);  
   
         for (i = 0; i < (int)argc; i++) {          if (n->span) {
                 (void)printf(" -%s", mdoc_argnames[argv[i].arg]);                  assert(NULL == p);
                 if (argv[i].sz > 0)                  printf("tbl: ");
                         (void)printf(" [");                  for (dp = n->span->first; dp; dp = dp->next) {
                 for (j = 0; j < (int)argv[i].sz; j++)                          printf("[%s]", dp->string);
                         (void)printf(" [%s]", argv[i].value[j]);                          if (dp->next)
                 if (argv[i].sz > 0)                                  putchar(' ');
                         (void)printf(" ]");                  }
         }          } else {
                   printf("%s (%s)", p, t);
   
         for (i = 0; i < (int)sz; i++)                  for (i = 0; i < (int)argc; i++) {
                 (void)printf(" [%s]", params[i]);                          printf(" -%s", mdoc_argnames[argv[i].arg]);
                           if (argv[i].sz > 0)
                                   printf(" [");
                           for (j = 0; j < (int)argv[i].sz; j++)
                                   printf(" [%s]", argv[i].value[j]);
                           if (argv[i].sz > 0)
                                   printf(" ]");
                   }
   
                   for (i = 0; i < (int)sz; i++)
                           printf(" [%s]", params[i]);
   
         (void)printf(" %d:%d\n", n->line, n->pos);                  printf(" %d:%d", n->line, n->pos);
           }
   
           putchar('\n');
   
         if (n->child)          if (n->child)
                 print_mdoc(n->child, indent + 1);                  print_mdoc(n->child, indent + 1);
         if (n->next)          if (n->next)
Line 152  print_man(const struct man_node *n, int indent)
Line 180  print_man(const struct man_node *n, int indent)
 {  {
         const char       *p, *t;          const char       *p, *t;
         int               i;          int               i;
           const struct tbl_dat *dp;
   
         switch (n->type) {          switch (n->type) {
         case (MAN_ROOT):          case (MAN_ROOT):
Line 172  print_man(const struct man_node *n, int indent)
Line 201  print_man(const struct man_node *n, int indent)
         case (MAN_BODY):          case (MAN_BODY):
                 t = "block-body";                  t = "block-body";
                 break;                  break;
           case (MAN_TBL):
                   t = "tbl";
                   break;
         default:          default:
                 abort();                  abort();
                 /* NOTREACHED */                  /* NOTREACHED */
         }          }
   
           p = NULL;
   
         switch (n->type) {          switch (n->type) {
         case (MAN_TEXT):          case (MAN_TEXT):
                 p = n->string;                  p = n->string;
Line 193  print_man(const struct man_node *n, int indent)
Line 227  print_man(const struct man_node *n, int indent)
         case (MAN_ROOT):          case (MAN_ROOT):
                 p = "root";                  p = "root";
                 break;                  break;
           case (MAN_TBL):
                   break;
         default:          default:
                 abort();                  abort();
                 /* NOTREACHED */                  /* NOTREACHED */
         }          }
   
         for (i = 0; i < indent; i++)          for (i = 0; i < indent; i++)
                 (void)printf("    ");                  putchar('\t');
         (void)printf("%s (%s) %d:%d\n", p, t, n->line, n->pos);  
           if (n->span) {
                   assert(NULL == p);
                   printf("tbl: ");
                   for (dp = n->span->first; dp; dp = dp->next) {
                           printf("[%s]", dp->string);
                           if (dp->next)
                                   putchar(' ');
                   }
           } else
                   printf("%s (%s) %d:%d", p, t, n->line, n->pos);
   
           putchar('\n');
   
         if (n->child)          if (n->child)
                 print_man(n->child, indent + 1);                  print_man(n->child, indent + 1);

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.27

CVSweb