-/* $Id: tree.c,v 1.41 2011/07/21 13:37:04 kristaps Exp $ */
+/* $Id: tree.c,v 1.47 2011/09/18 14:14:15 schwarze Exp $ */
/*
- * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2008, 2009, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
#endif
#include <assert.h>
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
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):
- printf("eqn-root(%d, %d)\n",
- ep->font, ep->mark);
- print_box(ep->child, indent + 1);
+ t = "eqn-root";
+ break;
+ case (EQN_LIST):
+ t = "eqn-list";
break;
case (EQN_SUBEXPR):
- printf("eqn-subxpr(%d, %d)\n",
- ep->font, ep->mark);
- print_box(ep->child, indent + 1);
+ t = "eqn-expr";
break;
case (EQN_TEXT):
- printf("eqn-text(%d, %d): [%s]\n",
- ep->font, ep->mark, ep->text);
+ t = "eqn-text";
break;
- default:
+ 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);
}