Răsfoiți Sursa

COMP: Fix support for vsnprintf

Andy Cedilnik 20 ani în urmă
părinte
comite
c09548b50e

+ 3 - 2
Utilities/cmtar/CMakeLists.txt

@@ -97,6 +97,7 @@ FOREACH(func
     strsep
     strdup
     strftime
+    vsnprintf
     glob
     )
   CHECK_SYMBOL_EXISTS_EX("${func}")
@@ -312,10 +313,10 @@ SET(NEED_STRMODE 1)
 ENDIF(NOT HAVE_STRMODE)
 
 IF(WIN32)
-IF(NOT HAVE_SNPRINTF)
+IF(NOT HAVE_SNPRINTF OR NOT HAVE_VSNPRINTF)
 SET(libtar_SRC ${libtar_SRC} compat/snprintf.c)
 SET(NEED_SNPRINTF 1)
-ENDIF(NOT HAVE_SNPRINTF)
+ENDIF(NOT HAVE_SNPRINTF OR NOT HAVE_VSNPRINTF)
 ENDIF(WIN32)
 
 IF(NOT HAVE_DIRNAME)

+ 5 - 3
Utilities/cmtar/compat/compat.h

@@ -201,10 +201,12 @@ int inet_aton(const char *, struct in_addr *);
 #ifdef _MSC_VER /* compile snprintf only onwin32 */
 #if !defined(HAVE_SNPRINTF)
 int mutt_snprintf(char *, size_t, const char *, ...);
-int mutt_vsnprintf(char *, size_t, const char *, va_list);
-#define snprintf mutt_snprintf
-#define vsnprintf mutt_vsnprintf
+# define snprintf mutt_snprintf
+#endif
 
+#if !defined(HAVE_VSNPRINTF)
+int mutt_vsnprintf(char *, size_t, const char *, va_list);
+# define vsnprintf mutt_vsnprintf
 #endif /* NEED_SNPRINTF && ! HAVE_SNPRINTF */
 #endif
 

+ 2 - 1
Utilities/cmtar/compat/snprintf.c

@@ -44,6 +44,7 @@
 
 #if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF)
 
+#include <stdio.h>
 #include <string.h>
 # include <ctype.h>
 #include <sys/types.h>
@@ -706,7 +707,7 @@ int mutt_snprintf (va_alist) va_dcl
   VA_SHIFT (str, char *);
   VA_SHIFT (count, size_t );
   VA_SHIFT (fmt, char *);
-  (void) mutt_vsnprintf(str, count, fmt, ap);
+  (void) vsnprintf(str, count, fmt, ap);
   VA_END;
   return(strlen(str));
 }

+ 4 - 1
Utilities/cmtar/config.h.in

@@ -51,6 +51,9 @@
 /* Define if your system has a working snprintf */
 #cmakedefine HAVE_SNPRINTF @HAVE_SNPRINTF@
 
+/* Define if your system has a working vsnprintf */
+#cmakedefine HAVE_VSNPRINTF @HAVE_VSNPRINTF@
+
 /* Define to 1 if you have the <stdint.h> header file. */
 #cmakedefine HAVE_STDINT_H @HAVE_STDINT_H@
 
@@ -184,7 +187,7 @@
 #cmakedefine size_t @size_t@
 
 /* Define to `int' if <sys/types.h> does not define. */
-#cmakedefine ssize_t @size_t@
+#cmakedefine ssize_t @ssize_t@
 
 /* Define to `int' if <sys/types.h> doesn't define. */
 #cmakedefine uid_t @uid_t@