X-Git-Url: https://git.cameronkatri.com/mandoc.git/blobdiff_plain/175c51d9a38aa43801777db95c54f0d7abf91092..efe798f445e86ad7dd7d47627c75150c3af43497:/tree.c

diff --git a/tree.c b/tree.c
index a446fb14..fdb70e1b 100644
--- a/tree.c
+++ b/tree.c
@@ -1,6 +1,7 @@
-/*	$Id: tree.c,v 1.38 2011/07/21 11:34:53 kristaps Exp $ */
+/*	$Id: tree.c,v 1.50 2013/12/24 19:11:46 schwarze Exp $ */
 /*
- * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2008, 2009, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2013 Ingo Schwarze <schwarze@openbsd.org>
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -19,6 +20,7 @@
 #endif
 
 #include <assert.h>
+#include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <time.h>
@@ -57,13 +59,11 @@ print_mdoc(const struct mdoc_node *n, int indent)
 {
 	const char	 *p, *t;
 	int		  i, j;
-	size_t		  argc, sz;
-	char		**params;
+	size_t		  argc;
 	struct mdoc_argv *argv;
 
 	argv = NULL;
-	argc = sz = 0;
-	params = NULL;
+	argc = 0;
 	t = p = NULL;
 
 	switch (n->type) {
@@ -160,11 +160,14 @@ print_mdoc(const struct mdoc_node *n, int indent)
 			if (argv[i].sz > 0)
 				printf(" ]");
 		}
-		
-		for (i = 0; i < (int)sz; i++)
-			printf(" [%s]", params[i]);
 
-		printf(" %d:%d\n", n->line, n->pos);
+		putchar(' ');
+		if (MDOC_LINE & n->flags)
+			putchar('*');
+		printf("%d:%d", n->line, n->pos);
+		if (n->lastline != n->line)
+			printf("-%d", n->lastline);
+		putchar('\n');
 	}
 
 	if (n->child)
@@ -262,24 +265,42 @@ static void
 print_box(const struct eqn_box *ep, int indent)
 {
 	int		 i;
+	const char	*t;
 
 	if (NULL == ep)
 		return;
 	for (i = 0; i < indent; i++)
 		putchar('\t');
 
+	t = NULL;
 	switch (ep->type) {
 	case (EQN_ROOT):
-		puts("eqn-root");
-		print_box(ep->child, indent + 1);
-		return;
+		t = "eqn-root";
+		break;
+	case (EQN_LIST):
+		t = "eqn-list";
+		break;
+	case (EQN_SUBEXPR):
+		t = "eqn-expr";
+		break;
 	case (EQN_TEXT):
-		printf("eqn-text: [%s]\n", ep->text);
-		print_box(ep->next, indent);
-		return;
-	default:
+		t = "eqn-text";
+		break;
+	case (EQN_MATRIX):
+		t = "eqn-matrix";
 		break;
 	}
+
+	assert(t);
+	printf("%s(%d, %d, %d, %d, %d, \"%s\", \"%s\") %s\n", 
+		t, EQN_DEFSIZE == ep->size ? 0 : ep->size,
+		ep->pos, ep->font, ep->mark, ep->pile, 
+		ep->left ? ep->left : "",
+		ep->right ? ep->right : "",
+		ep->text ? ep->text : "");
+
+	print_box(ep->first, indent + 1);
+	print_box(ep->next, indent);
 }
 
 static void