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.
(cherry picked from commit 65b64bca77b18f7ee964119e1b3b363d66189c3e)

Andrei Pelinescu-Onciul authored on 29/09/2010 15:35:25
Showing 2 changed files
... ...
@@ -100,9 +100,11 @@ inline static int lval_avp_assign(struct run_act_ctx* h, struct sip_msg* msg,
100 100
 			break;
101 101
 		case RV_ACTION_ST:
102 102
 			flags=avp->type & ~AVP_VAL_STR;
103
-			if (rv->v.action)
103
+			if (rv->v.action) {
104 104
 				value.n=run_actions_safe(h, rv->v.action, msg);
105
-			else
105
+				h->run_flags &= ~(RETURN_R_F|BREAK_R_F); /* catch return &
106
+														    break in expr*/
107
+			} else
106 108
 				value.n=-1;
107 109
 			ret=value.n;
108 110
 			break;
... ...
@@ -275,9 +277,11 @@ inline static int lval_pvar_assign(struct run_act_ctx* h, struct sip_msg* msg,
275 275
 			break;
276 276
 		case RV_ACTION_ST:
277 277
 			pval.flags=PV_TYPE_INT|PV_VAL_INT;
278
-			if (rv->v.action)
278
+			if (rv->v.action) {
279 279
 				pval.ri=run_actions_safe(h, rv->v.action, msg);
280
-			else
280
+				h->run_flags &= ~(RETURN_R_F|BREAK_R_F); /* catch return &
281
+														    break in expr*/
282
+			} else
281 283
 				pval.ri=0;
282 284
 			ret=pval.ri;
283 285
 			break;
... ...
@@ -893,9 +893,11 @@ int rval_get_int(struct run_act_ctx* h, struct sip_msg* msg,
893 893
 			}
894 894
 			break;
895 895
 		case RV_ACTION_ST:
896
-			if (rv->v.action)
896
+			if (rv->v.action) {
897 897
 				*i=(run_actions_safe(h, rv->v.action, msg)>0);
898
-			else
898
+				h->run_flags &= ~(RETURN_R_F|BREAK_R_F); /* catch return &
899
+														    break in expr*/
900
+			} else
899 901
 				*i=0;
900 902
 			break;
901 903
 		case RV_SEL:
... ...
@@ -1088,9 +1090,11 @@ int rval_get_tmp_str(struct run_act_ctx* h, struct sip_msg* msg,
1088 1088
 			*tmpv=rv->v.s;
1089 1089
 			break;
1090 1090
 		case RV_ACTION_ST:
1091
-			if (rv->v.action)
1091
+			if (rv->v.action) {
1092 1092
 				i=(run_actions_safe(h, rv->v.action, msg)>0);
1093
-			else
1093
+				h->run_flags &= ~(RETURN_R_F|BREAK_R_F); /* catch return &
1094
+														    break in expr*/
1095
+			} else
1094 1096
 				i=0;
1095 1097
 			tmpv->s=int2str(i, &tmpv->len);
1096 1098
 			break;