mirror of
https://github.com/git/git.git
synced 2024-06-02 17:36:09 +02:00
Add strtoimax() compatibility function.
Since systems that omit strtoumax() will likely omit strtomax() too, and likewise for strtoull() and strtoll(), we arrange for the make variables NO_STRTOUMAX and NO_STRTOULL to cover both the signed and unsigned functions, and define compatibility implementations for them. Signed-off-by: Nick Alcock <nix@esperi.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
f696543dad
commit
e3eed7f8d2
6
Makefile
6
Makefile
|
@ -57,8 +57,8 @@ all::
|
||||||
#
|
#
|
||||||
# Define NO_STRLCPY if you don't have strlcpy.
|
# Define NO_STRLCPY if you don't have strlcpy.
|
||||||
#
|
#
|
||||||
# Define NO_STRTOUMAX if you don't have strtoumax in the C library.
|
# Define NO_STRTOUMAX if you don't have both strtoimax and strtoumax in the
|
||||||
# If your compiler also does not support long long or does not have
|
# C library. If your compiler also does not support long long or does not have
|
||||||
# strtoull, define NO_STRTOULL.
|
# strtoull, define NO_STRTOULL.
|
||||||
#
|
#
|
||||||
# Define NO_SETENV if you don't have setenv in the C library.
|
# Define NO_SETENV if you don't have setenv in the C library.
|
||||||
|
@ -1402,7 +1402,7 @@ ifdef NO_STRLCPY
|
||||||
endif
|
endif
|
||||||
ifdef NO_STRTOUMAX
|
ifdef NO_STRTOUMAX
|
||||||
COMPAT_CFLAGS += -DNO_STRTOUMAX
|
COMPAT_CFLAGS += -DNO_STRTOUMAX
|
||||||
COMPAT_OBJS += compat/strtoumax.o
|
COMPAT_OBJS += compat/strtoumax.o compat/strtoimax.o
|
||||||
endif
|
endif
|
||||||
ifdef NO_STRTOULL
|
ifdef NO_STRTOULL
|
||||||
COMPAT_CFLAGS += -DNO_STRTOULL
|
COMPAT_CFLAGS += -DNO_STRTOULL
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
#include "../git-compat-util.h"
|
||||||
|
|
||||||
|
intmax_t gitstrtoimax (const char *nptr, char **endptr, int base)
|
||||||
|
{
|
||||||
|
#if defined(NO_STRTOULL)
|
||||||
|
return strtol(nptr, endptr, base);
|
||||||
|
#else
|
||||||
|
return strtoll(nptr, endptr, base);
|
||||||
|
#endif
|
||||||
|
}
|
Loading…
Reference in New Issue