sbase

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

commit c405152c29fe5e6d9c4be269e211835ebe7cb325
parent da56cc0598f839b0c35a3a4dcc2dda33c734a54b
Author: FRIGN <dev@frign.de>
Date:   Mon Mar  7 11:00:47 +0100

Add linecmp()

Diffstat:
libutil/linecmp.c | 20++++++++++++++++++++
1 file changed, 20 insertions(+), 0 deletions(-)
diff --git a/libutil/linecmp.c b/libutil/linecmp.c @@ -0,0 +1,20 @@ +/* See LICENSE file for copyright and license details. */ +#include <stdio.h> +#include <string.h> + +#include "../text.h" +#include "../util.h" + +int +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]; + } + + return res; +}