Before a7158ceec00f14e680a885722cfe23761b4662d3, string comparision was done with strcmp, which does unsigned comparison. The natural sort implementation instead compares on char values. This causes implementation-defined behavior in comparison, depending on the signedness of char type. Fix this by using unsigned comparison instead.
Unified · Split
| @@ -51,9 +51,9 @@ int mp_natural_sort_cmp(const char *name1, const char *name2) · 50 unmodified lines | ||
| 51 | 51 | name2++; |
| 52 | 52 | } |
| 53 | 53 | } else { |
| 54 | − if (mp_tolower(name1[0]) < mp_tolower(name2[0])) | |
| 54 | + if ((unsigned char)mp_tolower(name1[0]) < (unsigned char)mp_tolower(name2[0])) | |
| 55 | 55 | return -1; |
| 56 | − if (mp_tolower(name1[0]) > mp_tolower(name2[0])) | |
| 56 | + if ((unsigned char)mp_tolower(name1[0]) > (unsigned char)mp_tolower(name2[0])) | |
| 57 | 57 | return 1; |
| 58 | 58 | name1++; |
| 59 | 59 | name2++; |