aboutsummaryrefslogtreecommitdiffstats
path: root/git-compat-util.h
diff options
context:
space:
mode:
authorPhillip Wood <phillip.wood@dunelm.org.uk>2025-07-16 10:38:29 +0100
committerJunio C Hamano <gitster@pobox.com>2025-07-16 08:18:06 -0700
commitf3ba426e3539b2d585944f9d6425dbc13b7d0d28 (patch)
tree784a6054599fd62c283285bd6458beb7786b6be6 /git-compat-util.h
parentCodingGuidelines: allow the use of bool (diff)
downloadgit-f3ba426e3539b2d585944f9d6425dbc13b7d0d28.tar.gz
git-f3ba426e3539b2d585944f9d6425dbc13b7d0d28.zip
git-compat-util: convert string predicates to return bool
Since 8277dbe987 (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 <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-compat-util.h')
-rw-r--r--git-compat-util.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/git-compat-util.h b/git-compat-util.h
index 4678e21c4c..50ca9dc547 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -895,16 +895,16 @@ static inline size_t xsize_t(off_t len)
* is done via tolower(), so it is strictly ASCII (no multi-byte characters or
* locale-specific conversions).
*/
-static inline int skip_iprefix(const char *str, const char *prefix,
+static inline bool skip_iprefix(const char *str, const char *prefix,
const char **out)
{
do {
if (!*prefix) {
*out = str;
- return 1;
+ return true;
}
} while (tolower(*str++) == tolower(*prefix++));
- return 0;
+ return false;
}
/*
@@ -912,7 +912,7 @@ static inline int skip_iprefix(const char *str, const char *prefix,
* comparison is done via tolower(), so it is strictly ASCII (no multi-byte
* characters or locale-specific conversions).
*/
-static inline int skip_iprefix_mem(const char *buf, size_t len,
+static inline bool skip_iprefix_mem(const char *buf, size_t len,
const char *prefix,
const char **out, size_t *outlen)
{
@@ -920,10 +920,10 @@ static inline int skip_iprefix_mem(const char *buf, size_t len,
if (!*prefix) {
*out = buf;
*outlen = len;
- return 1;
+ return true;
}
} while (len-- > 0 && tolower(*buf++) == tolower(*prefix++));
- return 0;
+ return false;
}
static inline int strtoul_ui(char const *s, int base, unsigned int *result)