Mercurial > baum
changeset 30:cd979b979610
fixed multiple (un)indentions in read_input; some better comments
author | meillo@marmaro.de |
---|---|
date | Fri, 22 Feb 2008 14:47:47 +0100 |
parents | 88a51653db83 |
children | 4e60d96265f0 |
files | actions.c baum.c |
diffstat | 2 files changed, 14 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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);
--- 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(); }