sbase

suckless unix tools
git clone git://git.2f30.org/sbase.git
Log | Files | Refs | README | LICENSE

commit 2fea92166391362145771066f956a1bbddec3023
parent c568edc487f4ea76a2110bad9ab924903d654ea8
Author: FRIGN <dev@frign.de>
Date:   Thu Mar 10 20:12:56 +0100

Fix linecmp() to return correct values

Diffstat:
libutil/linecmp.c | 12++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/libutil/linecmp.c b/libutil/linecmp.c @@ -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;