changeset 16:3808a6ffc881

Fix logical bug walk_code_tree() and duplicate function calls
author Thinker K.F. Li <thinker@codemud.net>
date Fri, 10 Sep 2010 12:04:40 +0800
parents cf0d24827624
children 2bf246207140
files src/cospy.c
diffstat 1 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/cospy.c	Fri Sep 10 11:43:43 2010 +0800
+++ b/src/cospy.c	Fri Sep 10 12:04:40 2010 +0800
@@ -141,11 +141,10 @@
     if(expr == NULL)
 	return;
     
+    if(visit && TREE_VISITED(expr))
+	return;
     TREE_VISITED(expr) = visit;
     
-    if(TREE_VISITED(expr))
-	return;
-
     code = TREE_CODE(expr);
 
     if(cb && (accept_code == -1 || code == accept_code))
@@ -457,6 +456,9 @@
 	   EXPR_FILENAME(expr),
 	   EXPR_LINENO(expr),
 	   TREE_CODE(parent));
+
+    /* Do a function call twice */
+    tree_insert_before(expr, expr, parent);
 }
 
 /*! \brief Find all call expression in a code block.