[OpenSIPS-Users] switch / case behaviour
Bogdan-Andrei Iancu
bogdan at opensips.org
Thu Apr 12 16:09:35 EDT 2018
+1
Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
http://www.opensips-solutions.com
OpenSIPS Summit 2018
http://www.opensips.org/events/Summit-2018Amsterdam
On 04/12/2018 02:00 PM, Liviu Chircu wrote:
>
> Hi Richard,
>
> IMO, that looks like a slip-up which has been probably lurking in
> there since the very beginnings. I suggest we should fix it to match
> the expected behavior of switch/case/default for most (all?)
> programming languages which are out there. It would be interesting to
> hear other opinions as well before we act, though.
>
> Cheers,
>
> Liviu Chircu
> OpenSIPS Developer
> http://www.opensips-solutions.com
> On 09.04.2018 16:38, Richard Revels wrote:
>> I am unsure of the expected behaviour in the config switch / case
>> block when the break is not defined between a defined case and the
>> default case but what I'm seeing right now is not what I expect.
>> Wanted to get some input before opening a bug tracker on it.
>>
>> --code--
>> route[testswitch]
>> {
>> switch( $avp(testvalue) )
>> {
>> case "defined break":
>> xlog("L_INFO", "log only this line \n");
>> break;
>>
>> case "non defined break":
>> xlog("L_INFO", "log this line and fall through to also
>> and then to default \n");
>>
>> case "also non defined":
>> xlog("L_INFO", "log this line and fall through to default
>> \n");
>>
>> default:
>> xlog("L_ERR", "log default line \n");
>> }
>> xlog("L_ERR", "at end of switch block with $avp(testvalue) \n");
>> }
>>
>> ...
>>
>> $avp(testvalue) := "defined break";
>> route(testswitch);
>> $avp(testvalue) := "non defined break";
>> route(testswitch);
>> $avp(testvalue) := "also non defined";
>> route(testswitch);
>> $avp(testvalue) := "non defined value";
>> route(testswitch);
>>
>> --end code--
>>
>> --log--
>>
>> 2018-04-09T13:13:28.092141+00:00 pidflo-01 /sbin/opensips[25651]: log
>> only this line
>> 2018-04-09T13:13:28.092150+00:00 pidflo-01 /sbin/opensips[25651]: at
>> end of switch block with defined break
>> 2018-04-09T13:13:28.092158+00:00 pidflo-01 /sbin/opensips[25651]: log
>> this line and fall through to also and then to default
>> 2018-04-09T13:13:28.092161+00:00 pidflo-01 /sbin/opensips[25651]: log
>> this line and fall through to default
>> 2018-04-09T13:13:28.092164+00:00 pidflo-01 /sbin/opensips[25651]: at
>> end of switch block with non defined break
>> 2018-04-09T13:13:28.092168+00:00 pidflo-01 /sbin/opensips[25651]: log
>> this line and fall through to default
>> 2018-04-09T13:13:28.092171+00:00 pidflo-01 /sbin/opensips[25651]: at
>> end of switch block with also non defined
>> 2018-04-09T13:13:28.092176+00:00 pidflo-01 /sbin/opensips[25651]: log
>> default line
>> 2018-04-09T13:13:28.092179+00:00 pidflo-01 /sbin/opensips[25651]: at
>> end of switch block with non defined value
>>
>> --end log--
>>
>>
>>
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.opensips.org
>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
>
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20180412/62f4a67b/attachment.html>
More information about the Users
mailing list