Add C-locale variants of isascii(3) APIs, and use them#1471
Open
alejandro-colomar wants to merge 9 commits intoshadow-maint:masterfrom
Open
Add C-locale variants of isascii(3) APIs, and use them#1471alejandro-colomar wants to merge 9 commits intoshadow-maint:masterfrom
alejandro-colomar wants to merge 9 commits intoshadow-maint:masterfrom
Conversation
35a5d39 to
68cbbe3
Compare
These are like the isascii(3) family of APIs, but use the C locale, as the _c suffix hints. These macros behave well with non-casted input, unlike isascii(3). The isascii_c() and iscntrl_c() implementations are different from the rest because they must return true for '\0'. Reported-by: Tobias Stoeckmann <tobias@stoeckmann.org> Cc: Paul Eggert <eggert@cs.ucla.edu> Signed-off-by: Alejandro Colomar <alx@kernel.org>
We want to use the C locale. Reported-by: Tobias Stoeckmann <tobias@stoeckmann.org> Signed-off-by: Alejandro Colomar <alx@kernel.org>
The APIs defined under each of those subdirs are too similar and related that it makes more sense to define them in the same files. (BTW, we only had one API per subdir, except in one subdir that had two APIs, so in the end, we have almost the same separation.) Signed-off-by: Alejandro Colomar <alx@kernel.org>
This also makes it consistent with strisdigit(). Signed-off-by: Alejandro Colomar <alx@kernel.org>
By being closer together, I find them more readable. The pattern and the differences are easier to spot. Signed-off-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
68cbbe3 to
0d2063a
Compare
This compacts it into a one-liner, more similar to the strisascii_c() functions. Since we only use the argument once, we can even turn this into a macro. Signed-off-by: Alejandro Colomar <alx@kernel.org>
0d2063a to
347f931
Compare
This allows us to not depend on whether strisprint_c("") returns true or
false.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
67d289d to
554e412
Compare
It is not intuitive or clear what the right behavior should be for an empty string. If we define these APIs as "return true if all characters in the string belong to the specified character set", then an empty string should return true. On the other hand, if you ask me if an empty string is a numeric string, I might naively say no. It is irrelevant whether we return true or false for an empty string. All of the callers already handle correctly the case of an empty string. This makes the implementation simpler, using the argument only once. This allows implementing these as macros. Signed-off-by: Alejandro Colomar <alx@kernel.org>
554e412 to
d311b0d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reported-by: @stoeckmann
Cc: @eggert
Revisions:
v2
v3
v4
v5
v5b
v5c