changeset 34:e986c6abed2b

eliminated generic blackhole node at root
author meillo@marmaro.de
date Sat, 01 Mar 2008 17:45:55 +0100
parents 2e564bf8599c
children 3e93e66ff8d3
files baum.c
diffstat 1 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/baum.c	Sat Mar 01 17:36:59 2008 +0100
+++ b/baum.c	Sat Mar 01 17:45:55 2008 +0100
@@ -138,8 +138,7 @@
 	strcpy(name, "");
 	value = 0;
 	last_indent = -1;
-	root = newNode("blackhole", 0);
-	last_node = root;
+	last_node = NULL;
 	file = fopen(filename, "r");
 
 	while ((c = getc(file)) != EOF) {
@@ -167,7 +166,12 @@
 						fprintf(stderr, "error: Indention over more than one level. Only indent by one!\n");
 						exit(5);
 					}
-					last_node->down = node;
+					if (last_node == NULL) {
+						root = node;
+						last_node = root;
+					} else {
+						last_node->down = node;
+					}
 					push(last_node);
 				} else if (indent == last_indent) { /* right */
 					last_node->right = node;
@@ -263,6 +267,7 @@
 	}
 
 	shell_return = action(root);
+	fflush(stdout);
 
 	if (option_verbose) {
 		printTree(root, 0);