summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--playlist.c6
-rw-r--r--utf8.c28
-rw-r--r--utf8.h6
3 files changed, 39 insertions, 1 deletions
diff --git a/playlist.c b/playlist.c
index def4754f..6be4d4bb 100644
--- a/playlist.c
+++ b/playlist.c
@@ -3058,7 +3058,11 @@ pl_sort_compare_str (playItem_t *a, playItem_t *b) {
char tmp2[1024];
pl_format_title (a, -1, tmp1, sizeof (tmp1), pl_sort_id, pl_sort_format);
pl_format_title (b, -1, tmp2, sizeof (tmp2), pl_sort_id, pl_sort_format);
- return !pl_sort_ascending ? strcmp (tmp2, tmp1) : strcmp (tmp1, tmp2);
+ int res = u8_strcasecmp (tmp1, tmp2);
+ if (!pl_sort_ascending) {
+ res = -res;
+ }
+ return res;
}
}
diff --git a/utf8.c b/utf8.c
index c303b9a1..6249f94a 100644
--- a/utf8.c
+++ b/utf8.c
@@ -688,6 +688,34 @@ utfcasestr (const char *s1, const char *s2) {
return NULL;
}
+int
+u8_strcasecmp (const char *a, const char *b) {
+ const char *p1 = a, *p2 = b;
+ while (*p1 && *p2) {
+ int32_t i1 = 0;
+ int32_t i2 = 0;
+ char s1[10], s2[10];
+ const char *next;
+ u8_nextchar (p1, &i1);
+ u8_nextchar (p2, &i2);
+ int l1 = u8_tolower (p1, i1, s1);
+ int l2 = u8_tolower (p2, i2, s2);
+ int res = 0;
+ if (l1 != l2) {
+ res = l1-l2;
+ }
+ else {
+ res = memcmp (s1, s2, l1);
+ }
+ if (res) {
+ return res;
+ }
+ p1 += i1;
+ p2 += i2;
+ }
+ return 0;
+}
+
void
u8_lc_map_test (void) {
struct u8_case_map_t *lc;
diff --git a/utf8.h b/utf8.h
index f0912c12..9deb08a3 100644
--- a/utf8.h
+++ b/utf8.h
@@ -98,6 +98,12 @@ int u8_valid (const char *str,
int max_len,
const char **end);
+int
+u8_tolower (const signed char *c, int l, char *out);
+
+int
+u8_strcasecmp (const char *a, const char *b);
+
const char *
utfcasestr (const char *s1, const char *s2);