This project is read-only.

Possible bug? VssRevProps CompareTo

Feb 9, 2012 at 3:55 PM

Hi, 

I think I've spotted a possible bug in VssRevProps::CompareTo

This functions is used to compare two structures which contain the time, comment and author of a change.  As far as I'm aware, the function should return 0 if the time, comment and author of both structures are identical, otherwise it should return -1 or +1.

The bug is in the comparison:

if (p.Time == Time)
{    
if (string.Compare(p.Author, Author, true) == 0 && string.Compare(p.Comment, Comment) == 0)
return 0;                   
return string.Compare(p.Author, Author, true);
}

If the times are equal, this will return 0 if the p.Author and Author are equal and pComment and Comment are equal.  This makes sense.
But, if p.Comment and Comment aren't equal, then it drops out of the "if" but it still returns 0 if p.Author and Author are equal.

So, in plain English, if the times and authors in both structure are the same, and the comment isn't, it will still return zero. 

 

Should this not be:

if (p.Time == Time)
{    
if (string.Compare(p.Author, Author, true) == 0)                   
return string.Compare(p.Comment, Comment, true);

       return string.Compare(p.Author, Author, true);
}

Like most people on here, I'm new to the code (though it looks like a brilliant solution to moving VSS to SVN), so any comment on my possible bug find would be appreciated (I may have mis-read the code, so please excuse me if I have.

Many thanks,

Dave