Added support for inverted regexps

This commit is contained in:
Olof hagsand 2019-05-29 14:39:36 +02:00
parent 2fe185d683
commit 5706703ab4
9 changed files with 68 additions and 50 deletions

View file

@ -287,21 +287,30 @@ yang2cli_var_pattern(clicon_handle h,
char *mode;
cg_var *cvp;
char *pattern;
int invert;
char *posix;
mode = clicon_yang_regexp(h);
cvp = NULL; /* Loop over compiled regexps */
while ((cvp = cvec_each(patterns, cvp)) != NULL){
pattern = cv_string_get(cvp);
invert = cv_flag(cvp, V_INVERT);
if (strcmp(mode, "posix") == 0){
char *posix = NULL;
posix = NULL;
if (regexp_xsd2posix(pattern, &posix) < 0)
goto done;
cprintf(cb, " regexp:\"%s\"", posix);
if (posix)
cprintf(cb, " regexp:%s\"%s\"",
invert?"!":"",
posix);
if (posix){
free(posix);
posix = NULL;
}
}
else
cprintf(cb, " regexp:\"%s\"", pattern);
cprintf(cb, " regexp:%s\"%s\"",
invert?"!":"",
pattern);
}
retval = 0;
done: