Browse code

core: return & break are absorbed in expressions

return & break inside an expression do not cause the current route
block or while/switch statement to end.
E.g.: $v = { return 1; } will not end the current route, will
only set $v to 1.

Andrei Pelinescu-Onciul authored on 29/09/2010 15:35:25
Showing 2 changed files
... ...
@@ -107,9 +107,11 @@ inline static int lval_avp_assign(struct run_act_ctx* h, struct sip_msg* msg,
107 107
 			break;
108 108
 		case RV_ACTION_ST:
109 109
 			flags=avp->type & ~AVP_VAL_STR;
110
-			if (rv->v.action)
110
+			if (rv->v.action) {
111 111
 				value.n=run_actions_safe(h, rv->v.action, msg);
112
-			else
112
+				h->run_flags &= ~(RETURN_R_F|BREAK_R_F); /* catch return &
113
+														    break in expr*/
114
+			} else
113 115
 				value.n=-1;
114 116
 			ret=value.n;
115 117
 			break;
... ...
@@ -282,9 +284,11 @@ inline static int lval_pvar_assign(struct run_act_ctx* h, struct sip_msg* msg,
282 282
 			break;
283 283
 		case RV_ACTION_ST:
284 284
 			pval.flags=PV_TYPE_INT|PV_VAL_INT;
285
-			if (rv->v.action)
285
+			if (rv->v.action) {
286 286
 				pval.ri=run_actions_safe(h, rv->v.action, msg);
287
-			else
287
+				h->run_flags &= ~(RETURN_R_F|BREAK_R_F); /* catch return &
288
+														    break in expr*/
289
+			} else
288 290
 				pval.ri=0;
289 291
 			ret=pval.ri;
290 292
 			break;
... ...
@@ -900,9 +900,11 @@ int rval_get_int(struct run_act_ctx* h, struct sip_msg* msg,
900 900
 			}
901 901
 			break;
902 902
 		case RV_ACTION_ST:
903
-			if (rv->v.action)
903
+			if (rv->v.action) {
904 904
 				*i=(run_actions_safe(h, rv->v.action, msg)>0);
905
-			else
905
+				h->run_flags &= ~(RETURN_R_F|BREAK_R_F); /* catch return &
906
+														    break in expr*/
907
+			} else
906 908
 				*i=0;
907 909
 			break;
908 910
 		case RV_SEL:
... ...
@@ -1099,9 +1101,11 @@ int rval_get_tmp_str(struct run_act_ctx* h, struct sip_msg* msg,
1099 1099
 			*tmpv=rv->v.s;
1100 1100
 			break;
1101 1101
 		case RV_ACTION_ST:
1102
-			if (rv->v.action)
1102
+			if (rv->v.action) {
1103 1103
 				i=(run_actions_safe(h, rv->v.action, msg)>0);
1104
-			else
1104
+				h->run_flags &= ~(RETURN_R_F|BREAK_R_F); /* catch return &
1105
+														    break in expr*/
1106
+			} else
1105 1107
 				i=0;
1106 1108
 			tmpv->s=sint2strbuf(i, tmp_cache->i2s,
1107 1109
 								sizeof(tmp_cache->i2s), &tmpv->len);