baum
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 diff
1.1 --- a/baum.c Sat Mar 01 17:36:59 2008 +0100 1.2 +++ b/baum.c Sat Mar 01 17:45:55 2008 +0100 1.3 @@ -138,8 +138,7 @@ 1.4 strcpy(name, ""); 1.5 value = 0; 1.6 last_indent = -1; 1.7 - root = newNode("blackhole", 0); 1.8 - last_node = root; 1.9 + last_node = NULL; 1.10 file = fopen(filename, "r"); 1.11 1.12 while ((c = getc(file)) != EOF) { 1.13 @@ -167,7 +166,12 @@ 1.14 fprintf(stderr, "error: Indention over more than one level. Only indent by one!\n"); 1.15 exit(5); 1.16 } 1.17 - last_node->down = node; 1.18 + if (last_node == NULL) { 1.19 + root = node; 1.20 + last_node = root; 1.21 + } else { 1.22 + last_node->down = node; 1.23 + } 1.24 push(last_node); 1.25 } else if (indent == last_indent) { /* right */ 1.26 last_node->right = node; 1.27 @@ -263,6 +267,7 @@ 1.28 } 1.29 1.30 shell_return = action(root); 1.31 + fflush(stdout); 1.32 1.33 if (option_verbose) { 1.34 printTree(root, 0);