firmware: disregard trailing slash when sorting directory names

This commit is contained in:
Maximilian Rehkopf 2012-06-11 02:00:58 +02:00
parent 91458011aa
commit 3db272662c

View File

@ -54,13 +54,14 @@ int sort_cmp_elem(const void* elem1, const void* elem2) {
if (*sort_str1 == '.') return -1; if (*sort_str1 == '.') return -1;
if (*sort_str2 == '.') return 1; if (*sort_str2 == '.') return 1;
/* /* Do not compare trailing slashes of directory names */
uint16_t cmp_i; if ((el1 & 0x80000000) && (el2 & 0x80000000)) {
for(cmp_i=0; cmp_i<8 && sort_long1[cmp_i] == sort_long2[cmp_i]; cmp_i++); char *str1_slash = strrchr(sort_str1, '/');
if(cmp_i==8) { char *str2_slash = strrchr(sort_str2, '/');
return 0; if(str1_slash != NULL) *str1_slash = 0;
if(str2_slash != NULL) *str2_slash = 0;
} }
return sort_long1[cmp_i]-sort_long2[cmp_i]; */
return strcasecmp(sort_str1, sort_str2); return strcasecmp(sort_str1, sort_str2);
} }