[OpenSIPS-Devel] [OpenSIPS/opensips] 72fba8: cfg syntax: Disallow esoteric if/while syntax

Liviu Chircu noreply at github.com
Fri Feb 7 10:42:52 EST 2020


  Branch: refs/heads/master
  Home:   https://github.com/OpenSIPS/opensips
  Commit: 72fba84168046ef3b6100db9df9dd88c43b68fbd
      https://github.com/OpenSIPS/opensips/commit/72fba84168046ef3b6100db9df9dd88c43b68fbd
  Author: Liviu Chircu <liviu at opensips.org>
  Date:   2020-02-07 (Fri, 07 Feb 2020)

  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: 536e7b065e5480a17c0bd4c97248aed6b52641ea
      https://github.com/OpenSIPS/opensips/commit/536e7b065e5480a17c0bd4c97248aed6b52641ea
  Author: Liviu Chircu <liviu at opensips.org>
  Date:   2020-02-07 (Fri, 07 Feb 2020)

  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: 628a126fe3523e800440855f10f9841d6a2c39eb
      https://github.com/OpenSIPS/opensips/commit/628a126fe3523e800440855f10f9841d6a2c39eb
  Author: Liviu Chircu <liviu at opensips.org>
  Date:   2020-02-07 (Fri, 07 Feb 2020)

  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/a9e45e8e0e9f...628a126fe352



More information about the Devel mailing list