Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collation: special case '.' #7

Open
ericwj opened this issue Mar 13, 2024 · 0 comments
Open

Collation: special case '.' #7

ericwj opened this issue Mar 13, 2024 · 0 comments

Comments

@ericwj
Copy link

ericwj commented Mar 13, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant