# HG changeset patch # User meillo@marmaro.de # Date 1203688067 -3600 # Node ID cd979b979610c3e78a7b4f3e73caaf61ef42f364 # Parent 88a51653db83d865886da188040c77ee7ba27fee fixed multiple (un)indentions in read_input; some better comments diff -r 88a51653db83 -r cd979b979610 actions.c --- a/actions.c Fri Feb 22 13:55:57 2008 +0100 +++ b/actions.c Fri Feb 22 14:47:47 2008 +0100 @@ -93,7 +93,7 @@ unsigned char i; tp = node->down; for (i = 0; i < node->value; i++) { - /* deep copy */ + /* FIXME deep copy */ last = insertLast(node, newNode(tp->name, tp->value)); if (tp->down != NULL) { last->down = newNode(tp->down->name, tp->down->value); diff -r 88a51653db83 -r cd979b979610 baum.c --- a/baum.c Fri Feb 22 13:55:57 2008 +0100 +++ b/baum.c Fri Feb 22 14:47:47 2008 +0100 @@ -16,6 +16,7 @@ #define VERSION "0.2" + int option_check = 0; int option_verbose = 0; @@ -110,7 +111,7 @@ -/* read tree stack */ +/* stack for read_input */ void push(struct Node* node) { struct Stackitem* tmp; struct Stackitem* new; @@ -174,14 +175,21 @@ /* create node */ node = newNode((char*) name, value); if (indent > last_indent) { /* down */ - /* FIXME if it goes more than one level down -> error */ + /* if it goes more than one level down -> error */ + if (indent - last_indent > 1) { + fprintf(stderr, "error: Indention over more than one level. Only indent by one!\n"); + exit(50); + } last_node->down = node; push(last_node); } else if (indent == last_indent) { /* right */ last_node->right = node; } else if (indent < last_indent) { /* up */ - /* FIXME handle if it goes more than one level up */ - last_node = pull(); + /* handle if it goes more than one level up */ + while (indent < last_indent) { + last_node = pull(); + last_indent--; + } last_node->right = node; } last_indent = indent; @@ -211,7 +219,7 @@ } - /* empty stack */ + /* clear stack */ while (stack != NULL) { pull(); }