HomeClusterLabs Projects

Refactor: libcrmcommon: Use regex for pcmk__compare_versions()
6219d94f4a47Unpublished

Unpublished Commit ยท Learn More

Not On Permanent Ref: This commit is not an ancestor of any permanent ref.
This commit no longer exists in the repository. It may have been part of a branch which was deleted.This commit has been deleted in the repository: it is no longer reachable from any branch, tag, or 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

Event Timeline

Commit No Longer Exists

This commit no longer exists in the repository.