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
patterndb: Add support for nested quotted string in @QSTRING@ #4717
Conversation
This user does not have permission to start the build. Can one of the admins verify this patch and start the build? |
1 similar comment
This user does not have permission to start the build. Can one of the admins verify this patch and start the build? |
@kira-syslogng test this please |
ba7805b
to
6068885
Compare
Ooops, fixed! |
|
||
if ((end = strchr(str + 1, ((gchar *)&state)[0])) != NULL) | ||
while (*end) |
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.
while this works I'd try to retain the simplified case where you don't have separate starting/ending quotes.
strchr() is probably much faster than the loop implemented here.
e.g. I'd create two functions, one for the simple case, one for the nested case and decide which one to call in a wrapper that checks param[0] and param[1]
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.
I like this a lot, thanks for contributing it and I don't think that this needs a separate parser. Previously QSTRING did not support quote pairs, and you just added it as a new feature, which also happens to support nesting.
The syntax we implemented in db-parser() is not the best one, but this change retains conventions and is not breaking compatibility.
When using 2 chars to match quoted strings (e.g. `(), `[]`, `{}`), we want to detect nesting to capture the whole containing expression. Matching `(foo (bar (baz) qux)) quux` against `@QSTRING::()@` previously captured `(foo (bar (baz)` and now capture `(foo (bar (baz) qux))`. Fixes: syslog-ng#4716 Signed-off-by: Romain Tartière <romain@blogreen.org>
6068885
to
afbe526
Compare
I think it did, I use it 😁 I split the code in 2 distinct functions as suggested, makes it a bit more readable. |
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.
Approved. Thanks a lot.
Before merging, could you please add a NEWS file snippet? I am not sure if this can still get into 4.5.0 which is being prepared right now: #4719 |
Let's include this one in v4.5.0. We'll add the entry manually. |
When using 2 chars to match quoted strings (e.g.
(),
[],
{}`), wewant to detect nesting to capture the whole containing expression.
Matching
(foo (bar (baz) qux)) quux
against@QSTRING::()@
previouslycaptured
(foo (bar (baz)
and now capture(foo (bar (baz) qux))
.Fixes: #4716
Signed-off-by: Romain Tartière romain@blogreen.org