Add linecmp()
This commit is contained in:
parent
698a14b1da
commit
3debc5e064
20
libutil/linecmp.c
Normal file
20
libutil/linecmp.c
Normal file
@ -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;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user