Fix linecmp() to return correct values

This commit is contained in:
FRIGN 2016-03-10 20:12:56 +01:00 committed by sin
parent 0b87cd4c61
commit 515525997c

View File

@ -10,10 +10,14 @@ linecmp(struct line *a, struct line *b)
{
int res = 0;
if (!(res = memcmp(a->data, b->data, MIN(a->len, b->len))) &&
a->len != b->len) {
res = a->data[MIN(a->len, b->len) - 1] -
b->data[MIN(a->len, b->len) - 1];
if (!(res = memcmp(a->data, b->data, MIN(a->len, b->len)))) {
if (a->len > b->len) {
res = a->data[b->len];
} else if (b->len > a->len) {
res = -b->data[a->len];
} else {
res = 0;
}
}
return res;