Browse code

core expr eval: string == fix

- fixed typo which made == the same as != for strings
- minor optimizations debugging messages fixes

Andrei Pelinescu-Onciul authored on 05/05/2009 17:17:12
Showing 1 changed files
... ...
@@ -2792,6 +2792,7 @@ static int rve_opt_01(struct rval_expr* rve, enum rval_type rve_type)
2792 2792
 	enum rval_expr_op op;
2793 2793
 	struct cfg_pos pos;
2794 2794
 	int right; /* debugging msg */
2795
+	int dbg; /* debugging msg on/off */
2795 2796
 
2796 2797
 /* helper macro: replace in-place a <ctype> type rve with v (another rve).
2797 2798
  * if type_of(v)== <ctype> => rve:=*v (copy v contents into rve and free v)
... ...
@@ -2827,6 +2828,7 @@ static int rve_opt_01(struct rval_expr* rve, enum rval_type rve_type)
2827 2827
 	rv=0;
2828 2828
 	ret=0;
2829 2829
 	right=0;
2830
+	dbg=1;
2830 2831
 	
2831 2832
 	if (rve_is_constant(rve->right.rve)){
2832 2833
 		ct_rve=rve->right.rve;
... ...
@@ -2967,7 +2969,7 @@ static int rve_opt_01(struct rval_expr* rve, enum rval_type rve_type)
2967 2967
 				break;
2968 2968
 		}
2969 2969
 		/* debugging messages */
2970
-		if (ret==1){
2970
+		if (ret==1 && dbg){
2971 2971
 			if (right){
2972 2972
 				if (rve->op==RVE_RVAL_OP){
2973 2973
 					if (rve->left.rval.type==RV_INT)
... ...
@@ -3062,11 +3064,13 @@ static int rve_opt_01(struct rval_expr* rve, enum rval_type rve_type)
3062 3062
 					rve->left.rve=v_rve;
3063 3063
 					rve->right.rve=0;
3064 3064
 					ret=1;
3065
-					DBG("FIXUP RVE: (%d,%d-%d,%d) optimized"
3065
+					if (dbg)
3066
+						DBG("FIXUP RVE: (%d,%d-%d,%d) optimized"
3066 3067
 								" op%d($v, \"\") -> strempty($v)\n", 
3067 3068
 								rve->fpos.s_line, rve->fpos.s_col,
3068 3069
 								rve->fpos.e_line, rve->fpos.e_col,
3069 3070
 								op);
3071
+					dbg=0;
3070 3072
 				}
3071 3073
 				break;
3072 3074
 			default:
... ...
@@ -3078,7 +3082,7 @@ static int rve_opt_01(struct rval_expr* rve, enum rval_type rve_type)
3078 3078
 	    can be determined only at runtime => we cannot optimize */
3079 3079
 		
3080 3080
 		/* debugging messages */
3081
-		if (ret==1){
3081
+		if (ret==1 && dbg){
3082 3082
 			if (right){
3083 3083
 				if (rve->op==RVE_RVAL_OP){
3084 3084
 					if (rve->left.rval.type==RV_STR)
... ...
@@ -3259,12 +3263,11 @@ static int rve_optimize(struct rval_expr* rve)
3259 3259
 			l_type=rve_guess_type(rve->left.rve);
3260 3260
 			if (l_type==RV_INT){
3261 3261
 				rve->op=(rve->op==RVE_EQ_OP)?RVE_IEQ_OP:RVE_IDIFF_OP;
3262
-				DBG("FIXUP RVE (%d,%d-%d,%d): changed ==/!= into interger"
3262
+				DBG("FIXUP RVE (%d,%d-%d,%d): changed ==/!= into integer"
3263 3263
 						" ==/!=\n",
3264 3264
 						rve->fpos.s_line, rve->fpos.s_col,
3265 3265
 						rve->fpos.e_line, rve->fpos.e_col);
3266 3266
 			}else if (l_type==RV_STR){
3267
-				rve->op=RVE_CONCAT_OP;
3268 3267
 				rve->op=(rve->op==RVE_EQ_OP)?RVE_STREQ_OP:RVE_STRDIFF_OP;
3269 3268
 				DBG("FIXUP RVE (%d,%d-%d,%d): changed ==/!= into string"
3270 3269
 						" ==/!=\n",