Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

tagtree.c move sort_inverse out of compare function

Change-Id: I9c91a96a45fe98d51d27974bc2d6d79eaa5039d3

+25 -18
+25 -18
apps/tagtree.c
··· 117 117 #define MAX_MENU_ID_SIZE 32 118 118 119 119 #define RELOAD_TAGTREE (-1024) 120 - static bool sort_inverse; 120 + 121 + static int(*qsort_fn)(const char*, const char*, size_t); 122 + /* dummmy functions to allow compatibility strncasecmp */ 123 + static int strnatcasecmp_n(const char *a, const char *b, size_t n) 124 + { 125 + (void)n; 126 + return strnatcasecmp(a, b); 127 + } 128 + static int strnatcasecmp_n_inv(const char *a, const char *b, size_t n) 129 + { 130 + (void)n; 131 + return strnatcasecmp(b, a); 132 + } 133 + static int strncasecmp_inv(const char *a, const char *b, size_t n) 134 + { 135 + return strncasecmp(b, a, n); 136 + } 121 137 122 138 /* 123 139 * "%3d. %s" autoscore title %sort = "inverse" %limit = "100" ··· 824 840 { 825 841 struct tagentry *e1 = (struct tagentry *)p1; 826 842 struct tagentry *e2 = (struct tagentry *)p2; 827 - 828 - if (sort_inverse) 829 - return strncasecmp(e2->name, e1->name, MAX_PATH); 830 - 831 - return strncasecmp(e1->name, e2->name, MAX_PATH); 832 - } 833 - 834 - static int nat_compare(const void *p1, const void *p2) 835 - { 836 - struct tagentry *e1 = (struct tagentry *)p1; 837 - struct tagentry *e2 = (struct tagentry *)p2; 838 - 839 - if (sort_inverse) 840 - return strnatcasecmp(e2->name, e1->name); 841 - 842 - return strnatcasecmp(e1->name, e2->name); 843 + return qsort_fn(e1->name, e2->name, MAX_PATH); 843 844 } 844 845 845 846 static void tagtree_buffer_event(unsigned short id, void *ev_data) ··· 1428 1429 int level = c->currextra; 1429 1430 int tag; 1430 1431 bool sort = false; 1432 + bool sort_inverse; 1431 1433 int sort_limit; 1432 1434 int strip; 1433 1435 ··· 1667 1669 1668 1670 if (sort) 1669 1671 { 1672 + if (global_settings.interpret_numbers) 1673 + qsort_fn = sort_inverse ? strnatcasecmp_n_inv : strnatcasecmp_n; 1674 + else 1675 + qsort_fn = sort_inverse ? strncasecmp_inv : strncasecmp; 1676 + 1670 1677 struct tagentry *entries = get_entries(c); 1671 1678 qsort(&entries[special_entry_count], 1672 1679 current_entry_count - special_entry_count, 1673 1680 sizeof(struct tagentry), 1674 - global_settings.interpret_numbers ? nat_compare : compare); 1681 + compare); 1675 1682 } 1676 1683 1677 1684 if (!init)