Skip to content

cast characters to unsigned when classifying characters #6770

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

Merged
merged 4 commits into from
Mar 18, 2024
Merged

Conversation

ethomson
Copy link
Member

An iteration on #6679 to tidy up in advance of v1.8.

boretrk and others added 4 commits December 16, 2023 23:48
ctype classification takes an integer in as returned from getc()
if we just sign extend characters to integers 128-255 will be
misclassified. (255 will become EOF)
Newlib in particular doesn't like this since they uses the value
as an index in a lookup table.
The Microsoft C runtime (MSVCRT) may take a heavy lock on the
locale in order to figure out how the `ctype` functions work.
This is deeply slow. Provide our own to avoid that.

On POSIX, provide emulation for that functionality using the ctype
functions, but compress the return value into a `bool`, and cast the
value to an `unsigned char`.
Use the `git__` ctype functions (`git__isdigit` and friends) instead of
explicitly casting.
@ethomson ethomson merged commit 0f12a01 into main Mar 18, 2024
17 of 18 checks passed
@ethomson ethomson added bug build and removed bug labels Mar 20, 2024
@ethomson ethomson deleted the ethomson/ctype branch April 3, 2024 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants