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

Avoid using GNU extensions in the dependency splitter regex #1617

Merged

Conversation

markjdb
Copy link
Contributor

@markjdb markjdb commented Aug 24, 2023

Sticking to POSIX-compatible extended regular expressions makes the code more portable. In particular, this change is required to avoid an abort at load time on FreeBSD.

No functional change intended.

markjdb added a commit to markjdb/freebsd-ports that referenced this pull request Aug 24, 2023
Our regex implementation doesn't implement \s or \S, so libdnf.so cannot
be loaded as it throws an exception when RELDEP_REGEX is compiled.  For
instance, "dnf --version" simply aborts without printing anything.

Submitted upstream as a pull request:
rpm-software-management/libdnf#1617

Sponsored by:	Klara, Inc.
@@ -29,7 +29,7 @@
namespace libdnf {

static const Regex RELDEP_REGEX =
Regex("^(\\S*)\\s*(<=|>=|<|>|=|==)?\\s*(\\S*)$", REG_EXTENDED);
Regex("^([^[:space:]]*)[[:space:]]*(<=|>=|<|>|=|==)?[[:space:]]*([^[:space:]]*)$", REG_EXTENDED);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. It's never come to my mind that there might be a compatibility problem with '\s'.
Does it make sense to leave a comment here? Just to remind future maintainers who might feel tempted to "simplify" the regex by putting \s back.

Would you mind filing a similar PR also for dnf5 (next generation of dnf)?
https://github.com/rpm-software-management/dnf5/blob/e2aa5eead7589e65994b2f971f63d5d64b88d421/libdnf5/solv/reldep_parser.cpp#L30

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to leave a comment here?

Sure, I updated the diff.

Would you mind filing a similar PR also for dnf5 (next generation of dnf)?

Certainly: rpm-software-management/dnf5#843

@m-blaha m-blaha self-assigned this Aug 28, 2023
Sticking to POSIX-compatible extended regular expressions makes the code
more portable.  In particular, this change is required to avoid an abort
at load time on FreeBSD.

No functional change intended.
Copy link
Member

@m-blaha m-blaha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much!

@m-blaha m-blaha merged commit 31ed3e7 into rpm-software-management:dnf-4-master Aug 29, 2023
3 checks passed
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

2 participants