-
Notifications
You must be signed in to change notification settings - Fork 227
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
Assume C89 is available #481
Conversation
I wonder if there's any system that defines a locale-dependent isdigit(3). C89 allows for that (and since POSIX.1-2017 defers to ISO C in this case, I assume that's also true of POSIX.1-2017), but at least glibc unconditionally defines it to basically the same that we do. I also don't know if POSIX limits what locales can define as decimal digits. Maybe it does. EDIT: There's something in ISO C that may limit the ability of locales to add more digits:
Since in ascii(7), So, I think I'll remove ISDIGIT() |
We're in 2021. C89 is everywhere; in fact, there are many other assumptions in the code that wouldn't probably hold on pre-standard C environments. Let's simplify and assume that C89 is available. The specific assumptions are that: - <string.h>, and <stdlib.h> are available - strchr(3), strrchr(3), and strtok(3) are available - isalpha(3), isspace(3), isdigit(3), and isupper(3) are available I think we can safely assume we have all of those. Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
The recent removal of STDC_HEADERS made IN_CTYPE_DOMAIN be defined to 1 unconditionally. Remove the now unnecessary definition, and propagate its truthness to expressions where it was used. Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
Due to the recent removal of IN_CTYPE_DOMAIN(), the uppercase macros that wrapped these standard calls are now defined to be equivalent. Therefore, there's no need for the wrappers, and it is much more readable to use the standard calls directly. However, hold on with ISDIGIT*(), since it's not so obvious what to do with it. Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
It wasn't being used at all. Let's remove it. Use isdigit(3) directly in comments that referenced it. Also, in those comments, remove an outdated reference to the fact that ISDIGIT_LOCALE(c) might evaluate its argument more than once, which could be true a few commits ago, until IN_CTYPE_DEFINITION(c) was removed. Previously, the definition for ISDIGIT_LOCALE(c) was: #if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII)) # define IN_CTYPE_DOMAIN(c) 1 #else # define IN_CTYPE_DOMAIN(c) isascii(c) #endif #define ISDIGIT_LOCALE(c) (IN_CTYPE_DOMAIN (c) && isdigit (c)) Which could evaluate 'c' twice on pre-C89 systems (which I hope don't exist nowadays). Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
C89 defined isdigit as a function that tests for any decimal-digit character, defining the decimal digits as 0 1 2 3 4 5 6 7 8 9. I don't own a copy of C89 to check, but check in C17: 7.4.1.5 5.2.1 More specifically: > In both the source and execution basic character sets, the value > of each character after 0 in the above list of decimal digits > shall be one greater than the value of the previous. And since in ascii(7), the character after '9' is ':', it's highly unlikely that any implementation will ever accept any _decimal digit_ other than 0..9. POSIX simply defers to the ISO C standard. This is exactly what we wanted from ISDIGIT(c), so just use it. Non-standard implementations might have been slower or considered other characters as digits in the past, but let's assume implementations available today conform to ISO C89. Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
Thank you. Sorry i forgot to merge this before tagging 4.11. |
No problem, I have more changes pending :) Thanks! |
Remove STDC_HEADERS, since C89 is nowadays available everywhere (or at least everywhere we can possibly care).
STDC_HEADERS removal allows to simplify other things. Propagate those changes.