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

Fix unicode non-ASCII name check with unsigned char #256

Merged
merged 1 commit into from
Nov 17, 2021
Merged

Fix unicode non-ASCII name check with unsigned char #256

merged 1 commit into from
Nov 17, 2021

Conversation

pinotree
Copy link
Contributor

@pinotree pinotree commented Nov 17, 2021

In case 'char' is unsigned (which happens on some architectures), then
checks like str[i] > 0 will always be true (for non-NULL characters,
of course). Since we are interested to check only for the values <= 127,
then change the check to cast the char to unsigned, so we can always
check that the value is lower than 0x80 (128).

@evanmiller
Copy link
Contributor

Can we simplify this logic with (unsigned char)str[i] < 0x80?

In case 'char' is unsigned (which happens on some architectures), then
checks like 'str[i] > 0' will always be true (for non-NULL characters,
of course). Since we are interested to check only for the values <= 127,
then change the check to cast the char to unsigned, so we can always
check that the value is lower than 0x80 (128).
@pinotree
Copy link
Contributor Author

Can we simplify this logic with (unsigned char)str[i] < 0x80?

Oh indeed; apparently I complicated this overlooking the easy solution; thanks!

@evanmiller evanmiller changed the base branch from master to dev November 17, 2021 13:04
@evanmiller evanmiller merged commit 53c027c into WizardMac:dev Nov 17, 2021
@pinotree pinotree deleted the unsigned-char-unicode-check branch November 17, 2021 13:24
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

Successfully merging this pull request may close these issues.

2 participants