Skip to content

Commit f3ba426

Browse files
phillipwoodgitster
authored andcommitted
git-compat-util: convert string predicates to return bool
Since 8277dbe (git-compat-util: convert skip_{prefix,suffix}{,_mem} to bool, 2023-12-16) a number of our string predicates have been returning bool instead of int. Now that we've declared that experiment a success, let's convert the return type of the case-independent skip_iprefix() and skip_iprefix_mem() functions to match the return type of their case-dependent equivalents. Returning bool instead of int makes it clear that these functions are predicates. Signed-off-by: Phillip Wood <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bfa405e commit f3ba426

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

git-compat-util.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -895,35 +895,35 @@ static inline size_t xsize_t(off_t len)
895895
* is done via tolower(), so it is strictly ASCII (no multi-byte characters or
896896
* locale-specific conversions).
897897
*/
898-
static inline int skip_iprefix(const char *str, const char *prefix,
898+
static inline bool skip_iprefix(const char *str, const char *prefix,
899899
const char **out)
900900
{
901901
do {
902902
if (!*prefix) {
903903
*out = str;
904-
return 1;
904+
return true;
905905
}
906906
} while (tolower(*str++) == tolower(*prefix++));
907-
return 0;
907+
return false;
908908
}
909909

910910
/*
911911
* Like skip_prefix_mem, but compare case-insensitively. Note that the
912912
* comparison is done via tolower(), so it is strictly ASCII (no multi-byte
913913
* characters or locale-specific conversions).
914914
*/
915-
static inline int skip_iprefix_mem(const char *buf, size_t len,
915+
static inline bool skip_iprefix_mem(const char *buf, size_t len,
916916
const char *prefix,
917917
const char **out, size_t *outlen)
918918
{
919919
do {
920920
if (!*prefix) {
921921
*out = buf;
922922
*outlen = len;
923-
return 1;
923+
return true;
924924
}
925925
} while (len-- > 0 && tolower(*buf++) == tolower(*prefix++));
926-
return 0;
926+
return false;
927927
}
928928

929929
static inline int strtoul_ui(char const *s, int base, unsigned int *result)

0 commit comments

Comments
 (0)