Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avpops: avp_subst() support pvar as subst parameter #2158

Merged
merged 2 commits into from Jan 3, 2020

Conversation

linuxmaniac
Copy link
Member

Pre-Submission Checklist

  • Commit message has the format required by CONTRIBUTING guide
  • Commits are split per component (core, individual modules, libs, utils, ...)
  • Each component has a single commit (if not, squash them into one commit)
  • No commits to README files for modules (changes must be done to docbook files
    in doc/ subfolder, the README file is autogenerated)

Type Of Change

  • Small bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds new functionality)
  • Breaking change (fix or feature that would change existing functionality)

Checklist:

  • PR should be backported to stable branches
  • Tested changes locally

Description

Allow pvar as second parameter of avp_subst() function

@miconda
Copy link
Member

miconda commented Dec 2, 2019

Looking further at this patch, it requires to have the second parameter as a single variable to be considered with "pvar" support, because I see you search for / in the second parameter. It makes it support like:

$var(se) = "/abc/xyz/";
avp_subst("$avp(x)", "$var(se)");

Right now it supports PV in the replacement part of the subst expression, not allowing in the match/regexp part.

Maybe is better to just add a new function that will always evaluate the subst parameter with variables, allowing more flexible format for subst parameter. At the end, you just need to have your added code in a dedicated function that evaluates first the parameter and then compiles the subst expression.

So we can have:

avp_susbtx("$avp(x)", "/$fU/$rU/g");

Allowing also:

$var(se) = "/" + $fU + "/" + $rU + "/g";
avp_substx("$avp(x)", "$var(se)");

The new function can have a different name than avp_substx(), I used to exemplify here.

sipwiser and others added 2 commits December 13, 2019 08:48
* same functionality as avp_subst() but second parameter
  will be evaluated before calling subst.
@linuxmaniac
Copy link
Member Author

Added avp_subst_pv() and now this is supported:

    $(avp(src)[*]) = "testME";
    $var(x) = "/e/j/gi";
    avp_subst_pv("$avp(src)", "$var(x)");

    $var(z) = "j";
    $var(y) = "e";
    $var(x) = "/" + $var(y) + "/" + $var(z) + "/gi";
    avp_subst_pv("$avp(src)", "$var(x)");
    avp_subst_pv("$avp(src)", "/$var(y)/$var(z)/gi");
    avp_subst_pv("$avp(src)", "/" + $var(y) + "/" + $var(z) + "/gi");
    avp_subst_pv("$avp(src)", "/e/j/gi");

@henningw
Copy link
Contributor

Is this is still work in progress or could be merged?

@linuxmaniac
Copy link
Member Author

I'm waiting for feedback. No more changes from my side.

@miconda
Copy link
Member

miconda commented Jan 2, 2020

It is a new function now, it can be merged.

@linuxmaniac linuxmaniac merged commit 5c8ddbc into master Jan 3, 2020
@linuxmaniac linuxmaniac deleted the vseva/avpops_subst branch January 3, 2020 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants