-
Notifications
You must be signed in to change notification settings - Fork 620
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 many calls to ctype functions #3734
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #3734 +/- ##
==========================================
- Coverage 83.00% 82.99% -0.01%
==========================================
Files 226 226
Lines 55012 55037 +25
==========================================
+ Hits 45661 45678 +17
- Misses 9351 9359 +8
☔ View full report in Codecov by Sentry. |
You may use sed or grep to find the lines to change in this pull request. |
Done. I actually used Geany's Search in files feature so I could easily jump between matches with a lot less risk of missing one in that loong list, but it's just an interface to grep. I couldn't do any |
Thank you for updating the commit log. I have one complicated request. About libreadtags/readtags.c, could you remove the change from this pull request? So could you make another pull request for the repository about After merging this pull request (without changes about libreadtags/readtags.c) and |
All ctype functions like `isspace()`, `tolower()` 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 each one of them to see if the call, or call chain, was using appropriate values and types.
Sure, no problem, and it wasn't really complicated at all :) It's done, and the companion PR at libreadtags is universal-ctags/libreadtags#49 |
|
Thank you! |
All ctype functions like
isspace()
,tolower()
and alike expect a character as anunsigned char
or EOF, anything else has undefined behavior.This commit should fix all calls to the various ctype functions either:
unsigned char
cast where appropriate;int
casts that are more confusing than useful.Some instances required slightly more involved changes though, but the fix itself is the same.
That one was long, boring and a bit tricky. I think I didn't miss any calls (used some grepping and went through it all), but I could have let one slip somehow I guess… reviewing will likely be just as tricky, sorry.