-
Notifications
You must be signed in to change notification settings - Fork 254
lib/: Add ispfchar(), and use it instead of its pattern #1469
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
base: master
Are you sure you want to change the base?
Conversation
f97b10f to
1ead5c6
Compare
1ead5c6 to
8fd9e48
Compare
This function returns true if the input character is a character from the POSIX portable filename character set. Link: <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/V1_chap03.html#tag_03_265> Signed-off-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
In the first case, we can do the transformation because a few lines above, we explicitly reject a name starting with a '-'. In the second case, we're obviously using ispfchar() instead of its pattern. Signed-off-by: Alejandro Colomar <alx@kernel.org>
8fd9e48 to
d39008c
Compare
| inline bool | ||
| ispfchar(unsigned char c) | ||
| { | ||
| return isalnum(c) || c == '.' || c == '_' || c == '-'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The isalnum function is locale dependent. German umlauts are definitely not portable file characters, but will be as soon as setlocale is called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the reminder!
I should use variants of these functions that work on the C locale exclusively.
Revisions:
v2
v2b