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 calls to ctype functions #49

Merged
merged 1 commit into from
May 25, 2023
Merged

Conversation

b4n
Copy link
Member

@b4n b4n commented May 25, 2023

All ctype functions like isdigit() and alike expect a character as an unsigned char or EOF, anything else has undefined behavior.

This commit should fix all calls to the various ctype functions either:

  • adding unsigned char cast where appropriate;
  • removing useless int casts that are more confusing than useful.

Some instances required slightly more involved changes though, but the fix itself is the same.

To find the calls to check, I used an equivalent to the following:

git grep -P 'is(alnum|alpha|cntrl|x?digit|graph|lower|print|punct|'\
'space|upper|ascii|blank)|to(low|up)er'

...and then proceeded to manually check them to see if the call, or call chain, was using appropriate values and types.


See also universal-ctags/ctags#3734

All ctype functions like `isdigit()` and alike expect a character as an
`unsigned char` or EOF, anything else has undefined behavior.

This commit should fix all calls to the various ctype functions either:

* adding `unsigned char` cast where appropriate;
* removing useless `int` casts that are more confusing than useful.

Some instances required slightly more involved changes though, but the
fix itself is the same.

To find the calls to check, I used an equivalent to the following:

```
git grep -P 'is(alnum|alpha|cntrl|x?digit|graph|lower|print|punct|'\
'space|upper|ascii|blank)|to(low|up)er'
```

...and then proceeded to manually check them to see if the call, or
call chain, was using appropriate values and types.
@masatake masatake merged commit 20f49de into universal-ctags:master May 25, 2023
@masatake
Copy link
Member

Thank you very much.

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