[sr-dev] git:sr_3.0: core: return & break are absorbed in expressions
Andrei Pelinescu-Onciul
andrei at iptel.org
Mon Oct 11 11:26:28 CEST 2010
Module: sip-router
Branch: sr_3.0
Commit: db863ff6c6851cec23b3a66ce7d404e2a2ad1515
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=db863ff6c6851cec23b3a66ce7d404e2a2ad1515
Author: Andrei Pelinescu-Onciul <andrei at iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei at iptel.org>
Date: Wed Sep 29 17:35:25 2010 +0200
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)
---
lvalue.c | 12 ++++++++----
rvalue.c | 12 ++++++++----
2 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/lvalue.c b/lvalue.c
index 4f4e501..9b55244 100644
--- a/lvalue.c
+++ b/lvalue.c
@@ -100,9 +100,11 @@ inline static int lval_avp_assign(struct run_act_ctx* h, struct sip_msg* msg,
break;
case RV_ACTION_ST:
flags=avp->type & ~AVP_VAL_STR;
- if (rv->v.action)
+ if (rv->v.action) {
value.n=run_actions_safe(h, rv->v.action, msg);
- else
+ h->run_flags &= ~(RETURN_R_F|BREAK_R_F); /* catch return &
+ break in expr*/
+ } else
value.n=-1;
ret=value.n;
break;
@@ -275,9 +277,11 @@ inline static int lval_pvar_assign(struct run_act_ctx* h, struct sip_msg* msg,
break;
case RV_ACTION_ST:
pval.flags=PV_TYPE_INT|PV_VAL_INT;
- if (rv->v.action)
+ if (rv->v.action) {
pval.ri=run_actions_safe(h, rv->v.action, msg);
- else
+ h->run_flags &= ~(RETURN_R_F|BREAK_R_F); /* catch return &
+ break in expr*/
+ } else
pval.ri=0;
ret=pval.ri;
break;
diff --git a/rvalue.c b/rvalue.c
index f9ba65c..1821afd 100644
--- a/rvalue.c
+++ b/rvalue.c
@@ -893,9 +893,11 @@ int rval_get_int(struct run_act_ctx* h, struct sip_msg* msg,
}
break;
case RV_ACTION_ST:
- if (rv->v.action)
+ if (rv->v.action) {
*i=(run_actions_safe(h, rv->v.action, msg)>0);
- else
+ h->run_flags &= ~(RETURN_R_F|BREAK_R_F); /* catch return &
+ break in expr*/
+ } else
*i=0;
break;
case RV_SEL:
@@ -1088,9 +1090,11 @@ int rval_get_tmp_str(struct run_act_ctx* h, struct sip_msg* msg,
*tmpv=rv->v.s;
break;
case RV_ACTION_ST:
- if (rv->v.action)
+ if (rv->v.action) {
i=(run_actions_safe(h, rv->v.action, msg)>0);
- else
+ h->run_flags &= ~(RETURN_R_F|BREAK_R_F); /* catch return &
+ break in expr*/
+ } else
i=0;
tmpv->s=int2str(i, &tmpv->len);
break;
More information about the sr-dev
mailing list