wimlib
wimlib copied to clipboard
Collation: special case '.'
A little thing I found.
Comparing the collation in wimlib with PrjFileNameCompare, just comparing 64K individual characters, the collations are exactly equal except that the dot (\u002e '.'
) sorts before everything else (except \0
).
To make the collations equal, the comparison becomes something like:
u16 c1 = upcase[le16_to_cpu(s1[i])];
u16 c2 = upcase[le16_to_cpu(s2[i])];
if (c1 != c2) {
if (c1 == '.' && c2) return -1;
if (c2 == '.' && c1) return +1;
return (c1 < c2) ? -1 : 1;
}
If the assumption is not made that \0
will never appear.