It is common for comparison functions to return 0
on "equals", so that they can also return a negative number for "less than" and a positive number for "greater than". strcmp()
and memcmp()
work like this.
It is, however, idiomatic for zero to be false and nonzero to be true, because this is how the C flow control and logical boolean operators work. So it might be that the return values chosen for this function are fine, but it is the function's name that is in error (it should really just be called compare()
or similar).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…