]> git.ipfire.org Git - thirdparty/git.git/commit
config: introduce `git_config_double()`
authorTaylor Blau <me@ttaylorr.com>
Thu, 23 May 2024 21:26:39 +0000 (17:26 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 24 May 2024 18:40:42 +0000 (11:40 -0700)
commit5831f8ac41a137b93d5481cc48078cb5628538e3
tree6b1bfd4ceb72d6cb81e3fac887b3e0916b91801f
parentc059c8795e926cfe3ad8cb7a47f54c071227fcfa
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>
config.c
config.h
parse.c
parse.h