aboutsummaryrefslogtreecommitdiffstats
path: root/strbuf.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2025-07-24 16:03:55 -0700
committerJunio C Hamano <gitster@pobox.com>2025-07-24 16:03:55 -0700
commit5ce97021dd22751d0ab66dce4106dabc0463cdf0 (patch)
tree215cea90bb92d71861135ab2b1a6b75ab9f34962 /strbuf.c
parent97e14d99f6def189b0f786ac6207b792ca3197b1 (diff)
parentf006e0323ee4b407bee3e0ff241d9d3f7a03b66a (diff)
downloadgit-5ce97021dd22751d0ab66dce4106dabc0463cdf0.tar.gz
Merge branch 'pw/adopt-c99-bool-officially'
Declare weather-balloon we raised for "bool" type 18 months ago a success and officially allow using the type in our codebase. * pw/adopt-c99-bool-officially: strbuf: convert predicates to return bool git-compat-util: convert string predicates to return bool CodingGuidelines: allow the use of bool
Diffstat (limited to 'strbuf.c')
-rw-r--r--strbuf.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/strbuf.c b/strbuf.c
index f30fdc6984..6c3851a7f8 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -8,55 +8,55 @@
#include "utf8.h"
#include "date.h"
-int starts_with(const char *str, const char *prefix)
+bool starts_with(const char *str, const char *prefix)
{
for (; ; str++, prefix++)
if (!*prefix)
- return 1;
+ return true;
else if (*str != *prefix)
- return 0;
+ return false;
}
-int istarts_with(const char *str, const char *prefix)
+bool istarts_with(const char *str, const char *prefix)
{
for (; ; str++, prefix++)
if (!*prefix)
- return 1;
+ return true;
else if (tolower(*str) != tolower(*prefix))
- return 0;
+ return false;
}
-int starts_with_mem(const char *str, size_t len, const char *prefix)
+bool starts_with_mem(const char *str, size_t len, const char *prefix)
{
const char *end = str + len;
for (; ; str++, prefix++) {
if (!*prefix)
- return 1;
+ return true;
else if (str == end || *str != *prefix)
- return 0;
+ return false;
}
}
-int skip_to_optional_arg_default(const char *str, const char *prefix,
+bool skip_to_optional_arg_default(const char *str, const char *prefix,
const char **arg, const char *def)
{
const char *p;
if (!skip_prefix(str, prefix, &p))
- return 0;
+ return false;
if (!*p) {
if (arg)
*arg = def;
- return 1;
+ return true;
}
if (*p != '=')
- return 0;
+ return false;
if (arg)
*arg = p + 1;
- return 1;
+ return true;
}
/*