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

Define compat version of mkdtemp for systems lacking it

Solaris 9 doesn't have mkdtemp() so we need to emulate it for the rsync transport implementation. Since Solaris 9 is lacking this function we can also reasonably assume it is not available on Solaris 8 either. The new Makfile definition NO_MKDTEMP can be set to enable the git compat version. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Oct 20, 2007 at 16:03 UTC ca5bb5d5390e4ec709ca3e11c451c58a836d4ee6
3 files changed +21
Makefile
+8
@@ -38,6 +38,8 @@ all::
38 #
39 # Define NO_SETENV if you don't have setenv in the C library.
40 #
41 +# Define NO_MKDTEMP if you don't have mkdtemp in the C library.
42 +#
43 # Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.
44 # Enable it on Windows. By default, symrefs are still used.
45 #
@@ -414,12 +416,14 @@ ifeq ($(uname_S),SunOS)
416 NEEDS_LIBICONV = YesPlease
417 NO_UNSETENV = YesPlease
418 NO_SETENV = YesPlease
419 + NO_MKDTEMP = YesPlease
420 NO_C99_FORMAT = YesPlease
421 NO_STRTOUMAX = YesPlease
422 endif
423 ifeq ($(uname_R),5.9)
424 NO_UNSETENV = YesPlease
425 NO_SETENV = YesPlease
426 + NO_MKDTEMP = YesPlease
427 NO_C99_FORMAT = YesPlease
428 NO_STRTOUMAX = YesPlease
429 endif
@@ -610,6 +614,10 @@ ifdef NO_SETENV
614 COMPAT_CFLAGS += -DNO_SETENV
615 COMPAT_OBJS += compat/setenv.o
616 endif
617 +ifdef NO_MKDTEMP
618 + COMPAT_CFLAGS += -DNO_MKDTEMP
619 + COMPAT_OBJS += compat/mkdtemp.o
620 +endif
621 ifdef NO_UNSETENV
622 COMPAT_CFLAGS += -DNO_UNSETENV
623 COMPAT_OBJS += compat/unsetenv.o
compat/mkdtemp.c new
+8
@@ -0,0 +1,8 @@
1 +#include "../git-compat-util.h"
2 +
3 +char *gitmkdtemp(char *template)
4 +{
5 + if (!mktemp(template) || mkdir(template, 0700))
6 + return NULL;
7 + return template;
8 +}
git-compat-util.h
+5
@@ -147,6 +147,11 @@ extern ssize_t git_pread(int fd, void *buf, size_t count, off_t offset);
147 extern int gitsetenv(const char *, const char *, int);
148 #endif
149
150 +#ifdef NO_MKDTEMP
151 +#define mkdtemp gitmkdtemp
152 +extern char *gitmkdtemp(char *);
153 +#endif
154 +
155 #ifdef NO_UNSETENV
156 #define unsetenv gitunsetenv
157 extern void gitunsetenv(const char *);