Browse Source

Add a compat/strtoumax.c for Solaris 8.

Solaris 8 was pre-c99, and they weren't willing to commit to
the strtoumax definition according to /usr/include/inttypes.h.

This adds NO_STRTOUMAX and NO_STRTOULL for ancient systems.
If NO_STRTOUMAX is defined, the routine in compat/strtoumax.c
will be used instead.  That routine passes its arguments to
strtoull unless NO_STRTOULL is defined.  If NO_STRTOULL, then
the routine uses strtoul (unsigned long).

Signed-off-by: Jason Riedy <ejr@cs.berkeley.edu>
Acked-by: Shawn O Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
maint
Jason Riedy 18 years ago committed by Junio C Hamano
parent
commit
bc6b4f52fc
  1. 13
      Makefile
  2. 10
      compat/strtoumax.c
  3. 5
      git-compat-util.h

13
Makefile

@ -28,6 +28,10 @@ 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.
# If your compiler also does not support long long or does not have
# 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.
# #
# Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link. # Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.
@ -353,11 +357,13 @@ ifeq ($(uname_S),SunOS)
NO_UNSETENV = YesPlease NO_UNSETENV = YesPlease
NO_SETENV = YesPlease NO_SETENV = YesPlease
NO_C99_FORMAT = YesPlease NO_C99_FORMAT = YesPlease
NO_STRTOUMAX = YesPlease
endif endif
ifeq ($(uname_R),5.9) ifeq ($(uname_R),5.9)
NO_UNSETENV = YesPlease NO_UNSETENV = YesPlease
NO_SETENV = YesPlease NO_SETENV = YesPlease
NO_C99_FORMAT = YesPlease NO_C99_FORMAT = YesPlease
NO_STRTOUMAX = YesPlease
endif endif
INSTALL = ginstall INSTALL = ginstall
TAR = gtar TAR = gtar
@ -517,6 +523,13 @@ ifdef NO_STRLCPY
COMPAT_CFLAGS += -DNO_STRLCPY COMPAT_CFLAGS += -DNO_STRLCPY
COMPAT_OBJS += compat/strlcpy.o COMPAT_OBJS += compat/strlcpy.o
endif endif
ifdef NO_STRTOUMAX
COMPAT_CFLAGS += -DNO_STRTOUMAX
COMPAT_OBJS += compat/strtoumax.o
endif
ifdef NO_STRTOULL
COMPAT_CFLAGS += -DNO_STRTOULL
endif
ifdef NO_SETENV ifdef NO_SETENV
COMPAT_CFLAGS += -DNO_SETENV COMPAT_CFLAGS += -DNO_SETENV
COMPAT_OBJS += compat/setenv.o COMPAT_OBJS += compat/setenv.o

10
compat/strtoumax.c

@ -0,0 +1,10 @@
#include "../git-compat-util.h"

uintmax_t gitstrtoumax (const char *nptr, char **endptr, int base)
{
#if defined(NO_STRTOULL)
return strtoul(nptr, endptr, base);
#else
return strtoull(nptr, endptr, base);
#endif
}

5
git-compat-util.h

@ -139,6 +139,11 @@ extern char *gitstrcasestr(const char *haystack, const char *needle);
extern size_t gitstrlcpy(char *, const char *, size_t); extern size_t gitstrlcpy(char *, const char *, size_t);
#endif #endif


#ifdef NO_STRTOUMAX
#define strtoumax gitstrtoumax
extern uintmax_t gitstrtoumax(const char *, char **, int);
#endif

extern void release_pack_memory(size_t); extern void release_pack_memory(size_t);


static inline char* xstrdup(const char *str) static inline char* xstrdup(const char *str)

Loading…
Cancel
Save