baum

changeset 53:036779d5da75

"sum" node clears its value now everytime it gets called
author meillo@marmaro.de
date Sun, 02 Mar 2008 16:32:52 +0100
parents 201b4603671a
children 6e46b106c334
files actions.c baum.c
diffstat 2 files changed, 6 insertions(+), 5 deletions(-) [+]
line diff
     1.1 --- a/actions.c	Sun Mar 02 16:26:06 2008 +0100
     1.2 +++ b/actions.c	Sun Mar 02 16:32:52 2008 +0100
     1.3 @@ -64,6 +64,8 @@
     1.4  
     1.5  unsigned char action_sum(struct Node* node) {
     1.6  	struct Node* tp;
     1.7 +
     1.8 +	node->value = 0;
     1.9  	tp = node->down;
    1.10  	while (tp != NULL) {
    1.11  		node->value += action(tp);
    1.12 @@ -93,7 +95,6 @@
    1.13  		/* return value */
    1.14  		input = action(node->down);
    1.15  	}
    1.16 -
    1.17  	insertLast(node, newNode("number", (char) input));
    1.18  	return 0;
    1.19  }
     2.1 --- a/baum.c	Sun Mar 02 16:26:06 2008 +0100
     2.2 +++ b/baum.c	Sun Mar 02 16:32:52 2008 +0100
     2.3 @@ -276,16 +276,16 @@
     2.4  	read_input(argv[0]);
     2.5  
     2.6  	if (option_verbose) {
     2.7 -		fprintf(stderr, "\n\ntree read from input\n(should be the same without comments and empty lines)\n\n");
     2.8 -		printTree(root, 0);
     2.9 +		fprintf(stderr, "\n\ntree read from input:\n");
    2.10 +		printTree(root, 1);
    2.11  	}
    2.12  
    2.13  	shell_return = action(root);
    2.14  	fflush(stdout);
    2.15  
    2.16  	if (option_verbose) {
    2.17 -		fprintf(stderr, "\n\ntree after execution of the program\n\n");
    2.18 -		printTree(root, 0);
    2.19 +		fprintf(stderr, "\n\nmodified tree after execution:\n");
    2.20 +		printTree(root, 1);
    2.21  	}
    2.22  
    2.23  	delete(root);