]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
portability: Handle system *sprintf functions with bad type signatures
authorJoel Rosdahl <joel@rosdahl.net>
Thu, 18 Nov 2010 17:22:06 +0000 (18:22 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Mon, 22 Nov 2010 20:07:35 +0000 (21:07 +0100)
m4/snprintf.m4
snprintf.c
system.h

index 1a844ba6140c02897a4564fd3b13679c0d3c31e0..cf08c5c61dd232bf041ff9871eee0fd4c9b0be2c 100644 (file)
@@ -125,9 +125,7 @@ AC_DEFUN([HW_FUNC_VSNPRINTF],
   AS_IF([test "$hw_cv_func_vsnprintf_c99" = yes],
     [AC_DEFINE([HAVE_VSNPRINTF], [1],
       [Define to 1 if you have a C99 compliant `vsnprintf' function.])],
-    [AC_DEFINE([vsnprintf], [rpl_vsnprintf],
-      [Define to rpl_vsnprintf if the replacement function should be used.])
-    AC_CHECK_HEADERS([inttypes.h locale.h stddef.h stdint.h])
+    [AC_CHECK_HEADERS([inttypes.h locale.h stddef.h stdint.h])
     AC_CHECK_MEMBERS([struct lconv.decimal_point, struct lconv.thousands_sep],
       [], [], [#include <locale.h>])
     AC_TYPE_LONG_DOUBLE
@@ -171,9 +169,7 @@ AC_DEFUN([HW_FUNC_SNPRINTF],
   AS_IF([test "$hw_cv_func_snprintf_c99" = yes],
     [AC_DEFINE([HAVE_SNPRINTF], [1],
       [Define to 1 if you have a C99 compliant `snprintf' function.])],
-    [AC_DEFINE([snprintf], [rpl_snprintf],
-      [Define to rpl_snprintf if the replacement function should be used.])
-    _HW_FUNC_XPRINTF_REPLACE])
+    [_HW_FUNC_XPRINTF_REPLACE])
 ])# HW_FUNC_SNPRINTF
 
 # HW_FUNC_VASPRINTF
@@ -188,9 +184,7 @@ AC_DEFUN([HW_FUNC_VASPRINTF],
     [hw_cv_func_vasprintf=yes],
     [hw_cv_func_vasprintf=no])
   AS_IF([test "$hw_cv_func_vasprintf" = no],
-    [AC_DEFINE([vasprintf], [rpl_vasprintf],
-      [Define to rpl_vasprintf if the replacement function should be used.])
-    AC_CHECK_HEADERS([stdlib.h])
+    [AC_CHECK_HEADERS([stdlib.h])
     HW_FUNC_VA_COPY
     AS_IF([test "$hw_cv_func_va_copy" = no],
       [HW_FUNC___VA_COPY])
@@ -209,9 +203,7 @@ AC_DEFUN([HW_FUNC_ASPRINTF],
     [hw_cv_func_asprintf=yes],
     [hw_cv_func_asprintf=no])
   AS_IF([test "$hw_cv_func_asprintf" = no],
-    [AC_DEFINE([asprintf], [rpl_asprintf],
-      [Define to rpl_asprintf if the replacement function should be used.])
-    _HW_FUNC_XPRINTF_REPLACE])
+    [_HW_FUNC_XPRINTF_REPLACE])
 ])# HW_FUNC_ASPRINTF
 
 # _HW_FUNC_XPRINTF_REPLACE
index 587c6be3a92a370a7978869f38915a1da1551fb1..600eff2d69155fdef00a22184c0217130cb383ac 100644 (file)
@@ -524,6 +524,23 @@ static LDOUBLE mypow10(int);
 
 extern int errno;
 
+#if !HAVE_VSNPRINTF
+  int rpl_vsnprintf(char *, size_t, const char *, va_list);
+  #define vsnprintf rpl_vsnprintf
+#endif
+#if !HAVE_SNPRINTF
+  int rpl_snprintf(char *, size_t, const char *, ...);
+  #define snprintf rpl_snprintf
+#endif
+#if !HAVE_VASPRINTF
+  int rpl_vasprintf(char **, const char *, va_list);
+  #define vasprintf rpl_vasprintf
+#endif
+#if !HAVE_ASPRINTF
+  int rpl_asprintf(char **, const char *, ...);
+  #define asprintf rpl_asprintf
+#endif
+
 int
 rpl_vsnprintf(char *str, size_t size, const char *format, va_list args)
 {
index d143cf167dc2e87a30b3a11656ac803da074949b..a75025f71e10ab4a883ca6ec464b6cb72f7b0686 100644 (file)
--- a/system.h
+++ b/system.h
 
 #if !HAVE_VSNPRINTF
   int rpl_vsnprintf(char *, size_t, const char *, va_list);
+  #define vsnprintf rpl_vsnprintf
 #endif
 #if !HAVE_SNPRINTF
   int rpl_snprintf(char *, size_t, const char *, ...);
+  #define snprintf rpl_snprintf
 #endif
 #if !HAVE_VASPRINTF
   int rpl_vasprintf(char **, const char *, va_list);
+  #define vasprintf rpl_vasprintf
 #endif
 #if !HAVE_ASPRINTF
   int rpl_asprintf(char **, const char *, ...);
+  #define asprintf rpl_asprintf
 #endif
 
 #ifdef HAVE_STDBOOL_H