[OpenSIPS/opensips] f3abf6: cfg syntax: Disallow esoteric if/while syntax

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[OpenSIPS/opensips] f3abf6: cfg syntax: Disallow esoteric if/while syntax

Liviu Chircu-3
  Branch: refs/heads/feature/improve-cfg-syntax
  Home:   https://github.com/OpenSIPS/opensips
  Commit: f3abf690a54f36edff08d2929d7634c7f5484761
      https://github.com/OpenSIPS/opensips/commit/f3abf690a54f36edff08d2929d7634c7f5484761
  Author: Liviu Chircu <[hidden email]>
  Date:   2019-07-27 (Sat, 27 Jul 2019)

  Changed paths:
    M cfg.y

  Log Message:
  -----------
  cfg syntax: Disallow esoteric if/while syntax

The opensips.cfg no longer accepts constructs such as:

    if $var(foo) {
        ...
    }

    if [ $var(foo) == 2 ]
        xlog("bar\n");

    while $var(foo) < 10 {
        ...
    }

... and forces the condition to be paranthesized.  Aside from any
consistency considerations, this change also allows us to disambiguate
the if-if-else shift/reduce conflicts of the grammar, which were so far
masked using the "expect 2" rule.


  Commit: b2b4f48a153fb37929014bff20a72ba4972414f8
      https://github.com/OpenSIPS/opensips/commit/b2b4f48a153fb37929014bff20a72ba4972414f8
  Author: Liviu Chircu <[hidden email]>
  Date:   2019-07-27 (Sat, 27 Jul 2019)

  Changed paths:
    M cfg.y

  Log Message:
  -----------
  cfg syntax:  Enhance the 'return' statement

The opensips.cfg now additionally allows syntax such as:

    * return 1;
    * return +2;
    * return -3;
    * return $var(foo);


  Commit: 71fef11495168442718f5db61680abf48abf794d
      https://github.com/OpenSIPS/opensips/commit/71fef11495168442718f5db61680abf48abf794d
  Author: Liviu Chircu <[hidden email]>
  Date:   2019-07-27 (Sat, 27 Jul 2019)

  Changed paths:
    M action.c
    M route_struct.h

  Log Message:
  -----------
  cfg syntax: Fix all complex assignment operators

The opensips.cfg now fully supports the non-trivial assignment
operators, such as: +=, -=, *=, /=, %=, &=, |= and ^=.  Syntactially,
they were supported until now, but were actually unimplemented (more
precisely, they were equivalent to the "=" operator).

Only the "+=" operator can also work with strings, for example:

    $var(x) = "foo";
    $var(x) += "-bar"; # now contains "foo-bar"

    $rU = "+40";
    $rU += "729" + "884950"; # now contains "+40729884950"

All of them (including "+="), work with integers:

    $var(i) = 0;
    $var(i) += 2; # 2
    $var(i) *= 3; # 6
    $var(i) /= 6; # 1
    ...


Compare: https://github.com/OpenSIPS/opensips/compare/f3abf690a54f%5E...71fef1149516

_______________________________________________
Devel mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/devel