From b9a27cf18784bfe43fea85d5f097d3ddff707a3c Mon Sep 17 00:00:00 2001
From: Přemysl Janouch
Date: Sun, 23 Oct 2016 18:35:15 +0200
Subject: Use case insensitive ordering
---
nncmpp.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/nncmpp.c b/nncmpp.c
index f91b03a..fdf062f 100644
--- a/nncmpp.c
+++ b/nncmpp.c
@@ -101,6 +101,7 @@ enum
#include
#include
#include
+#include
// We need cURL to extract links from Internet stream playlists. It'd be way
// too much code to do this all by ourselves, and there's nothing better around.
@@ -783,10 +784,21 @@ load_config_colors (struct config_item *subtree, void *user_data)
#undef XX
}
+static int
+app_casecmp (const uint8_t *a, const uint8_t *b)
+{
+ int res;
+ // XXX: this seems to produce some strange results
+ if (u8_casecmp (a, strlen ((const char *) a), b, strlen ((const char *) b),
+ NULL, NULL, &res))
+ res = u8_strcmp (a, b);
+ return res;
+}
+
static int
str_vector_sort_utf8_cb (const void *a, const void *b)
{
- return u8_strcmp (*(const uint8_t **) a, *(const uint8_t **) b);
+ return app_casecmp (*(const uint8_t **) a, *(const uint8_t **) b);
}
static void
@@ -2143,8 +2155,7 @@ library_tab_compare (char **a, char **b)
if (xa.type != xb.type)
return xa.type - xb.type;
- // TODO: this should be case insensitive
- return u8_strcmp ((uint8_t *) xa.path, (uint8_t *) xb.path);
+ return app_casecmp ((uint8_t *) xa.path, (uint8_t *) xb.path);
}
static void
--
cgit v1.2.3-70-g09d2