]> git.cameronkatri.com Git - mandoc.git/blobdiff - tree.c
First, make extra data cells be thrown away. This makes "dp->layout"
[mandoc.git] / tree.c
diff --git a/tree.c b/tree.c
index 17d56843992f7d4502a4585f0553e1291d1a5f57..427a9d4185943468d59c2e38013e7eb39e93c680 100644 (file)
--- a/tree.c
+++ b/tree.c
@@ -1,4 +1,4 @@
-/*     $Id: tree.c,v 1.27 2011/01/01 14:09:21 kristaps Exp $ */
+/*     $Id: tree.c,v 1.32 2011/01/10 14:40:30 kristaps Exp $ */
 /*
  * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
  *
@@ -30,6 +30,7 @@
 
 static void    print_mdoc(const struct mdoc_node *, int);
 static void    print_man(const struct man_node *, int);
+static void    print_span(const struct tbl_span *, int);
 
 
 /* ARGSUSED */
@@ -58,7 +59,6 @@ print_mdoc(const struct mdoc_node *n, int indent)
        size_t            argc, sz;
        char            **params;
        struct mdoc_argv *argv;
-       const struct tbl_dat *dp;
 
        argv = NULL;
        argc = sz = 0;
@@ -136,18 +136,13 @@ print_mdoc(const struct mdoc_node *n, int indent)
                /* NOTREACHED */
        }
 
-       for (i = 0; i < indent; i++)
-               putchar('\t');
-
        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(' ');
-               }
+               print_span(n->span, indent);
        } else {
+               for (i = 0; i < indent; i++)
+                       putchar('\t');
+
                printf("%s (%s)", p, t);
 
                for (i = 0; i < (int)argc; i++) {
@@ -180,7 +175,6 @@ print_man(const struct man_node *n, int indent)
 {
        const char       *p, *t;
        int               i;
-       const struct tbl_dat *dp;
 
        switch (n->type) {
        case (MAN_ROOT):
@@ -234,19 +228,14 @@ print_man(const struct man_node *n, int indent)
                /* NOTREACHED */
        }
 
-       for (i = 0; i < indent; i++)
-               putchar('\t');
-
        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 
+               print_span(n->span, indent);
+       } else {
+               for (i = 0; i < indent; i++)
+                       putchar('\t');
                printf("%s (%s) %d:%d", p, t, n->line, n->pos);
+       }
 
        putchar('\n');
 
@@ -255,3 +244,51 @@ print_man(const struct man_node *n, int indent)
        if (n->next)
                print_man(n->next, indent);
 }
+
+static void
+print_span(const struct tbl_span *sp, int indent)
+{
+       const struct tbl_dat *dp;
+       int              i;
+
+       for (i = 0; i < indent; i++)
+               putchar('\t');
+
+       printf("tbl: ");
+
+       switch (sp->pos) {
+       case (TBL_SPAN_HORIZ):
+               putchar('-');
+               return;
+       case (TBL_SPAN_DHORIZ):
+               putchar('=');
+               return;
+       default:
+               break;
+       }
+
+       for (dp = sp->first; dp; dp = dp->next) {
+               switch (dp->pos) {
+               case (TBL_DATA_HORIZ):
+                       /* FALLTHROUGH */
+               case (TBL_DATA_NHORIZ):
+                       putchar('-');
+                       continue;
+               case (TBL_DATA_DHORIZ):
+                       /* FALLTHROUGH */
+               case (TBL_DATA_NDHORIZ):
+                       putchar('=');
+                       continue;
+               default:
+                       break;
+               }
+               printf("[\"%s\"", dp->string ? dp->string : "");
+               if (dp->spans)
+                       printf("(%d)", dp->spans);
+               if (NULL == dp->layout)
+                       putchar('*');
+               putchar(']');
+               if (dp->next)
+                       putchar(' ');
+       }
+}