-
Notifications
You must be signed in to change notification settings - Fork 268
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
Draft
alejandro-colomar
wants to merge
14
commits into
shadow-maint:master
Choose a base branch
from
alejandro-colomar:chkname
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
45b4ff7
lib/string/ctype/isascii.[ch]: is*_c(): Add APIs
alejandro-colomar c8a29c6
lib/, src/: Use isascii_c() functions instead of isascii(3)
alejandro-colomar 4a129a8
lib/: Merge directories "lib/string/ctype/*" into unified files
alejandro-colomar 786b218
lib/string/ctype/strisascii.h: strisprint(): Simplify implementation
alejandro-colomar 89c453b
lib/string/ctype/strisascii.h: Compact definitions
alejandro-colomar f31d65e
lib/: stris*(): Rename C-locale APIs with a _c suffix
alejandro-colomar 7e52af1
lib/string/ctype/strchrisascii.h: Use strpbrk(3) to simplify
alejandro-colomar 337ecf8
lib/fields.c: valid_field(): Check empty string before strisprint_c()
alejandro-colomar dc539f1
lib/string/ctype/strisascii.*: Don't special-case ""
alejandro-colomar 5a059fe
lib/: Merge "lib/string/ctype/*" files even further
alejandro-colomar 42e056d
lib/string/ctype/isascii.h: ispfchar_c(): Add macro
alejandro-colomar 277c74a
lib/chkname.c: is_valid_name(): Use isalnum(3) instead of its pattern
alejandro-colomar ada55b6
lib/chkname.c: is_valid_name(): Split Samba check
alejandro-colomar 0d55459
lib/chkname.c: is_valid_name(): Use ispfchar_c() to simplify
alejandro-colomar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| // SPDX-FileCopyrightText: 2024-2025, Alejandro Colomar <alx@kernel.org> | ||
| // SPDX-License-Identifier: BSD-3-Clause | ||
|
|
||
|
|
||
| #include "config.h" | ||
|
|
||
| #include "string/ctype/isascii.h" |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| // SPDX-FileCopyrightText: 2024-2025, Alejandro Colomar <alx@kernel.org> | ||
| // SPDX-License-Identifier: BSD-3-Clause | ||
|
|
||
|
|
||
| #ifndef SHADOW_INCLUDE_LIB_STRING_CTYPE_ISASCII_H_ | ||
| #define SHADOW_INCLUDE_LIB_STRING_CTYPE_ISASCII_H_ | ||
|
|
||
|
|
||
| #include "config.h" | ||
|
|
||
| #include <string.h> | ||
|
|
||
| #include "string/strcmp/streq.h" | ||
| #include "string/strspn/stpspn.h" | ||
|
|
||
|
|
||
| #define CTYPE_CNTRL_C \ | ||
| "\x7F" \ | ||
| "\x1F\x1E\x1D\x1C\x1B\x1A\x19\x18\x17\x16\x15\x14\x13\x12\x11\x10" \ | ||
| "\x0F\x0E\x0D\x0C\x0B\x0A\x09\x08\x07\x06\x05\x04\x03\x02\x01" /*NUL*/ | ||
|
|
||
| #define CTYPE_LOWER_C "abcdefghijklmnopqrstuvwxyz" | ||
| #define CTYPE_UPPER_C "ABCDEFGHIJKLMNOPQRSTUVWXYZ" | ||
| #define CTYPE_DIGIT_C "0123456789" | ||
| #define CTYPE_PUNCT_C "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~" | ||
| #define CTYPE_SPACE_C " \t\n\v\f\r" | ||
| #define CTYPE_ALPHA_C CTYPE_LOWER_C CTYPE_UPPER_C | ||
| #define CTYPE_ALNUM_C CTYPE_ALPHA_C CTYPE_DIGIT_C | ||
| #define CTYPE_GRAPH_C CTYPE_ALNUM_C CTYPE_PUNCT_C | ||
| #define CTYPE_PRINT_C CTYPE_GRAPH_C " " | ||
| #define CTYPE_XDIGIT_C CTYPE_DIGIT_C "abcdefABCDEF" | ||
| #define CTYPE_ASCII_C CTYPE_PRINT_C CTYPE_CNTRL_C /*NUL*/ | ||
| #define CTYPE_PFCHAR_C CTYPE_ALNUM_C "._-" // portable filename character set | ||
|
|
||
|
|
||
| // isascii_c - is [:ascii:] C-locale | ||
| #define isascii_c(c) (!!strchr(CTYPE_ASCII_C, c)) | ||
| #define iscntrl_c(c) (!!strchr(CTYPE_CNTRL_C, c)) | ||
| #define islower_c(c) (!streq(strchrnul(CTYPE_LOWER_C, c), "")) | ||
| #define isupper_c(c) (!streq(strchrnul(CTYPE_UPPER_C, c), "")) | ||
| #define isdigit_c(c) (!streq(strchrnul(CTYPE_DIGIT_C, c), "")) | ||
| #define ispunct_c(c) (!streq(strchrnul(CTYPE_PUNCT_C, c), "")) | ||
| #define isspace_c(c) (!streq(strchrnul(CTYPE_SPACE_C, c), "")) | ||
| #define isalpha_c(c) (!streq(strchrnul(CTYPE_ALPHA_C, c), "")) | ||
| #define isalnum_c(c) (!streq(strchrnul(CTYPE_ALNUM_C, c), "")) | ||
| #define isgraph_c(c) (!streq(strchrnul(CTYPE_GRAPH_C, c), "")) | ||
| #define isprint_c(c) (!streq(strchrnul(CTYPE_PRINT_C, c), "")) | ||
| #define isxdigit_c(c) (!streq(strchrnul(CTYPE_XDIGIT_C, c), "")) | ||
| #define ispfchar_c(c) (!streq(strchrnul(CTYPE_PFCHAR_C, c), "")) | ||
|
|
||
|
|
||
| // strisascii_c - string is [:ascii:] C-locale | ||
| #define strisdigit_c(s) streq(stpspn(s, CTYPE_DIGIT_C), "") | ||
| #define strisprint_c(s) streq(stpspn(s, CTYPE_PRINT_C), "") | ||
|
|
||
|
|
||
| // strchriscntrl_c - string character is [:cntrl:] C-locale | ||
| #define strchriscntrl_c(s) (!!strpbrk(s, CTYPE_CNTRL_C)) | ||
|
|
||
|
|
||
| #endif // include guard |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.