Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib/: Treat strpbrk(3)'s return value as a boolean
Browse files Browse the repository at this point in the history
with the meaning "a character was found".

strpbrk(3) is just like strchr(3), but searches for multiple characters.
Both functions have a boolean-like return value, which evaluates to true
if a character was found.

A better name for strpbrk(3) would have been strchrs().

Signed-off-by: Alejandro Colomar <alx@kernel.org>
alejandro-colomar committed Jan 24, 2025
1 parent 8a3145a commit 412d4da
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/fields.c
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ int valid_field (const char *field, const char *illegal)

/* For each character of field, search if it appears in the list
* of illegal characters. */
if (illegal && NULL != strpbrk (field, illegal)) {
if (illegal && strpbrk(field, illegal)) {
return -1;
}

2 changes: 1 addition & 1 deletion lib/setupenv.c
Original file line number Diff line number Diff line change
@@ -72,7 +72,7 @@ static void read_env_file (const char *filename)
val = stpsep(cp, "=");
if (val == NULL)
continue;
if (strpbrk(name, " \t") != NULL)
if (strpbrk(name, " \t"))
continue;
#if 0 /* XXX untested, and needs rewrite with fewer goto's :-) */
/*

0 comments on commit 412d4da

Please sign in to comment.