]> git.cameronkatri.com Git - mandoc.git/blobdiff - tree.c
Switch on the `TS' documentation in roff.7. As per off-line discussion,
[mandoc.git] / tree.c
diff --git a/tree.c b/tree.c
index ee0f1576014b1d0357b1e6d13d68c8007209d36c..70bd73d9ef27dc7ed15e56fe0c235839c0e39f71 100644 (file)
--- a/tree.c
+++ b/tree.c
@@ -1,4 +1,4 @@
-/*     $Id: tree.c,v 1.26 2011/01/01 13:54:58 kristaps Exp $ */
+/*     $Id: tree.c,v 1.31 2011/01/03 13:59:21 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,18 +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);
-               for (dp = n->span->first; dp; dp = dp->next) {
-                       printf("tbl: [%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');
 
@@ -254,3 +244,46 @@ 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%s]", dp->string, dp->layout ?  "" : "*");
+               if (dp->next)
+                       putchar(' ');
+       }
+}