HomeClusterLabs Projects

Refactor: libcrmcommon: Use regex for pcmk__compare_versions()
44d161ecffb5Unpublished

Unpublished Commit ยท Learn More

Not On Permanent Ref: This commit is not an ancestor of any permanent ref.

Description

Refactor: libcrmcommon: Use regex for pcmk__compare_versions()

Seems a bit more readable and a bit less error-prone, even though it's
less efficient.

I started out trying to use a GRegex, which works great except that it
requires freeing and reallocating a GMatchInfo struct every time you
reuse the regex to match a later offset of the same string. We don't
need the fancy PCRE features anyway.

I started working on an implementation that just uses
pcmk__numeric_strcasecmp(), but it started getting ugly for things like
"1" vs. "1.0", since it treats all non-digit characters equally (in
particular, it doesn't treat dots specially).

pcmk__compare_versions() could also reasonable go into strings.c, by the
way.

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>

Details

Provenance
nrwahl2Authored on Mar 25 2025, 3:44 AM
Parents
rPc2b55235a5f8: Refactor: libcrmcommon: New pcmk__compare_versions()
Branches
Unknown
Tags
Unknown

Event Timeline