Git fork

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>

authored by

Nick Alcock and committed by
Junio C Hamano
e3eed7f8 f696543d

+13 -3
+3 -3
Makefile
··· 57 57 # 58 58 # Define NO_STRLCPY if you don't have strlcpy. 59 59 # 60 - # Define NO_STRTOUMAX if you don't have strtoumax in the C library. 61 - # If your compiler also does not support long long or does not have 60 + # Define NO_STRTOUMAX if you don't have both strtoimax and strtoumax in the 61 + # C library. If your compiler also does not support long long or does not have 62 62 # strtoull, define NO_STRTOULL. 63 63 # 64 64 # Define NO_SETENV if you don't have setenv in the C library. ··· 1402 1402 endif 1403 1403 ifdef NO_STRTOUMAX 1404 1404 COMPAT_CFLAGS += -DNO_STRTOUMAX 1405 - COMPAT_OBJS += compat/strtoumax.o 1405 + COMPAT_OBJS += compat/strtoumax.o compat/strtoimax.o 1406 1406 endif 1407 1407 ifdef NO_STRTOULL 1408 1408 COMPAT_CFLAGS += -DNO_STRTOULL
+10
compat/strtoimax.c
··· 1 + #include "../git-compat-util.h" 2 + 3 + intmax_t gitstrtoimax (const char *nptr, char **endptr, int base) 4 + { 5 + #if defined(NO_STRTOULL) 6 + return strtol(nptr, endptr, base); 7 + #else 8 + return strtoll(nptr, endptr, base); 9 + #endif 10 + }