@matheusbsbs / matheus-bagliano / commits / bc6b4f52fc
Fork 0

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>

Jason Riedy committed Feb 19, 2007 at 16:22 UTC bc6b4f52fc79712db637ff90a472b82b32695e11
3 files changed +28
Makefile
+13
@@ -28,6 +28,10 @@ all::
28 #
29 # Define NO_STRLCPY if you don't have strlcpy.
30 #
31 +# Define NO_STRTOUMAX if you don't have strtoumax in the C library.
32 +# If your compiler also does not support long long or does not have
33 +# strtoull, define NO_STRTOULL.
34 +#
35 # Define NO_SETENV if you don't have setenv in the C library.
36 #
37 # Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.
@@ -353,11 +357,13 @@ ifeq ($(uname_S),SunOS)
357 NO_UNSETENV = YesPlease
358 NO_SETENV = YesPlease
359 NO_C99_FORMAT = YesPlease
360 + NO_STRTOUMAX = YesPlease
361 endif
362 ifeq ($(uname_R),5.9)
363 NO_UNSETENV = YesPlease
364 NO_SETENV = YesPlease
365 NO_C99_FORMAT = YesPlease
366 + NO_STRTOUMAX = YesPlease
367 endif
368 INSTALL = ginstall
369 TAR = gtar
@@ -517,6 +523,13 @@ ifdef NO_STRLCPY
523 COMPAT_CFLAGS += -DNO_STRLCPY
524 COMPAT_OBJS += compat/strlcpy.o
525 endif
526 +ifdef NO_STRTOUMAX
527 + COMPAT_CFLAGS += -DNO_STRTOUMAX
528 + COMPAT_OBJS += compat/strtoumax.o
529 +endif
530 +ifdef NO_STRTOULL
531 + COMPAT_CFLAGS += -DNO_STRTOULL
532 +endif
533 ifdef NO_SETENV
534 COMPAT_CFLAGS += -DNO_SETENV
535 COMPAT_OBJS += compat/setenv.o
compat/strtoumax.c new
+10
@@ -0,0 +1,10 @@
1 +#include "../git-compat-util.h"
2 +
3 +uintmax_t gitstrtoumax (const char *nptr, char **endptr, int base)
4 +{
5 +#if defined(NO_STRTOULL)
6 + return strtoul(nptr, endptr, base);
7 +#else
8 + return strtoull(nptr, endptr, base);
9 +#endif
10 +}
git-compat-util.h
+5
@@ -139,6 +139,11 @@ extern char *gitstrcasestr(const char *haystack, const char *needle);
139 extern size_t gitstrlcpy(char *, const char *, size_t);
140 #endif
141
142 +#ifdef NO_STRTOUMAX
143 +#define strtoumax gitstrtoumax
144 +extern uintmax_t gitstrtoumax(const char *, char **, int);
145 +#endif
146 +
147 extern void release_pack_memory(size_t);
148
149 static inline char* xstrdup(const char *str)