2023-09-29 21:20:51 +00:00
|
|
|
#ifndef PARSE_H
|
|
|
|
#define PARSE_H
|
|
|
|
|
|
|
|
int git_parse_signed(const char *value, intmax_t *ret, intmax_t max);
|
|
|
|
int git_parse_ssize_t(const char *, ssize_t *);
|
|
|
|
int git_parse_ulong(const char *, unsigned long *);
|
|
|
|
int git_parse_int(const char *value, int *ret);
|
|
|
|
int git_parse_int64(const char *value, int64_t *ret);
|
config: introduce `git_config_double()`
Future commits will want to parse a double-precision floating point
value from configuration, but we have no way to parse such a value prior
to this patch.
The core of the routine is implemented in git_parse_double(). Unlike
git_parse_unsigned() and git_parse_signed(), however, the function
implemented here only works on type "double", and not related types like
"float", or "long double".
This is because "float" and "long double" use different functions to
convert from ASCII strings to floating point values (strtof() and
strtold(), respectively). Likewise, there is no pointer type that can
assign to any of these values (except for "void *"), so the only way to
define this trio of functions would be with a macro expansion that is
parameterized over the floating point type and conversion function.
That is all doable, but likely to be overkill given our current needs,
which is only to parse double-precision floats.
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-05-23 21:26:39 +00:00
|
|
|
int git_parse_double(const char *value, double *ret);
|
2023-09-29 21:20:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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 */
|