]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
1475. [port] Probe for old sprintf().
authorMark Andrews <marka@isc.org>
Tue, 24 Jun 2003 06:24:44 +0000 (06:24 +0000)
committerMark Andrews <marka@isc.org>
Tue, 24 Jun 2003 06:24:44 +0000 (06:24 +0000)
CHANGES
configure
configure.in
lib/isc/include/isc/platform.h.in
lib/isc/include/isc/print.h
lib/isc/print.c

diff --git a/CHANGES b/CHANGES
index 55923de7348d9aff706fbb9e3d0cfcfcf292213e..c64a4f20b32c67ae88ae7b9edf50c1cae66dae22 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,5 @@
+1475.  [port]          Probe for old sprintf().
+
 1474.  [port]          Provide strtoul() and memmove() for platforms
                        without them.
 
index 55af0318f6311a415e55aa103373b81bf38bf210..577c7214bb685350862048fca4b450874998352e 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.in Revision: 1.343 .
+# From configure.in Revision: 1.344 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.53.
 #
 
 
 
+ISC_PRINT_OBJS=
+ISC_PRINT_SRCS=
+echo "$as_me:$LINENO: checking sprintf" >&5
+echo $ECHO_N "checking sprintf... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+#include "confdefs.h"
+
+#include <stdio.h>
+
+#ifdef F77_DUMMY_MAIN
+#  ifdef __cplusplus
+     extern "C"
+#  endif
+   int F77_DUMMY_MAIN() { return 1; }
+#endif
+int
+main ()
+{
+ char buf[2]; return(*sprintf(buf,"x"));
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+ISC_PRINT_OBJS="print.$O"
+ISC_PRINT_SRCS="print.c"
+ISC_PLATFORM_NEEDSPRINTF="#define ISC_PLATFORM_NEEDSPRINTF"
+
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ISC_PLATFORM_NEEDSPRINTF="#undef ISC_PLATFORM_NEEDSPRINTF"
+
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+
+
 echo "$as_me:$LINENO: checking for vsnprintf" >&5
 echo $ECHO_N "checking for vsnprintf... $ECHO_C" >&6
 if test "${ac_cv_func_vsnprintf+set}" = set; then
@@ -13391,12 +13441,14 @@ echo "${ECHO_T}$ac_cv_func_vsnprintf" >&6
 if test $ac_cv_func_vsnprintf = yes; then
   ISC_PLATFORM_NEEDVSNPRINTF="#undef ISC_PLATFORM_NEEDVSNPRINTF"
 else
-  ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS print.$O"
-        ISC_EXTRA_SRCS="$ISC_EXTRA_SRCS print.c"
+  ISC_EXTRA_OBJS="print.$O"
+        ISC_EXTRA_SRCS="print.c"
         ISC_PLATFORM_NEEDVSNPRINTF="#define ISC_PLATFORM_NEEDVSNPRINTF 1"
 fi
 
 
+ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS $ISC_PRINT_OBJS"
+ISC_EXTRA_SRCS="$ISC_EXTRA_SRCS $ISC_PRINT_SRCS"
 
 echo "$as_me:$LINENO: checking for strerror" >&5
 echo $ECHO_N "checking for strerror... $ECHO_C" >&6
@@ -15590,6 +15642,7 @@ s,@ISC_PLATFORM_NEEDMEMMOVE@,$ISC_PLATFORM_NEEDMEMMOVE,;t t
 s,@ISC_PLATFORM_NEEDSTRTOUL@,$ISC_PLATFORM_NEEDSTRTOUL,;t t
 s,@ISC_PLATFORM_NEEDSTRLCPY@,$ISC_PLATFORM_NEEDSTRLCPY,;t t
 s,@ISC_PLATFORM_NEEDSTRLCAT@,$ISC_PLATFORM_NEEDSTRLCAT,;t t
+s,@ISC_PLATFORM_NEEDSPRINTF@,$ISC_PLATFORM_NEEDSPRINTF,;t t
 s,@ISC_PLATFORM_NEEDVSNPRINTF@,$ISC_PLATFORM_NEEDVSNPRINTF,;t t
 s,@ISC_EXTRA_OBJS@,$ISC_EXTRA_OBJS,;t t
 s,@ISC_EXTRA_SRCS@,$ISC_EXTRA_SRCS,;t t
index dd2624b289daebe3e50d367cffbce88c423cc63e..ff2a08d39b83490f561044f7db2230ba2e188b72 100644 (file)
@@ -18,7 +18,7 @@ AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)dnl
 esyscmd([sed "s/^/# /" COPYRIGHT])dnl
 AC_DIVERT_POP()dnl
 
-AC_REVISION($Revision: 1.343 $)
+AC_REVISION($Revision: 1.344 $)
 
 AC_INIT(lib/dns/name.c)
 AC_PREREQ(2.13)
@@ -1595,12 +1595,30 @@ AC_CHECK_FUNC(strlcat,
        [ISC_PLATFORM_NEEDSTRLCAT="#define ISC_PLATFORM_NEEDSTRLCAT 1"])
 AC_SUBST(ISC_PLATFORM_NEEDSTRLCAT)
 
+ISC_PRINT_OBJS=
+ISC_PRINT_SRCS=
+AC_MSG_CHECKING(sprintf)
+AC_TRY_COMPILE([
+#include <stdio.h>
+],
+[ char buf[2]; return(*sprintf(buf,"x"));],
+[
+ISC_PRINT_OBJS="print.$O"
+ISC_PRINT_SRCS="print.c"
+ISC_PLATFORM_NEEDSPRINTF="#define ISC_PLATFORM_NEEDSPRINTF"
+],
+[ISC_PLATFORM_NEEDSPRINTF="#undef ISC_PLATFORM_NEEDSPRINTF"]
+)
+AC_SUBST(ISC_PLATFORM_NEEDSPRINTF)
+
 AC_CHECK_FUNC(vsnprintf,
        [ISC_PLATFORM_NEEDVSNPRINTF="#undef ISC_PLATFORM_NEEDVSNPRINTF"],
-       [ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS print.$O"
-        ISC_EXTRA_SRCS="$ISC_EXTRA_SRCS print.c"
+       [ISC_EXTRA_OBJS="print.$O"
+        ISC_EXTRA_SRCS="print.c"
         ISC_PLATFORM_NEEDVSNPRINTF="#define ISC_PLATFORM_NEEDVSNPRINTF 1"])
 AC_SUBST(ISC_PLATFORM_NEEDVSNPRINTF)
+ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS $ISC_PRINT_OBJS"
+ISC_EXTRA_SRCS="$ISC_EXTRA_SRCS $ISC_PRINT_SRCS"
 
 AC_CHECK_FUNC(strerror, AC_DEFINE(HAVE_STRERROR))
 
index 6c9edb46df50e0b3b7cd776f0bfe85dcf2a6f978..884e0883b25cc1005527b9873da1b989e3612962 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: platform.h.in,v 1.32 2003/06/24 05:10:33 marka Exp $ */
+/* $Id: platform.h.in,v 1.33 2003/06/24 06:23:59 marka Exp $ */
 
 #ifndef ISC_PLATFORM_H
 #define ISC_PLATFORM_H 1
  */
 @ISC_PLATFORM_NEEDVSNPRINTF@
 
+/*
+ * If this system need a modern sprintf() that returns (int) not (char*).
+ */
+@ISC_PLATFORM_NEEDSPRINTF@
+
 /*
  * The printf format string modifier to use with isc_uint64_t values.
  */
index 7a1bc83b6741b35427ecae74fe7de7a4200b071f..55455b5b8cb94b8ae61c3a76e31e72228b6378ff 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: print.h,v 1.17 2001/02/27 02:19:33 gson Exp $ */
+/* $Id: print.h,v 1.18 2003/06/24 06:23:59 marka Exp $ */
 
 #ifndef ISC_PRINT_H
 #define ISC_PRINT_H 1
 #define ISC_PLATFORM_NEEDVSNPRINTF
 #endif
 
+#if !defined(ISC_PLATFORM_NEEDSPRINTF) && defined(ISC__PRINT_SOURCE)
+#define ISC_PLATFORM_NEEDSPRINTF
+#endif
+
 /***
  *** Macros
  ***/
 #ifdef ISC_PLATFORM_NEEDVSNPRINTF
 #include <stdarg.h>
 #include <stddef.h>
+#endif
 
 ISC_LANG_BEGINDECLS
 
+#ifdef ISC_PLATFORM_NEEDVSNPRINTF
 int
 isc_print_vsnprintf(char *str, size_t size, const char *format, va_list ap)
      ISC_FORMAT_PRINTF(3, 0);
@@ -62,8 +68,14 @@ int
 isc_print_snprintf(char *str, size_t size, const char *format, ...)
      ISC_FORMAT_PRINTF(3, 4);
 #define snprintf isc_print_snprintf
+#endif /* ISC_PLATFORM_NEEDVSNPRINTF */
+
+#ifdef ISC_PLATFORM_NEEDSPRINTF
+int
+isc_print_sprintf(char *str, const char *format, ...) ISC_FORMAT_PRINTF(2, 3);
+#define sprintf isc_print_sprintf
+#endif
 
 ISC_LANG_ENDDECLS
-#endif /* ISC_PLATFORM_NEEDVSNPRINTF */
 
 #endif /* ISC_PRINT_H */
index ec953fd1bae99a719d0a151513a6a7e7e68c8ba4..c7042f3b00903af1dc47bc34c24108ac8933243e 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: print.c,v 1.24 2003/06/24 05:10:32 marka Exp $ */
+/* $Id: print.c,v 1.25 2003/06/24 06:23:58 marka Exp $ */
 
 #include <config.h>
 
 #include <isc/stdlib.h>
 #include <isc/util.h>
 
+int
+isc_print_sprintf(char *str, const char *format, ...) {
+       va_list ap;
+
+       va_start(ap, format);
+       vsprintf(str, format, ap);
+       va_end(ap);
+       return (strlen(str));
+}
+
 /*
  * Return length of string that would have been written if not truncated.
  */