This function parses and compares two strings to see which one seems to represent the greater "version". It splits the strings into pieces that are digits and pieces that are anything else. e.g. "utility-24.9_5 pkg v4.5" becomes "utility-" 24 "." 9 "_" 5 " pkg v" 4 "." 5
A new version might be: "utility-24.10_5 pkg v4.5"
Each component is compared. If both corresponding components are "integer chunks" they are compared using "<" and ">" - that means that 10 becomes greater than 9. If either component is not "integer" then string comparison is done. This makes the ordinary string changes work as expected and also stuff like "1.05" and "1.1" - a change like this will be seen as an upgrade.
Not that I have left the string comparison case-sensitive. If someone making their version string changes the "fixed text" they have put in the version string then anything is possible :) It is a bit difficult to guess all of that.
Also if people use alphabetic versioning that does not follow strcmp() sort order then there is always trouble - it works by luck with "-BETA" then "-RELEASE" because the English words happen to sort as expected.
Provide compare_pkg_versions
This function parses and compares two strings to see which one seems to represent the greater "version". It splits the strings into pieces that are digits and pieces that are anything else. e.g.
"utility-24.9_5 pkg v4.5"
becomes
"utility-"
24
"."
9
"_"
5
" pkg v"
4
"."
5
A new version might be:
"utility-24.10_5 pkg v4.5"
Each component is compared.
If both corresponding components are "integer chunks" they are compared using "<" and ">" - that means that 10 becomes greater than 9.
If either component is not "integer" then string comparison is done. This makes the ordinary string changes work as expected and also stuff like "1.05" and "1.1" - a change like this will be seen as an upgrade.
Not that I have left the string comparison case-sensitive. If someone making their version string changes the "fixed text" they have put in the version string then anything is possible :) It is a bit difficult to guess all of that.
Also if people use alphabetic versioning that does not follow strcmp() sort order then there is always trouble - it works by luck with "-BETA" then "-RELEASE" because the English words happen to sort as expected.