sbase

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

commit 3debc5e064987974f0dfc098f29ae6a48b712a4d
parent 698a14b1da7a9e425ed76a125fb1824376068740
Author: FRIGN <dev@frign.de>
Date:   Mon,  7 Mar 2016 11:00:47 +0100

Add linecmp()

Diffstat:
Alibutil/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; +}