Module: sip-router
Branch: master
Commit: 65b64bca77b18f7ee964119e1b3b363d66189c3e
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=65b64bc…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)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.
---
lvalue.c | 12 ++++++++----
rvalue.c | 12 ++++++++----
2 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/lvalue.c b/lvalue.c
index 47a625f..a8dcbd9 100644
--- a/lvalue.c
+++ b/lvalue.c
@@ -107,9 +107,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;
@@ -282,9 +284,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 6ef399b..9195972 100644
--- a/rvalue.c
+++ b/rvalue.c
@@ -900,9 +900,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:
@@ -1099,9 +1101,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=sint2strbuf(i, tmp_cache->i2s,
sizeof(tmp_cache->i2s), &tmpv->len);