#109 version_compare() update based on strtoi_c()

0.61
closed
None
2
2016-12-11
2005-05-18
No

If the previous patch for strtoi_c() is accepted, then this
can be fixed in routine version_compare() located in file
filter.cpp

This allows version_compare() to reject large values such
as 123456789

the diff file is based on today's CVS (May 17,2005)

----suggested update (filter.cpp)-------
static PosibErr<int> version_compare(const char * x,
const char * y)
{
do {
int xn = 0, yn = 0;
if (*x) {
if (!asc_isdigit(*x) || ((xn = strtoi_c(x, &x)) < 0))
return make_err(bad_version_string);
}
if (*y) {
if (!asc_isdigit(*y) || ((yn = strtoi_c(y, &y)) < 0))
return make_err(bad_version_string);
}
int diff = xn - yn;
if (diff != 0) return diff;
if (*x) {
if (*x != '.') return make_err(bad_version_string);
++x;}
if (*y) {
if (*y != '.') return make_err(bad_version_string);
++y;}
} while (*x || *y);
return 0;
}

Discussion

  • Jose Da Silva

    Jose Da Silva - 2005-05-18

    patch to allow testing for large numbers

     
  • Kevin Atkinson

    Kevin Atkinson - 2005-05-20
    • priority: 5 --> 2
    • assigned_to: nobody --> kevina
    • status: open --> open-later
     
  • Kevin Atkinson

    Kevin Atkinson - 2011-06-26
    • milestone: --> 0.61
     
  • Kevin Atkinson

    Kevin Atkinson - 2016-12-11
    • Status: open-later --> closed
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks