Git fork

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>

authored by

Phillip Wood and committed by
Junio C Hamano
f006e032 f3ba426e

+20 -20
+14 -14
strbuf.c
··· 8 8 #include "utf8.h" 9 9 #include "date.h" 10 10 11 - int starts_with(const char *str, const char *prefix) 11 + bool starts_with(const char *str, const char *prefix) 12 12 { 13 13 for (; ; str++, prefix++) 14 14 if (!*prefix) 15 - return 1; 15 + return true; 16 16 else if (*str != *prefix) 17 - return 0; 17 + return false; 18 18 } 19 19 20 - int istarts_with(const char *str, const char *prefix) 20 + bool istarts_with(const char *str, const char *prefix) 21 21 { 22 22 for (; ; str++, prefix++) 23 23 if (!*prefix) 24 - return 1; 24 + return true; 25 25 else if (tolower(*str) != tolower(*prefix)) 26 - return 0; 26 + return false; 27 27 } 28 28 29 - int starts_with_mem(const char *str, size_t len, const char *prefix) 29 + bool starts_with_mem(const char *str, size_t len, const char *prefix) 30 30 { 31 31 const char *end = str + len; 32 32 for (; ; str++, prefix++) { 33 33 if (!*prefix) 34 - return 1; 34 + return true; 35 35 else if (str == end || *str != *prefix) 36 - return 0; 36 + return false; 37 37 } 38 38 } 39 39 40 - int skip_to_optional_arg_default(const char *str, const char *prefix, 40 + bool skip_to_optional_arg_default(const char *str, const char *prefix, 41 41 const char **arg, const char *def) 42 42 { 43 43 const char *p; 44 44 45 45 if (!skip_prefix(str, prefix, &p)) 46 - return 0; 46 + return false; 47 47 48 48 if (!*p) { 49 49 if (arg) 50 50 *arg = def; 51 - return 1; 51 + return true; 52 52 } 53 53 54 54 if (*p != '=') 55 - return 0; 55 + return false; 56 56 57 57 if (arg) 58 58 *arg = p + 1; 59 - return 1; 59 + return true; 60 60 } 61 61 62 62 /*
+6 -6
strbuf.h
··· 660 660 __attribute__((format (printf, 1, 2))) 661 661 char *xstrfmt(const char *fmt, ...); 662 662 663 - int starts_with(const char *str, const char *prefix); 664 - int istarts_with(const char *str, const char *prefix); 665 - int starts_with_mem(const char *str, size_t len, const char *prefix); 663 + bool starts_with(const char *str, const char *prefix); 664 + bool istarts_with(const char *str, const char *prefix); 665 + bool starts_with_mem(const char *str, size_t len, const char *prefix); 666 666 667 667 /* 668 668 * If the string "str" is the same as the string in "prefix", then the "arg" ··· 678 678 * can be used instead of !strcmp(arg, "--key") and then 679 679 * skip_prefix(arg, "--key=", &arg) to parse such an option. 680 680 */ 681 - int skip_to_optional_arg_default(const char *str, const char *prefix, 681 + bool skip_to_optional_arg_default(const char *str, const char *prefix, 682 682 const char **arg, const char *def); 683 683 684 - static inline int skip_to_optional_arg(const char *str, const char *prefix, 684 + static inline bool skip_to_optional_arg(const char *str, const char *prefix, 685 685 const char **arg) 686 686 { 687 687 return skip_to_optional_arg_default(str, prefix, arg, ""); 688 688 } 689 689 690 - static inline int ends_with(const char *str, const char *suffix) 690 + static inline bool ends_with(const char *str, const char *suffix) 691 691 { 692 692 size_t len; 693 693 return strip_suffix(str, suffix, &len);