diff --git a/src/files.c b/src/files.c index 2d094756..4e0f3fbf 100644 --- a/src/files.c +++ b/src/files.c @@ -2354,11 +2354,13 @@ int diralphasort(const void *va, const void *vb) if (!aisdir && bisdir) return 1; - /* Standard function brain damage: We should be sorting - * alphabetically and case-insensitively according to the current - * locale, but there's no standard strcasecoll() function, so we - * have to use multibyte strcasecmp() instead. */ - return mbstrcasecmp(a, b); + int difference = mbstrcasecmp(a, b); + + /* If two names are equivalent when ignoring case, compare them bytewise. */ + if (difference == 0) + return strcmp(a, b); + else + return difference; } #endif