Skip to content

Commit

Permalink
Fix param.valueat at param.name - params are stored in the same order
Browse files Browse the repository at this point in the history
(cherry picked from commit 1f517c3)

Conflicts:
	transformations.c
  • Loading branch information
vladpaiu authored and liviuchircu committed Apr 1, 2015
1 parent 374f688 commit 3e66f6f
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions transformations.c
Expand Up @@ -1455,10 +1455,8 @@ int tr_eval_paramlist(struct sip_msg *msg, tr_param_t *tp, int subtype,
}
n = v.ri;
}
if(n<0)
if(n>=0)
{
n = -n;
n--;
for (pit = _tr_params_list; pit; pit=pit->next)
{
if(n==0)
Expand All @@ -1471,6 +1469,9 @@ int tr_eval_paramlist(struct sip_msg *msg, tr_param_t *tp, int subtype,
} else {
/* ugly hack -- params are in reverse order
* - first count then find */
n = -n;
n--;

i = 0;
for (pit = _tr_params_list; pit; pit=pit->next)
i++;
Expand Down Expand Up @@ -1510,10 +1511,8 @@ int tr_eval_paramlist(struct sip_msg *msg, tr_param_t *tp, int subtype,
}
n = v.ri;
}
if(n<0)
if(n>=0)
{
n = -n;
n--;
for (pit = _tr_params_list; pit; pit=pit->next)
{
if(n==0)
Expand All @@ -1524,8 +1523,11 @@ int tr_eval_paramlist(struct sip_msg *msg, tr_param_t *tp, int subtype,
n--;
}
} else {
/* ugly hack -- params are in reverse order
/* ugly hack -- params are in sorted order
* - first count then find */
n = -n;
n--;

i = 0;
for (pit = _tr_params_list; pit; pit=pit->next)
i++;
Expand All @@ -1548,8 +1550,9 @@ int tr_eval_paramlist(struct sip_msg *msg, tr_param_t *tp, int subtype,

case TR_PL_COUNT:
val->ri = 0;
for (pit = _tr_params_list; pit; pit=pit->next)
for (pit = _tr_params_list; pit; pit=pit->next) {
val->ri++;
}
val->flags = PV_TYPE_INT|PV_VAL_INT|PV_VAL_STR;
val->rs.s = int2str(val->ri, &val->rs.len);
break;
Expand Down

0 comments on commit 3e66f6f

Please sign in to comment.