Fix linecmp() to return correct values
This commit is contained in:
parent
0b87cd4c61
commit
515525997c
|
@ -10,10 +10,14 @@ linecmp(struct line *a, struct line *b)
|
||||||
{
|
{
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
if (!(res = memcmp(a->data, b->data, MIN(a->len, b->len))) &&
|
if (!(res = memcmp(a->data, b->data, MIN(a->len, b->len)))) {
|
||||||
a->len != b->len) {
|
if (a->len > b->len) {
|
||||||
res = a->data[MIN(a->len, b->len) - 1] -
|
res = a->data[b->len];
|
||||||
b->data[MIN(a->len, b->len) - 1];
|
} else if (b->len > a->len) {
|
||||||
|
res = -b->data[a->len];
|
||||||
|
} else {
|
||||||
|
res = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user