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 (2008-03-02)
parents 201b4603671a
children 6e46b106c334
files actions.c baum.c
diffstat 2 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/actions.c	Sun Mar 02 16:26:06 2008 +0100
+++ b/actions.c	Sun Mar 02 16:32:52 2008 +0100
@@ -64,6 +64,8 @@
 
 unsigned char action_sum(struct Node* node) {
 	struct Node* tp;
+
+	node->value = 0;
 	tp = node->down;
 	while (tp != NULL) {
 		node->value += action(tp);
@@ -93,7 +95,6 @@
 		/* return value */
 		input = action(node->down);
 	}
-
 	insertLast(node, newNode("number", (char) input));
 	return 0;
 }
--- a/baum.c	Sun Mar 02 16:26:06 2008 +0100
+++ b/baum.c	Sun Mar 02 16:32:52 2008 +0100
@@ -276,16 +276,16 @@
 	read_input(argv[0]);
 
 	if (option_verbose) {
-		fprintf(stderr, "\n\ntree read from input\n(should be the same without comments and empty lines)\n\n");
-		printTree(root, 0);
+		fprintf(stderr, "\n\ntree read from input:\n");
+		printTree(root, 1);
 	}
 
 	shell_return = action(root);
 	fflush(stdout);
 
 	if (option_verbose) {
-		fprintf(stderr, "\n\ntree after execution of the program\n\n");
-		printTree(root, 0);
+		fprintf(stderr, "\n\nmodified tree after execution:\n");
+		printTree(root, 1);
 	}
 
 	delete(root);