Skip to content

Commit

Permalink
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 <[email protected]>
  • Loading branch information
alejandro-colomar committed Feb 16, 2025
1 parent 915f7fc commit 37771da
Show file tree
Hide file tree
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
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/setupenv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 :-) */
/*
Expand Down

0 comments on commit 37771da

Please sign in to comment.