summaryrefslogtreecommitdiffstats
path: root/apps/tagtree.c
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2014-01-15 23:18:35 +0100
committerThomas Martitz <kugel@rockbox.org>2014-01-15 23:18:35 +0100
commit84c7d6133bf8a43688f1ac56d774fb94b1d3eed5 (patch)
tree99ef8340c61602ecaf1293636f6e5d649efc046a /apps/tagtree.c
parent4f5b13077e2f1500c8cbf88af790bca0ddfa2bc5 (diff)
downloadrockbox-84c7d6133bf8a43688f1ac56d774fb94b1d3eed5.tar.gz
rockbox-84c7d6133bf8a43688f1ac56d774fb94b1d3eed5.tar.bz2
rockbox-84c7d6133bf8a43688f1ac56d774fb94b1d3eed5.zip
tagtree: Use strnatcasecmp() for the database browser too.
Even though you can insert leading zeros that makes ascii sort work for numbers, sometimes the leading zeros don't suffice. In order to always sort numerically strnatcasecmp() is needed. With the default tagnavi.config this affects albums with discnum > 9 or tracnums > 99. This FS#12888. Change-Id: Ie265c86eaf6dd07b6beda9e5eef25eb81eef8fd4
Diffstat (limited to 'apps/tagtree.c')
-rw-r--r--apps/tagtree.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/apps/tagtree.c b/apps/tagtree.c
index 417b6f28f0..9eef38b5e6 100644
--- a/apps/tagtree.c
+++ b/apps/tagtree.c
@@ -53,6 +53,7 @@
#include "storage.h"
#include "dir.h"
#include "playback.h"
+#include "strnatcmp.h"
#include "panic.h"
#define str_or_empty(x) (x ? x : "(NULL)")
@@ -791,6 +792,17 @@ static int compare(const void *p1, const void *p2)
return strncasecmp(e1->name, e2->name, MAX_PATH);
}
+static int nat_compare(const void *p1, const void *p2)
+{
+ struct tagentry *e1 = (struct tagentry *)p1;
+ struct tagentry *e2 = (struct tagentry *)p2;
+
+ if (sort_inverse)
+ return strnatcasecmp(e2->name, e1->name);
+
+ return strnatcasecmp(e1->name, e2->name);
+}
+
static void tagtree_buffer_event(void *data)
{
struct tagcache_search tcs;
@@ -1530,7 +1542,8 @@ static int retrieve_entries(struct tree_context *c, int offset, bool init)
struct tagentry *entries = get_entries(c);
qsort(&entries[special_entry_count],
current_entry_count - special_entry_count,
- sizeof(struct tagentry), compare);
+ sizeof(struct tagentry),
+ global_settings.interpret_numbers ? nat_compare : compare);
}
if (!init)