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 diff
     1.1 --- a/actions.c	Fri Feb 22 13:55:57 2008 +0100
     1.2 +++ b/actions.c	Fri Feb 22 14:47:47 2008 +0100
     1.3 @@ -93,7 +93,7 @@
     1.4  	unsigned char i;
     1.5  	tp = node->down;
     1.6  	for (i = 0; i < node->value; i++) {
     1.7 -		/* deep copy */
     1.8 +		/* FIXME deep copy */
     1.9  		last = insertLast(node, newNode(tp->name, tp->value));
    1.10  		if (tp->down != NULL) {
    1.11  			last->down = newNode(tp->down->name, tp->down->value);
     2.1 --- a/baum.c	Fri Feb 22 13:55:57 2008 +0100
     2.2 +++ b/baum.c	Fri Feb 22 14:47:47 2008 +0100
     2.3 @@ -16,6 +16,7 @@
     2.4  
     2.5  #define VERSION "0.2"
     2.6  
     2.7 +
     2.8  int option_check = 0;
     2.9  int option_verbose = 0;
    2.10  
    2.11 @@ -110,7 +111,7 @@
    2.12  
    2.13  
    2.14  
    2.15 -/* read tree stack */
    2.16 +/* stack for read_input */
    2.17  void push(struct Node* node) {
    2.18  	struct Stackitem* tmp;
    2.19  	struct Stackitem* new;
    2.20 @@ -174,14 +175,21 @@
    2.21  				/* create node */
    2.22  				node = newNode((char*) name, value);
    2.23  				if (indent > last_indent) { /* down */
    2.24 -					/* FIXME if it goes more than one level down -> error */
    2.25 +					/* if it goes more than one level down -> error */
    2.26 +					if (indent - last_indent > 1) {
    2.27 +						fprintf(stderr, "error: Indention over more than one level. Only indent by one!\n");
    2.28 +						exit(50);
    2.29 +					}
    2.30  					last_node->down = node;
    2.31  					push(last_node);
    2.32  				} else if (indent == last_indent) { /* right */
    2.33  					last_node->right = node;
    2.34  				} else if (indent < last_indent) { /* up */
    2.35 -					/* FIXME handle if it goes more than one level up */
    2.36 -					last_node = pull();
    2.37 +					/* handle if it goes more than one level up */
    2.38 +					while (indent < last_indent) {
    2.39 +						last_node = pull();
    2.40 +						last_indent--;
    2.41 +					}
    2.42  					last_node->right = node;
    2.43  				}
    2.44  				last_indent = indent;
    2.45 @@ -211,7 +219,7 @@
    2.46  
    2.47  	}
    2.48  
    2.49 -	/* empty stack */
    2.50 +	/* clear stack */
    2.51  	while (stack != NULL) {
    2.52  		pull();
    2.53  	}