From: Junio C Hamano Date: Sun, 9 Mar 2008 05:29:50 +0000 (-0800) Subject: Merge branch 'mr/compat-snprintf' X-Git-Tag: v1.5.5-rc0~43 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/6e79a8858560a3a3e2b5e092a6cbdd5f3f1ad13b?hp=-c Merge branch 'mr/compat-snprintf' * mr/compat-snprintf: Add compat/snprintf.c for systems that return bogus --- 6e79a8858560a3a3e2b5e092a6cbdd5f3f1ad13b diff --combined Makefile index 6e857e62c3,6af7132853..7fbb815782 --- a/Makefile +++ b/Makefile @@@ -3,6 -3,10 +3,10 @@@ all: # Define V=1 to have a more verbose compile. # + # Define SNPRINTF_RETURNS_BOGUS if your are on a system which snprintf() + # or vsnprintf() return -1 instead of number of characters which would + # have been written to the final string if enough space had been available. + # # Define FREAD_READS_DIRECTORIES if your are on a system which succeeds # when attempting to read from an fopen'ed directory. # @@@ -478,7 -482,6 +482,7 @@@ ifeq ($(uname_S),FreeBSD NO_MEMMEM = YesPlease BASIC_CFLAGS += -I/usr/local/include BASIC_LDFLAGS += -L/usr/local/lib + DIR_HAS_BSD_GROUP_SEMANTICS = YesPlease endif ifeq ($(uname_S),OpenBSD) NO_STRCASESTR = YesPlease @@@ -630,6 -633,10 +634,10 @@@ endi ifdef NO_C99_FORMAT BASIC_CFLAGS += -DNO_C99_FORMAT endif + ifdef SNPRINTF_RETURNS_BOGUS + COMPAT_CFLAGS += -DSNPRINTF_RETURNS_BOGUS + COMPAT_OBJS += compat/snprintf.o + endif ifdef FREAD_READS_DIRECTORIES COMPAT_CFLAGS += -DFREAD_READS_DIRECTORIES COMPAT_OBJS += compat/fopen.o @@@ -748,9 -755,6 +756,9 @@@ ifdef THREADED_DELTA_SEARC EXTLIBS += -lpthread LIB_OBJS += thread-utils.o endif +ifdef DIR_HAS_BSD_GROUP_SEMANTICS + COMPAT_CFLAGS += -DDIR_HAS_BSD_GROUP_SEMANTICS +endif ifeq ($(TCLTK_PATH),) NO_TCLTK=NoThanks diff --combined git-compat-util.h index 591244351e,9d04faefb8..73968e02b0 --- a/git-compat-util.h +++ b/git-compat-util.h @@@ -209,6 -209,15 +209,15 @@@ void *gitmemmem(const void *haystack, s extern FILE *git_fopen(const char*, const char*); #endif + #ifdef SNPRINTF_RETURNS_BOGUS + #define snprintf git_snprintf + extern int git_snprintf(char *str, size_t maxsize, + const char *format, ...); + #define vsnprintf git_vsnprintf + extern int git_vsnprintf(char *str, size_t maxsize, + const char *format, va_list ap); + #endif + #ifdef __GLIBC_PREREQ #if __GLIBC_PREREQ(2, 1) #define HAVE_STRCHRNUL @@@ -437,10 -446,4 +446,10 @@@ void git_qsort(void *base, size_t nmemb #define qsort git_qsort #endif +#ifndef DIR_HAS_BSD_GROUP_SEMANTICS +# define FORCE_DIR_SET_GID S_ISGID +#else +# define FORCE_DIR_SET_GID 0 +#endif + #endif