MCPcopy Create free account
hub / github.com/Kitware/CMake / VersionCompare

Function VersionCompare

Source/cmSystemTools.cxx:3761–3815  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3759
3760namespace {
3761bool VersionCompare(cmSystemTools::CompareOp op, char const* lhss,
3762 char const* rhss)
3763{
3764 char const* endl = lhss;
3765 char const* endr = rhss;
3766
3767 while (((*endl >= '0') && (*endl <= '9')) ||
3768 ((*endr >= '0') && (*endr <= '9'))) {
3769 // Do component-wise comparison, ignoring leading zeros
3770 // (components are treated as integers, not as mantissas)
3771 while (*endl == '0') {
3772 endl++;
3773 }
3774 while (*endr == '0') {
3775 endr++;
3776 }
3777
3778 char const* beginl = endl;
3779 char const* beginr = endr;
3780
3781 // count significant digits
3782 while ((*endl >= '0') && (*endl <= '9')) {
3783 endl++;
3784 }
3785 while ((*endr >= '0') && (*endr <= '9')) {
3786 endr++;
3787 }
3788
3789 // compare number of digits first
3790 ptrdiff_t r = ((endl - beginl) - (endr - beginr));
3791 if (r == 0) {
3792 // compare the digits if number of digits is equal
3793 r = strncmp(beginl, beginr, endl - beginl);
3794 }
3795
3796 if (r < 0) {
3797 // lhs < rhs, so true if operation is LESS
3798 return (op & cmSystemTools::OP_LESS) != 0;
3799 }
3800 if (r > 0) {
3801 // lhs > rhs, so true if operation is GREATER
3802 return (op & cmSystemTools::OP_GREATER) != 0;
3803 }
3804
3805 if (*endr == '.') {
3806 endr++;
3807 }
3808
3809 if (*endl == '.') {
3810 endl++;
3811 }
3812 }
3813 // lhs == rhs, so true if operation is EQUAL
3814 return (op & cmSystemTools::OP_EQUAL) != 0;
3815}
3816}
3817
3818bool cmSystemTools::VersionCompare(cmSystemTools::CompareOp op,

Callers 15

LLVMFuzzerTestOneInputFunction · 0.85
HandleLevel2Method · 0.85
GenerateMethod · 0.85
AddLanguageFlagsMethod · 0.85
EvaluateWithLanguageMethod · 0.85
EvaluateMethod · 0.85
CheckNMakeFeaturesMethod · 0.85
GenerateMethod · 0.85
CheckNinjaFeaturesMethod · 0.85
GenerateMethod · 0.85
WriteCompilersMethod · 0.85
AddCompilerMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…