summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f496454)
raw | patch | inline | side by side (parent: f496454)
author | Jason Riedy <ejr@EECS.Berkeley.EDU> | |
Tue, 20 Feb 2007 00:22:56 +0000 (16:22 -0800) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Tue, 20 Feb 2007 02:20:30 +0000 (18:20 -0800) |
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>
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>
Makefile | patch | blob | history | |
compat/strtoumax.c | [new file with mode: 0644] | patch | blob |
git-compat-util.h | patch | blob | history |
diff --git a/Makefile b/Makefile
index dae29199655455abb4fa960ce4fb5d12ee469e9a..f85fb7c197a6c9c12d0388c385f7583de7cd0f51 100644 (file)
--- a/Makefile
+++ b/Makefile
#
# 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_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.
NO_UNSETENV = YesPlease
NO_SETENV = YesPlease
NO_C99_FORMAT = YesPlease
+ NO_STRTOUMAX = YesPlease
endif
ifeq ($(uname_R),5.9)
NO_UNSETENV = YesPlease
NO_SETENV = YesPlease
NO_C99_FORMAT = YesPlease
+ NO_STRTOUMAX = YesPlease
endif
INSTALL = ginstall
TAR = gtar
COMPAT_CFLAGS += -DNO_STRLCPY
COMPAT_OBJS += compat/strlcpy.o
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
COMPAT_CFLAGS += -DNO_SETENV
COMPAT_OBJS += compat/setenv.o
diff --git a/compat/strtoumax.c b/compat/strtoumax.c
--- /dev/null
+++ b/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
+}
diff --git a/git-compat-util.h b/git-compat-util.h
index 105ac28f9766cb8800fcf6071fd94ed0e3cdf90a..9863cf671f7522f73ea5a88af0d1234488c73396 100644 (file)
--- a/git-compat-util.h
+++ b/git-compat-util.h
extern size_t gitstrlcpy(char *, const char *, size_t);
#endif
+#ifdef NO_STRTOUMAX
+#define strtoumax gitstrtoumax
+extern uintmax_t gitstrtoumax(const char *, char **, int);
+#endif
+
extern void release_pack_memory(size_t);
static inline char* xstrdup(const char *str)