source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Make -Ttree spit out table columns.
@ 2011-01-01 13:54 kristaps
  0 siblings, 0 replies; only message in thread
From: kristaps @ 2011-01-01 13:54 UTC (permalink / raw)
  To: source

Log Message:
-----------
Make -Ttree spit out table columns.

Add forgotten assignment of span to -man's TBL nodes.

Modified Files:
--------------
    mdocml:
        man.c
        tree.c

Revision Data
-------------
Index: man.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man.c,v
retrieving revision 1.94
retrieving revision 1.95
diff -Lman.c -Lman.c -u -p -r1.94 -r1.95
--- man.c
+++ man.c
@@ -301,6 +301,7 @@ man_span_alloc(struct man *m, const stru
 
 	/* FIXME: grab from span */
 	n = man_node_alloc(0, 0, MAN_TBL, MAN_MAX);
+	n->span = span;
 
 	if ( ! man_node_append(m, n))
 		return(0);
Index: tree.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/tree.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -Ltree.c -Ltree.c -u -p -r1.25 -r1.26
--- tree.c
+++ tree.c
@@ -58,6 +58,7 @@ print_mdoc(const struct mdoc_node *n, in
 	size_t		  argc, sz;
 	char		**params;
 	struct mdoc_argv *argv;
+	const struct tbl_dat *dp;
 
 	argv = NULL;
 	argc = sz = 0;
@@ -96,6 +97,8 @@ print_mdoc(const struct mdoc_node *n, in
 		/* NOTREACHED */
 	}
 
+	p = NULL;
+
 	switch (n->type) {
 	case (MDOC_TEXT):
 		p = n->string;
@@ -124,7 +127,6 @@ print_mdoc(const struct mdoc_node *n, in
 		}
 		break;
 	case (MDOC_TBL):
-		p = "tbl";
 		break;
 	case (MDOC_ROOT):
 		p = "root";
@@ -135,23 +137,36 @@ print_mdoc(const struct mdoc_node *n, in
 	}
 
 	for (i = 0; i < indent; i++)
-		(void)printf("    ");
-	(void)printf("%s (%s)", p, t);
+		putchar('\t');
 
-	for (i = 0; i < (int)argc; i++) {
-		(void)printf(" -%s", mdoc_argnames[argv[i].arg]);
-		if (argv[i].sz > 0)
-			(void)printf(" [");
-		for (j = 0; j < (int)argv[i].sz; j++)
-			(void)printf(" [%s]", argv[i].value[j]);
-		if (argv[i].sz > 0)
-			(void)printf(" ]");
-	}
+	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)", p, t);
+
+		for (i = 0; i < (int)argc; 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]);
 
-	for (i = 0; i < (int)sz; i++)
-		(void)printf(" [%s]", params[i]);
+		printf(" %d:%d", n->line, n->pos);
+	}
 
-	(void)printf(" %d:%d\n", n->line, n->pos);
+	putchar('\n');
 
 	if (n->child)
 		print_mdoc(n->child, indent + 1);
@@ -165,6 +180,7 @@ print_man(const struct man_node *n, int 
 {
 	const char	 *p, *t;
 	int		  i;
+	const struct tbl_dat *dp;
 
 	switch (n->type) {
 	case (MAN_ROOT):
@@ -193,6 +209,8 @@ print_man(const struct man_node *n, int 
 		/* NOTREACHED */
 	}
 
+	p = NULL;
+
 	switch (n->type) {
 	case (MAN_TEXT):
 		p = n->string;
@@ -210,7 +228,6 @@ print_man(const struct man_node *n, int 
 		p = "root";
 		break;
 	case (MAN_TBL):
-		p = "tbl";
 		break;
 	default:
 		abort();
@@ -218,8 +235,19 @@ print_man(const struct man_node *n, int 
 	}
 
 	for (i = 0; i < indent; i++)
-		(void)printf("    ");
-	(void)printf("%s (%s) %d:%d\n", p, t, n->line, n->pos);
+		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 
+		printf("%s (%s) %d:%d", p, t, n->line, n->pos);
+
+	putchar('\n');
 
 	if (n->child)
 		print_man(n->child, indent + 1);
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-01-01 13:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-01 13:54 mdocml: Make -Ttree spit out table columns kristaps

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).