git/parse.h
Jeff King fa4fe12fa0 parse: prefer bool to int for boolean returns
All of the integer parsing functions in parse.[ch] return an int that is
"0" for failure or "1" for success. Since most of the other functions in
Git use "0" for success and "-1" for failure, this can be confusing.
Let's switch the return types to bool to make it clear that we are using
this other convention. Callers should not need to update at all.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-11-30 10:03:42 -08:00

23 lines
744 B
C

#ifndef PARSE_H
#define PARSE_H
bool git_parse_signed(const char *value, intmax_t *ret, intmax_t max);
bool git_parse_unsigned(const char *value, uintmax_t *ret, uintmax_t max);
bool git_parse_ssize_t(const char *, ssize_t *);
bool git_parse_ulong(const char *, unsigned long *);
bool git_parse_int(const char *value, int *ret);
bool git_parse_int64(const char *value, int64_t *ret);
bool git_parse_double(const char *value, double *ret);
/**
* Same as `git_config_bool`, except that it returns -1 on error rather
* than dying.
*/
int git_parse_maybe_bool(const char *);
int git_parse_maybe_bool_text(const char *value);
int git_env_bool(const char *, int);
unsigned long git_env_ulong(const char *, unsigned long);
#endif /* PARSE_H */