mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-11 05:17:44 +03:00
util: Rewrite in_charset to use strspn
This simplifies in_charset down to a one-liner, and allows for possible optimizations of strspn in libc.
This commit is contained in:
parent
7b909d7407
commit
e0333c7314
@ -921,16 +921,9 @@ char *delete_chars(char *s, const char *bad) {
|
||||
}
|
||||
|
||||
bool in_charset(const char *s, const char* charset) {
|
||||
const char *i;
|
||||
|
||||
assert(s);
|
||||
assert(charset);
|
||||
|
||||
for (i = s; *i; i++)
|
||||
if (!strchr(charset, *i))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return s[strspn(s, charset)] == '\0';
|
||||
}
|
||||
|
||||
char *file_in_same_dir(const char *path, const char *filename) {
|
||||
|
Loading…
Reference in New Issue
Block a user