-
Notifications
You must be signed in to change notification settings - Fork 449
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
Scheduler: allow negation of regular expressions in plan class XML specs (standard) #4529
base: dpa_regex
Are you sure you want to change the base?
Conversation
I think this should work, but I'm not a C++ guy so I won't merge this. Thanks for taking your time to mod the original PR! |
@Rytiss I think this implementation / modification comes closest to our original intentions of negation of regex. I wanted to have this ready before your original proposal becomes implemented. Thanks @davidpanderson for taking the time for the previous implementation, factoring out these regex as a separate datatype was valuable. However I didn't test this yet very much, due to lack of time and opportunity, and I didn't look much around in that code, in particular where the C-Strings that are manipulated there originate from. Certainly there is potential for an accidental error (probably off-by-one) in my modification. And we recently came across trouble with storing ( |
@bema-aei, I'll check c++ code (without logic behind it) |
@@ -33,13 +33,17 @@ int REGEX_CLAUSE::init(const char* p) { | |||
present = true; | |||
negate = false; | |||
expr = p; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here copy constructor will be called
p++; | ||
if (!strncmp(p,"(?!",3) && p[strlen(p)-1] == ')') { | ||
p += 3; | ||
p[strlen(p)-1] = '\0'; // don't parse trailing ')' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point data at expr
will not be changed, because you're modifying the original data piece that has nothing common with expr
at all.
If this is done by intention - then it's fine.
negate = true; | ||
} | ||
if (regcomp(®ex, p, REG_EXTENDED|REG_NOSUB) ) { | ||
return ERR_XML_PARSE; | ||
} | ||
if (negate) { | ||
p[strlen(p)] = ')'; // restore trailing ')' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here the same as above: data stored in expr
will not be modified.
Reference: https://godbolt.org/z/r1szzY9rr |
This MR is an extension of #4390 with the changes discussed but not (yet) implemented there, i.e. using the standard
(?!regex)
as proposed by @Rytiss instead of the simple but non-standard!regex
proposed by me and implemented by @davidpanderson . The branch is based on David'sdpa_regex
with an extra commit.