[hackers] [sbase] Add linecmp() || FRIGN

From: <git_AT_suckless.org>
Date: Thu, 10 Mar 2016 09:48:18 +0100 (CET)

commit 3debc5e064987974f0dfc098f29ae6a48b712a4d
Author: FRIGN <dev_AT_frign.de>
AuthorDate: Mon Mar 7 11:00:47 2016 +0100
Commit: sin <sin_AT_2f30.org>
CommitDate: Thu Mar 10 08:48:09 2016 +0000

    Add linecmp()

diff --git a/libutil/linecmp.c b/libutil/linecmp.c
new file mode 100644
index 0000000..cba27d1
--- /dev/null
+++ b/libutil/linecmp.c
_AT_@ -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;
+}
Received on Thu Mar 10 2016 - 09:48:18 CET

This archive was generated by hypermail 2.3.0 : Thu Mar 10 2016 - 10:00:46 CET