diff options
| author | Phillip Wood <phillip.wood@dunelm.org.uk> | 2025-07-16 10:38:30 +0100 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-07-16 08:18:06 -0700 |
| commit | f006e0323ee4b407bee3e0ff241d9d3f7a03b66a (patch) | |
| tree | 2ef9e3470907eb98e29cbb3f64155fc42907108a /strbuf.c | |
| parent | git-compat-util: convert string predicates to return bool (diff) | |
| download | git-f006e0323ee4b407bee3e0ff241d9d3f7a03b66a.tar.gz git-f006e0323ee4b407bee3e0ff241d9d3f7a03b66a.zip | |
strbuf: convert predicates to return bool
Now that the string predicates defined in git-compat-util.h all
return bool let's convert the return type of the string predicates
in strbuf.{c,h} to match them.
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'strbuf.c')
| -rw-r--r-- | strbuf.c | 28 |
1 files changed, 14 insertions, 14 deletions
@@ -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; } /* |
