[ntp:bk-ntp-dev-send] BitKeeper diffs

Harlan Stenn stenn at deacon.udel.edu
Wed Apr 13 04:29:31 UTC 2011


#### ChangeSet ####
2011-04-13 02:22:24+00:00, davehart at shiny.ad.hartbrothers.com
  ntp_proto.c sprintf() -> snprintf()

==== ChangeLog ====
2011-04-13 02:22:17+00:00, davehart at shiny.ad.hartbrothers.com +1 -1
  ntp_proto.c sprintf() -> snprintf()

--- 1.843/ChangeLog	2011-04-12 02:01:53 -04:00
+++ 1.844/ChangeLog	2011-04-12 22:22:17 -04:00
@@ -3,7 +3,7 @@
   replacements (http://www.jhweiss.de/software/snprintf.html)
 * Remove remaining sprintf() calls except refclock_ripencc.c (which is
   kept out of --enable-all-clocks as a result), upstream libs which use
-  sprintf() ony after careful buffer sizing, and ntp_proto.c.
+  sprintf() only after careful buffer sizing.
 (4.2.7p149) 2011/04/11 Released by Harlan Stenn <stenn at ntp.org>
 * [Bug 1881] describe the {+,-,s} characters in configure --help output.
 (4.2.7p148) 2011/04/09 Released by Harlan Stenn <stenn at ntp.org>

==== ntpd/ntp_proto.c ====
2011-04-13 02:22:17+00:00, davehart at shiny.ad.hartbrothers.com +3 -2
  ntp_proto.c sprintf() -> snprintf()

--- 1.319/ntpd/ntp_proto.c	2011-02-18 22:29:54 -05:00
+++ 1.320/ntpd/ntp_proto.c	2011-04-12 22:22:17 -04:00
@@ -1573,7 +1573,8 @@ process_packet(
 		p_del = t21 - t34;
 		p_offset = (t21 + t34) / 2.;
 		if (p_del < 0 || p_del > 1.) {
-			sprintf(statstr, "t21 %.6f t34 %.6f", t21, t34);
+			snprintf(statstr, sizeof(statstr),
+			    "t21 %.6f t34 %.6f", t21, t34);
 			report_event(PEVNT_XERR, peer, statstr);
 			return;
 		}
@@ -1597,7 +1598,7 @@ process_packet(
 			peer->aorg = p_xmt;
 			peer->borg = peer->dst;
 			if (t34 < 0 || t34 > 1.) {
-				sprintf(statstr,
+				snprintf(statstr, sizeof(statstr),
 				    "offset %.6f delay %.6f", t21, t34);
 				report_event(PEVNT_XERR, peer, statstr);
 				return;

#### ChangeSet ####
2011-04-13 01:02:31+00:00, davehart at shiny.ad.hartbrothers.com
  Move rpl_vsnprintf() declaration and #define vsnprintf to config.h

==== include/l_stdlib.h ====
2011-04-13 01:02:30+00:00, davehart at shiny.ad.hartbrothers.com +0 -10
  Move rpl_vsnprintf() declaration and #define vsnprintf to config.h

--- 1.19/include/l_stdlib.h	2011-04-11 17:24:09 -04:00
+++ 1.20/include/l_stdlib.h	2011-04-12 21:02:30 -04:00
@@ -131,16 +131,6 @@ struct sigvec;
 extern	int	sigvec		(int, struct sigvec *, struct sigvec *);
 #endif
 
-#if HW_WANT_RPL_VSNPRINTF
-#define vsnprintf rpl_vsnprintf
-int rpl_vsnprintf(char *, size_t, const char *, va_list);
-#endif
-
-#if HW_WANT_RPL_SNPRINTF
-#define snprintf rpl_snprintf
-int rpl_snprintf(char *, size_t, const char *, ...);
-#endif
-
 #ifdef DECL_STDIO_0
 #if defined(FILE) || defined(BUFSIZ)
 extern	int	_flsbuf		(int, FILE *);

==== lib/isc/inet_ntop.c ====
2011-04-13 01:02:30+00:00, davehart at shiny.ad.hartbrothers.com +2 -3
  leftover SNPRINTF() -> snprintf() overlooked in prior cset.

--- 1.9/lib/isc/inet_ntop.c	2011-04-12 02:01:53 -04:00
+++ 1.10/lib/isc/inet_ntop.c	2011-04-12 21:02:30 -04:00
@@ -90,9 +90,8 @@ inet_ntop4(const unsigned char *src, cha
 	static const char *fmt = "%u.%u.%u.%u";
 	char tmp[sizeof("255.255.255.255")];
 
-	/* NTP local change to use SNPRINTF() macro for SunOS4 compat */
-	if (SNPRINTF((tmp, sizeof(tmp), fmt, src[0], src[1], src[2],
-		      src[3])) >= size)
+	if (snprintf(tmp, sizeof(tmp), fmt, src[0], src[1], src[2],
+		     src[3]) >= size)
 	{
 		errno = ENOSPC;
 		return (NULL);

==== libntp/msyslog.c ====
2011-04-13 01:02:30+00:00, davehart at shiny.ad.hartbrothers.com +19 -2
  Work around strerror_r return type misdetection.

--- 1.39/libntp/msyslog.c	2011-04-05 03:05:43 -04:00
+++ 1.40/libntp/msyslog.c	2011-04-12 21:02:30 -04:00
@@ -15,9 +15,9 @@
 #endif
 #include <stdio.h>
 
+#include "ntp_string.h"
 #include "ntp.h"
 #include "ntp_debug.h"
-#include "ntp_string.h"
 #include "ntp_syslog.h"
 
 #ifdef SYS_WINNT
@@ -40,6 +40,13 @@ extern	char *	progname;
 void	addto_syslog	(int, const char *);
 void	format_errmsg	(char *, size_t, const char *, int);
 
+/*
+ * Work around misdetection by AC_FUNC_STRERROR_R on Debian Linux.
+ */
+#if defined(STRERROR_R_CHAR_P) && strerror_r == __xpg_strerror_r
+# undef STRERROR_R_CHAR_P
+#endif
+
 
 /*
  * errno_to_str() - a thread-safe strerror() replacement.
@@ -58,6 +65,7 @@ errno_to_str(
 # if defined(STRERROR_R_CHAR_P) || !HAVE_DECL_STRERROR_R
 	char *	pstatic;
 
+	buf[0] = '\0';
 #  ifdef STRERROR_R_CHAR_P
 	/*
 	 * For older GNU strerror_r, the return value either points to
@@ -67,7 +75,16 @@ errno_to_str(
 #  else
 	pstatic = strerror(err);
 #  endif
-	if (pstatic != buf)
+	if (NULL == pstatic && '\0' == buf[0])
+		snprintf(buf, bufsiz, "%s(%d): errno %d",
+#  ifdef STRERROR_R_CHAR_P
+			 "strerror_r",
+#  else
+			 "strerror",
+#  endif
+			 err, errno);
+	/* protect against believing an int return is a pointer */
+	else if (pstatic != buf && pstatic > (char *)bufsiz)
 		strlcpy(buf, pstatic, bufsiz);
 # else
 	int	rc;

==== ports/winnt/include/config.h ====
2011-04-13 01:02:30+00:00, davehart at shiny.ad.hartbrothers.com +5 -0
  Move rpl_vsnprintf() declaration and #define vsnprintf to config.h

--- 1.96/ports/winnt/include/config.h	2011-04-12 02:01:53 -04:00
+++ 1.97/ports/winnt/include/config.h	2011-04-12 21:02:30 -04:00
@@ -389,7 +389,12 @@ typedef __int32 int32_t;	/* define a typ
 #define HAVE_BSD_NICE			/* emulate BSD setpriority() */
 
 #define HW_WANT_RPL_VSNPRINTF		1
+#define vsnprintf			rpl_vsnprintf
+#include <stdarg.h>
+int rpl_vsnprintf(char *, size_t, const char *, va_list);
 #define HW_WANT_RPL_SNPRINTF		1
+#define snprintf			rpl_snprintf
+int rpl_snprintf(char *, size_t, const char *, ...);
 #define HAVE_VSNPRINTF			1
 #define HAVE_SNPRINTF			1
 

==== ports/winnt/libntp/syslog.c ====
2011-04-13 01:02:30+00:00, davehart at shiny.ad.hartbrothers.com +2 -0
  include ntp_stdlib.h for strlcpy() declaration

--- 1.10/ports/winnt/libntp/syslog.c	2011-04-12 02:01:54 -04:00
+++ 1.11/ports/winnt/libntp/syslog.c	2011-04-12 21:02:30 -04:00
@@ -28,6 +28,8 @@
 #include <isc/strerror.h>
 #include <lib_strbuf.h>
 
+#include "ntp_stdlib.h"
+
 #include "messages.h"
 
 static HANDLE hAppLog = NULL;

==== sntp/m4/ntp_libntp.m4 ====
2011-04-13 01:02:30+00:00, davehart at shiny.ad.hartbrothers.com +45 -19
  Move rpl_vsnprintf() declaration and #define vsnprintf to config.h

--- 1.12/sntp/m4/ntp_libntp.m4	2011-04-11 17:53:47 -04:00
+++ 1.13/sntp/m4/ntp_libntp.m4	2011-04-12 21:02:30 -04:00
@@ -27,6 +27,7 @@ NTP_LIB_M
 
 AC_FUNC_FORK
 AC_FUNC_ALLOCA
+AC_FUNC_STRERROR_R
 
 ac_busted_vpath_in_make=no
 case "$build" in
@@ -279,7 +280,6 @@ case "$ac_cv_c_char_unsigned$ac_cv_sizeo
 esac
 
 AC_TYPE_UID_T
-AC_FUNC_STRERROR_R
 
 m4_divert_text([HELP_ENABLE],
 [AS_HELP_STRING([defaults:],
@@ -455,27 +455,53 @@ AC_SUBST([LIBISC_PTHREADS_NOTHREADS])
 AM_CONDITIONAL([PTHREADS], [test "$have_pthreads" != "no"])
 
 AC_DEFUN([NTP_BEFORE_HW_FUNC_VSNPRINTF], [
-AC_BEFORE([$0], [HW_FUNC_VSNPRINTF])
-AC_BEFORE([$0], [HW_FUNC_SNPRINTF])
-AC_ARG_ENABLE(
-    [c99-snprintf],
-    [AS_HELP_STRING([--enable-c99-snprintf], [s force replacement])],
-    [force_c99_snprintf=$enableval],
-    [force_c99_snprintf=no]
-    )
-case "$force_c99_snprintf" in
- yes)
-    hw_force_rpl_snprintf=yes
-    hw_force_rpl_vsnprintf=yes
-esac
-hw_nodef_snprintf=yes
-hw_nodef_vsnprintf=yes
+    AC_BEFORE([$0], [HW_FUNC_VSNPRINTF])dnl
+    AC_BEFORE([$0], [HW_FUNC_SNPRINTF])dnl
+    AC_ARG_ENABLE(
+	[c99-snprintf],
+	[AS_HELP_STRING([--enable-c99-snprintf], [s force replacement])],
+	[force_c99_snprintf=$enableval],
+	[force_c99_snprintf=no]
+	)
+    case "$force_c99_snprintf" in
+     yes)
+	hw_force_rpl_snprintf=yes
+	hw_force_rpl_vsnprintf=yes
+    esac
+    AH_TOP([
+	#if !defined(_KERNEL) && !defined(PARSESTREAM)
+	# include <stdio.h>	/* before #define vsnprintf rpl_... */
+	#endif
+	])
+    AH_BOTTOM([
+	#if !defined(_KERNEL) && !defined(PARSESTREAM)
+	# if defined(HW_WANT_RPL_VSNPRINTF)
+	#  if defined(__cplusplus)
+	extern "C" {
+	# endif
+	# include <stdarg.h>
+	int rpl_vsnprintf(char *, size_t, const char *, va_list);
+	# if defined(__cplusplus)
+	}
+	#  endif
+	# endif
+	# if defined(HW_WANT_RPL_SNPRINTF)
+	#  if defined(__cplusplus)
+	extern "C" {
+	#  endif
+	int rpl_snprintf(char *, size_t, const char *, ...);
+	#  if defined(__cplusplus)
+	}
+	#  endif
+	# endif
+	#endif	/* !defined(_KERNEL) && !defined(PARSESTREAM) */
+	])
 ]) dnl end of AC_DEFUN of NTP_BEFORE_HW_FUNC_VSNPRINTF
 
 AC_DEFUN([NTP_C99_SNPRINTF], [
-AC_REQUIRE([NTP_BEFORE_HW_FUNC_VSNPRINTF])
-AC_REQUIRE([HW_FUNC_VSNPRINTF])
-AC_REQUIRE([HW_FUNC_SNPRINTF])
+    AC_REQUIRE([NTP_BEFORE_HW_FUNC_VSNPRINTF])dnl
+    AC_REQUIRE([HW_FUNC_VSNPRINTF])dnl
+    AC_REQUIRE([HW_FUNC_SNPRINTF])dnl
 ]) dnl end of DEFUN of NTP_C99_SNPRINTF
 
 NTP_C99_SNPRINTF

==== sntp/m4/snprintf.m4 ====
2011-04-13 01:02:30+00:00, davehart at shiny.ad.hartbrothers.com +1 -6
  Update comment.

--- 1.1/sntp/m4/snprintf.m4	2011-04-11 17:24:11 -04:00
+++ 1.2/sntp/m4/snprintf.m4	2011-04-12 21:02:30 -04:00
@@ -7,12 +7,7 @@
 # libopts to avoid their own replacement of snprintf.
 #
 # Changed to honor hw_nodef_snprintf, etc. which prevent config.h from
-# aliasing snprintf to rpl_snprintf, etc.  NTP uses this to defer that
-# definition until after system include files to avoid problems seen
-# on Linux building sntp/tests:
-# /usr/include/c++/4.4/cstdio:165: error: '::snprintf' has not been declared
-# This cstdio #undef's snprintf and then re-declares ::snprintf, however
-# the earlier stdio.h had its declarations aliased to rpl_snprintf, etc.
+# aliasing snprintf to rpl_snprintf, etc.
 #
 # Changed to honor hw_force_rpl_snprintf=yes, etc.  This is used by NTP
 # to test rpl_snprintf() and rpl_vsnprintf() on platforms which provide

==== tests/libntp/msyslog.cpp ====
2011-04-13 01:02:30+00:00, davehart at shiny.ad.hartbrothers.com +1 -0
  strerror() prototyped by string.h

--- 1.1/tests/libntp/msyslog.cpp	2010-12-21 01:58:01 -05:00
+++ 1.2/tests/libntp/msyslog.cpp	2011-04-12 21:02:30 -04:00
@@ -2,6 +2,7 @@
 
 extern "C" {
 #include <stdio.h>
+#include <string.h>
 #include <errno.h>
 // format_errmsg() is normally private to msyslog.c
 void	format_errmsg	(char *, size_t, const char *, int);

#### ChangeSet ####
2011-04-12 06:01:57+00:00, davehart at shiny.ad.hartbrothers.com
  Remove remaining sprintf() calls except refclock_ripencc.c (which is
    kept out of --enable-all-clocks as a result), upstream libs which use
    sprintf() ony after careful buffer sizing, and ntp_proto.c.

==== BitKeeper/deleted/14/ntp_sprintf.h~a4bd6474a120d477 ====
2011-04-12 04:55:25+00:00, davehart at shiny.ad.hartbrothers.com +0 -0
  Delete: include/ntp_sprintf.h

==== BitKeeper/deleted/53/refclock_trimbledc.c~29080509 ====
2011-04-12 05:28:40+00:00, davehart at shiny.ad.hartbrothers.com +0 -0
  Delete: ports/winnt/ntpd/refclock_trimbledc.c

==== BitKeeper/deleted/ab/refclock_trimbledc.h~29080509 ====
2011-04-12 05:28:42+00:00, davehart at shiny.ad.hartbrothers.com +0 -0
  Delete: ports/winnt/ntpd/refclock_trimbledc.h

==== ChangeLog ====
2011-04-12 06:01:53+00:00, davehart at shiny.ad.hartbrothers.com +3 -0
  Remove remaining sprintf() calls except refclock_ripencc.c (which is
    kept out of --enable-all-clocks as a result), upstream libs which use
    sprintf() ony after careful buffer sizing, and ntp_proto.c.

--- 1.842/ChangeLog	2011-04-11 17:53:47 -04:00
+++ 1.843/ChangeLog	2011-04-12 02:01:53 -04:00
@@ -1,6 +1,9 @@
 * Remove never-used, incomplete ports/winnt/ntpd/refclock_trimbledc.[ch]
 * On systems without C99-compliant (v)snprintf(), use C99-snprintf
   replacements (http://www.jhweiss.de/software/snprintf.html)
+* Remove remaining sprintf() calls except refclock_ripencc.c (which is
+  kept out of --enable-all-clocks as a result), upstream libs which use
+  sprintf() ony after careful buffer sizing, and ntp_proto.c.
 (4.2.7p149) 2011/04/11 Released by Harlan Stenn <stenn at ntp.org>
 * [Bug 1881] describe the {+,-,s} characters in configure --help output.
 (4.2.7p148) 2011/04/09 Released by Harlan Stenn <stenn at ntp.org>

==== configure.ac ====
2011-04-12 06:01:53+00:00, davehart at shiny.ad.hartbrothers.com +0 -6
  SPRINTF_CHAR check is not needed, ANSI C mandates int return type.

--- 1.524/configure.ac	2011-04-11 17:47:30 -04:00
+++ 1.525/configure.ac	2011-04-12 02:01:53 -04:00
@@ -895,12 +895,6 @@ case "$ac_cv_func_recvmsg" in
     esac
 esac
 
-case "$host" in
- *-*-sunos4*)
-    AC_DEFINE([SPRINTF_CHAR], [1], [*s*printf() functions are char*])
-    ;;
-esac
-
 AC_CACHE_CHECK(
     [number of arguments taken by setpgrp()],
     [ntp_cv_func_setpgrp_nargs],

==== include/Makefile.am ====
2011-04-12 06:01:53+00:00, davehart at shiny.ad.hartbrothers.com +0 -1
  Remove ntp_sprintf.h workaround for pre-ANSI C sprintf().

--- 1.48/include/Makefile.am	2011-03-05 17:35:32 -05:00
+++ 1.49/include/Makefile.am	2011-04-12 02:01:53 -04:00
@@ -49,7 +49,6 @@ noinst_HEADERS =	\
 	ntp_request.h	\
 	ntp_rfc2553.h	\
 	ntp_select.h	\
-	ntp_sprintf.h	\
 	ntp_stdlib.h	\
 	ntp_string.h	\
 	ntp_syscall.h	\

==== lib/isc/inet_ntop.c ====
2011-04-12 06:01:53+00:00, davehart at shiny.ad.hartbrothers.com +1 -3
  Remove ntp_sprintf.h workaround for pre-ANSI C sprintf().

--- 1.8/lib/isc/inet_ntop.c	2009-09-25 15:17:19 -04:00
+++ 1.9/lib/isc/inet_ntop.c	2011-04-12 02:01:53 -04:00
@@ -31,8 +31,6 @@ static char rcsid[] =
 #include <isc/net.h>
 #include <isc/print.h>
 
-#include "ntp_sprintf.h"	/* NTP local change, helps SunOS 4 */
-
 #define NS_INT16SZ	 2
 #define NS_IN6ADDRSZ	16
 
@@ -181,7 +179,7 @@ inet_ntop6(const unsigned char *src, cha
 			tp += strlen(tp);
 			break;
 		}
-		tp += SPRINTF((tp, "%x", words[i]));	/* NTP local change */
+		tp += sprintf(tp, "%x", words[i]);
 	}
 	/* Was it a trailing run of 0x00's? */
 	if (best.base != -1 && (best.base + best.len) ==

==== libntp/bsd_strerror.c ====
2011-04-12 06:01:53+00:00, davehart at shiny.ad.hartbrothers.com +4 -3
  sprintf() -> snprintf().

--- 1.5/libntp/bsd_strerror.c	2009-09-24 03:21:03 -04:00
+++ 1.6/libntp/bsd_strerror.c	2011-04-12 02:01:53 -04:00
@@ -39,9 +39,10 @@ strerror(
 	static char ebuf[20];
 
 	if ((unsigned int)errnum < sys_nerr)
-		return(sys_errlist[errnum]);
-	(void)sprintf(ebuf, "Unknown error: %d", errnum);
-	return(ebuf);
+		return sys_errlist[errnum];
+	snprintf(ebuf, sizeof(ebuf), "Unknown error: %d", errnum);
+
+	return ebuf;
 }
 #else
 int strerror_bs;

==== libntp/snprintf.c ====
2011-04-12 06:01:53+00:00, davehart at shiny.ad.hartbrothers.com +4 -4
  clarify HAVE_* macros in non-Autoconf use.

--- 1.9/libntp/snprintf.c	2011-04-11 17:24:10 -04:00
+++ 1.10/libntp/snprintf.c	2011-04-12 02:01:53 -04:00
@@ -123,10 +123,10 @@
  *	HW_WANT_RPL_SNPRINTF
  *	HW_WANT_RPL_VASPRINTF
  *	HW_WANT_RPL_ASPRINTF
- *	HAVE_VSNPRINTF
- *	HAVE_SNPRINTF
- *	HAVE_VASPRINTF
- *	HAVE_ASPRINTF
+ *	HAVE_VSNPRINTF	// define to 1 #if HW_WANT_RPL_VSNPRINTF
+ *	HAVE_SNPRINTF	// define to 1 #if HW_WANT_RPL_SNPRINTF
+ *	HAVE_VASPRINTF	// define to 1 #if HW_WANT_RPL_VASPRINTF
+ *	HAVE_ASPRINTF	// define to 1 #if HW_WANT_RPL_ASPRINTF
  *	HAVE_STDARG_H
  *	HAVE_STDDEF_H
  *	HAVE_STDINT_H

==== libparse/ieee754io.c ====
2011-04-12 06:01:53+00:00, davehart at shiny.ad.hartbrothers.com +19 -15
  sprintf() -> snprintf().

--- 1.10/libparse/ieee754io.c	2011-04-09 02:20:31 -04:00
+++ 1.11/libparse/ieee754io.c	2011-04-12 02:01:53 -04:00
@@ -89,14 +89,15 @@ fmt_flt(
 	unsigned long ch
 	)
 {
-  char *buf;
+	char *buf;
 
-  LIB_GETBUF(buf);
-  sprintf(buf, "%c %s %s %s", sign ? '-' : '+',
-	  fmt_blong(ch, 11),
-	  fmt_blong(mh, 20),
-	  fmt_blong(ml, 32));
-  return buf;
+	LIB_GETBUF(buf);
+	snprintf(buf, LIB_BUFLENGTH, "%c %s %s %s", sign ? '-' : '+',
+		 fmt_blong(ch, 11),
+		 fmt_blong(mh, 20),
+		 fmt_blong(ml, 32));
+
+	return buf;
 }
 
 static char *
@@ -105,15 +106,18 @@ fmt_hex(
 	int length
 	)
 {
-  char *buf;
-  int i;
+	char *	buf;
+	char	hex[4];
+	int	i;
+
+	LIB_GETBUF(buf);
+	buf[0] = '\0';
+	for (i = 0; i < length; i++) {
+		snprintf(hex, sizeof(hex), "%02x", bufp[i]);
+		strlcat(buf, hex, LIB_BUFLENGTH);
+	}
 
-  LIB_GETBUF(buf);
-  for (i = 0; i < length; i++)
-    {
-      sprintf(buf+i*2, "%02x", bufp[i]);
-    }
-  return buf;
+	return buf;
 }
 
 #endif

==== ntpd/refclock_mx4200.c ====
2011-04-12 06:01:53+00:00, davehart at shiny.ad.hartbrothers.com +0 -2
  Remove ntp_sprintf.h workaround for pre-ANSI C sprintf().

--- 1.29/ntpd/refclock_mx4200.c	2011-02-20 15:22:40 -05:00
+++ 1.30/ntpd/refclock_mx4200.c	2011-04-12 02:01:53 -04:00
@@ -67,8 +67,6 @@
 # include <sys/ppsclock.h>
 #endif
 
-#include "ntp_sprintf.h"
-
 #ifndef HAVE_STRUCT_PPSCLOCKEV
 struct ppsclockev {
 # ifdef HAVE_STRUCT_TIMESPEC

==== ntpd/refclock_tpro.c ====
2011-04-12 06:01:53+00:00, davehart at shiny.ad.hartbrothers.com +1 -1
  comment only.

--- 1.12/ntpd/refclock_tpro.c	2011-02-20 15:22:41 -05:00
+++ 1.13/ntpd/refclock_tpro.c	2011-04-12 02:01:53 -04:00
@@ -160,7 +160,7 @@ tpro_poll(
 	 * proper format, we declare bad format and exit. Note: we
 	 * can't use the sec/usec conversion produced by the driver,
 	 * since the year may be suspect. All format error checking is
-	 * done by the sprintf() and sscanf() routines.
+	 * done by the snprintf() and sscanf() routines.
 	 *
 	 * Note that the refclockproc usec member has now become nsec.
 	 * We could either multiply the read-in usec value by 1000 or

==== ntpd/refclock_tt560.c ====
2011-04-12 06:01:53+00:00, davehart at shiny.ad.hartbrothers.com +6 -6
  sprintf() -> snprintf().

--- 1.2/ntpd/refclock_tt560.c	2007-01-06 00:56:59 -05:00
+++ 1.3/ntpd/refclock_tt560.c	2011-04-12 02:01:53 -04:00
@@ -76,14 +76,14 @@ tt560_start(
 {
 	register struct tt560unit *up;
 	struct refclockproc *pp;
-	char device[20];
-	int     fd;
-        caddr_t membase;
+	char	device[20];
+	int	fd;
+	caddr_t membase;
 
 	/*
 	 * Open TT560 device
 	 */
-	(void)sprintf(device, DEVICE, unit);
+	snprintf(device, sizeof(device), DEVICE, unit);
 	fd = open(device, O_RDWR);
 	if (fd == -1) {
 		msyslog(LOG_ERR, "tt560_start: open of %s: %m", device);
@@ -195,9 +195,9 @@ tt560_poll(
 	 * proper format, we declare bad format and exit. Note: we
 	 * can't use the sec/usec conversion produced by the driver,
 	 * since the year may be suspect. All format error checking is
-	 * done by the sprintf() and sscanf() routines.
+	 * done by the snprintf() and sscanf() routines.
 	 */
-	sprintf(pp->a_lastcode,
+	snprintf(pp->a_lastcode, sizeof(pp->a_lastcode),
 	    "%1x%1x%1x %1x%1x:%1x%1x:%1x%1x.%1x%1x%1x%1x%1x%1x %1x",
 	    tp->hun_day,  tp->tens_day,  tp->unit_day,
 	                  tp->tens_hour, tp->unit_hour,

==== ntpd/refclock_wwv.c ====
2011-04-12 06:01:53+00:00, davehart at shiny.ad.hartbrothers.com +2 -2
  sprintf() -> snprintf().

--- 1.76/ntpd/refclock_wwv.c	2011-04-09 02:20:31 -04:00
+++ 1.77/ntpd/refclock_wwv.c	2011-04-12 02:01:53 -04:00
@@ -1569,7 +1569,7 @@ wwv_endpoc(
 		}
 	}
 	if (pp->sloppyclockflag & CLK_FLAG4) {
-		sprintf(tbuf,
+		snprintf(tbuf, sizeof(tbuf),
 		    "wwv2 %04x %5.0f %5.1f %5d %4d %4d %4d %4.0f %7.2f",
 		    up->status, up->epomax, up->eposnr, mepoch,
 		    up->avgint, maxrun, mcount - zcount, dtemp,
@@ -2021,7 +2021,7 @@ wwv_rsec(
 	}
 	if ((pp->sloppyclockflag & CLK_FLAG4) && !(up->status &
 	    DSYNC)) {
-		sprintf(tbuf,
+		snprintf(tbuf, sizeof(tbuf),
 		    "wwv3 %2d %04x %3d %4d %5.0f %5.1f %5.0f %5.1f %5.0f",
 		    nsec, up->status, up->gain, up->yepoch, up->epomax,
 		    up->eposnr, up->datsig, up->datsnr, bit);

==== ntpdate/ntptimeset.c ====
2011-04-12 06:01:53+00:00, davehart at shiny.ad.hartbrothers.com +4 -29
  sprintf() -> msyslog().
  Remove replacement vsprintf(), ANSI C mandates it.

--- 1.14/ntpdate/ntptimeset.c	2011-03-05 17:35:33 -05:00
+++ 1.15/ntpdate/ntptimeset.c	2011-04-12 02:01:53 -04:00
@@ -4,7 +4,7 @@
  * GOAL:
  * The goal of ntptime is to set the current time on system startup
  * to the best possible time using the network very wisely. It is assumed
- * that after a resonable time has been sett then ntp daemon will
+ * that after a reasonable time has been set then ntp daemon will
  * maintain it.
  *
  * PROBLEM DOMAIN:
@@ -51,7 +51,7 @@
  * NOTE: Please do not have this program print out every minute some line,
  *       of output. If this happens and the environment is in trouble then
  *       many pages of paper on many different machines will be filled up.
- *       Save some tress in your lifetime.
+ *       Save some trees in your lifetime.
  * 
  * CONCLUSION:
  * The behavior of the program derived from these three issues should be
@@ -318,9 +318,6 @@ static	void	init_io		P((void));
 static	int	sendpkt		P((struct sockaddr_in *dest, struct pkt *pkt, int len));
 	void 	input_handler	P((l_fp *xts));
 static	void	printserver	P((register struct server *pp, FILE *fp));
-#if !defined(HAVE_VSPRINTF)
-int	vsprintf	P((char *str, const char *fmt, va_list ap));
-#endif
 
 #ifdef HAVE_SIGNALED_IO
 extern  void    wait_for_signal P((void));
@@ -592,10 +589,8 @@ ntptimesetmain(
 			exit(1);
 		}
 		if (!authistrusted(sys_authkey)) {
-			char buf[10];
-
-			(void) sprintf(buf, "%lu", (unsigned long)sys_authkey);
-			msyslog(LOG_ERR, "authentication key %s unknown", buf);
+			msyslog(LOG_ERR, "authentication key %lu unknown",
+				(u_long)sys_authkey);
 			exit(1);
 		}
 	}
@@ -2137,23 +2132,3 @@ printserver(
 	(void) fprintf(fp, "offset %s\n\n",
 			   lfptoa(&pp->offset, 6));
 }
-
-#if !defined(HAVE_VSPRINTF)
-int
-vsprintf(
-	char *str,
-	const char *fmt,
-	va_list ap
-	)
-{
-	FILE f;
-	int len;
-
-	f._flag = _IOWRT+_IOSTRG;
-	f._ptr = str;
-	f._cnt = 32767;
-	len = _doprnt(fmt, ap, &f);
-	*f._ptr = 0;
-	return (len);
-}
-#endif

==== ports/winnt/include/config.h ====
2011-04-12 06:01:53+00:00, davehart at shiny.ad.hartbrothers.com +4 -2
  Comment out #define vsnprintf _vsnprintf as l_stdlib.h #defines them now.

--- 1.95/ports/winnt/include/config.h	2011-04-11 17:24:11 -04:00
+++ 1.96/ports/winnt/include/config.h	2011-04-12 02:01:53 -04:00
@@ -262,8 +262,8 @@ typedef int socklen_t;
  * to other names
  */
 #define inline		__inline
-#define vsnprintf	_vsnprintf
-#define snprintf	_snprintf
+/* #define vsnprintf	_vsnprintf */
+/* #define snprintf	_snprintf */
 #define stricmp		_stricmp
 #define strcasecmp	_stricmp
 #define isascii		__isascii
@@ -390,6 +390,8 @@ typedef __int32 int32_t;	/* define a typ
 
 #define HW_WANT_RPL_VSNPRINTF		1
 #define HW_WANT_RPL_SNPRINTF		1
+#define HAVE_VSNPRINTF			1
+#define HAVE_SNPRINTF			1
 
 typedef char *caddr_t;
 

==== ports/winnt/libntp/syslog.c ====
2011-04-12 06:01:54+00:00, davehart at shiny.ad.hartbrothers.com +1 -1
  vsprintf() -> vsnprintf().

--- 1.9/ports/winnt/libntp/syslog.c	2011-04-05 03:05:47 -04:00
+++ 1.10/ports/winnt/libntp/syslog.c	2011-04-12 02:01:54 -04:00
@@ -102,7 +102,7 @@ syslog(int level, const char *fmt, ...) 
 	str[0] = buf;
 
 	va_start(ap, fmt);
-	vsprintf(buf, fmt, ap);
+	vsnprintf(buf, sizeof(buf), fmt, ap);
 	va_end(ap);
 
 	/* Make sure that the channel is open to write the event */

==== ports/winnt/ntpd/hopf_PCI_io.c ====
2011-04-12 06:01:54+00:00, davehart at shiny.ad.hartbrothers.com +2 -0
  include ntp_stdlib.h for snprintf define.

--- 1.8/ports/winnt/ntpd/hopf_PCI_io.c	2011-04-11 17:24:11 -04:00
+++ 1.9/ports/winnt/ntpd/hopf_PCI_io.c	2011-04-12 02:01:54 -04:00
@@ -21,6 +21,8 @@
 #include <stdlib.h>
 #include <stddef.h>
 #include <winioctl.h>
+
+#include "ntp_stdlib.h"
 #include "hopf_PCI_io.h"
 
 

==== ports/winnt/vs2003/libntp.vcproj ====
2011-04-12 06:01:54+00:00, davehart at shiny.ad.hartbrothers.com +0 -3
  Remove ntp_sprintf.h workaround for pre-ANSI C sprintf().

--- 1.21/ports/winnt/vs2003/libntp.vcproj	2011-04-11 17:24:11 -04:00
+++ 1.22/ports/winnt/vs2003/libntp.vcproj	2011-04-12 02:01:54 -04:00
@@ -1576,9 +1576,6 @@
 				RelativePath="..\..\..\include\ntp_select.h">
 			</File>
 			<File
-				RelativePath="..\..\..\include\ntp_sprintf.h">
-			</File>
-			<File
 				RelativePath="..\..\..\include\ntp_stdlib.h">
 			</File>
 			<File

==== ports/winnt/vs2005/libntp.vcproj ====
2011-04-12 06:01:54+00:00, davehart at shiny.ad.hartbrothers.com +0 -4
  Remove ntp_sprintf.h workaround for pre-ANSI C sprintf().

--- 1.19/ports/winnt/vs2005/libntp.vcproj	2011-04-11 17:24:11 -04:00
+++ 1.20/ports/winnt/vs2005/libntp.vcproj	2011-04-12 02:01:54 -04:00
@@ -766,10 +766,6 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\include\ntp_sprintf.h"
-				>
-			</File>
-			<File
 				RelativePath="..\..\..\include\ntp_stdlib.h"
 				>
 			</File>

==== ports/winnt/vs2008/libntp/libntp.vcproj ====
2011-04-12 06:01:54+00:00, davehart at shiny.ad.hartbrothers.com +0 -4
  Remove ntp_sprintf.h workaround for pre-ANSI C sprintf().

--- 1.42/ports/winnt/vs2008/libntp/libntp.vcproj	2011-04-11 17:24:11 -04:00
+++ 1.43/ports/winnt/vs2008/libntp/libntp.vcproj	2011-04-12 02:01:54 -04:00
@@ -821,10 +821,6 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\..\include\ntp_sprintf.h"
-				>
-			</File>
-			<File
 				RelativePath="..\..\..\..\include\ntp_stdlib.h"
 				>
 			</File>

==== ports/winnt/vs2008/ntpd/ntpd.vcproj ====
2011-04-12 06:01:54+00:00, davehart at shiny.ad.hartbrothers.com +4 -0
  add refclock_tt560.c

--- 1.39/ports/winnt/vs2008/ntpd/ntpd.vcproj	2011-03-05 17:35:34 -05:00
+++ 1.40/ports/winnt/vs2008/ntpd/ntpd.vcproj	2011-04-12 02:01:54 -04:00
@@ -915,6 +915,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\..\..\ntpd\refclock_tt560.c"
+				>
+			</File>
+			<File
 				RelativePath="..\..\..\..\ntpd\refclock_ulink.c"
 				>
 			</File>

==== util/audio-pcm.c ====
2011-04-12 06:01:54+00:00, davehart at shiny.ad.hartbrothers.com +2 -2
  sprintf() -> snprintf().

--- 1.1/util/audio-pcm.c	2002-02-24 02:21:11 -05:00
+++ 1.2/util/audio-pcm.c	2011-04-12 02:01:54 -04:00
@@ -94,8 +94,8 @@ main( )
 	char *actl = ac_dev;
 	int devmask = 0, recmask = 0, recsrc = 0;
 
-	(void)sprintf(ai_dev, AI_DEV, unit);
-	(void)sprintf(ac_dev, AC_DEV, unit);
+	snprintf(ai_dev, sizeof(ai_dev), AI_DEV, unit);
+	snprintf(ac_dev, sizeof(ac_dev), AC_DEV, unit);
 
 	/*
 	 * Open audio device. Do not complain if not there.

==== util/sht.c ====
2011-04-12 06:01:55+00:00, davehart at shiny.ad.hartbrothers.com +1 -1
  sprintf() -> snprintf().

--- 1.3/util/sht.c	2003-05-09 21:46:00 -04:00
+++ 1.4/util/sht.c	2011-04-12 02:01:55 -04:00
@@ -62,7 +62,7 @@ getShmTime (
 #else
 	char buf[10];
 	LPSECURITY_ATTRIBUTES psec=0;
-	sprintf (buf,"NTP%d",unit);
+	snprintf (buf, sizeof(buf), "NTP%d", unit);
 	SECURITY_DESCRIPTOR sd;
 	SECURITY_ATTRIBUTES sa;
 	HANDLE shmid;

==== util/tg.c ====
2011-04-12 06:01:55+00:00, davehart at shiny.ad.hartbrothers.com +8 -7
  sprintf() -> snprintf().

--- 1.4/util/tg.c	2011-04-05 03:05:48 -04:00
+++ 1.5/util/tg.c	2011-04-12 02:01:55 -04:00
@@ -374,8 +374,8 @@ main(
 	case WWV:
 		printf("year %d day %d time %02d:%02d:%02d tone %d\n",
 		    year, day, hour, minute, second, tone);
-		sprintf(code, "%01d%03d%02d%02d%01d", year / 10, day,
-		    hour, minute, year % 10);
+		snprintf(code, sizeof(code), "%01d%03d%02d%02d%01d",
+		    year / 10, day, hour, minute, year % 10);
 		printf("%s\n", code);
 		ptr = 8;
 		for (i = 0; i <= second; i++) {
@@ -431,16 +431,17 @@ main(
 				year++;
 			}
 			if (encode == WWV) {
-				sprintf(code, "%01d%03d%02d%02d%01d",
-				    year / 10, day, hour, minute, year %
-				    10);
+				snprintf(code, sizeof(code),
+				    "%01d%03d%02d%02d%01d", year / 10,
+				    day, hour, minute, year % 10);
 				printf("\n%s\n", code);
 				ptr = 8;
 			}
 		}
 		if (encode == IRIG) {
-			sprintf(code, "%04x%04d%06d%02d%02d%02d", 0,
-			    year, day, hour, minute, second);
+			snprintf(code, sizeof(code),
+			    "%04x%04d%06d%02d%02d%02d", 0, year, day,
+			    hour, minute, second);
 			printf("%s\n", code);
 			ptr = 19;
 		}

==== util/tg2.c ====
2011-04-12 06:01:55+00:00, davehart at shiny.ad.hartbrothers.com +28 -19
  sprintf() -> snprintf().

--- 1.4/util/tg2.c	2011-04-05 03:05:48 -04:00
+++ 1.5/util/tg2.c	2011-04-12 02:01:55 -04:00
@@ -1098,7 +1098,7 @@ main(
 		printf("WWV time signal, starting point:\n");
 		printf(" Year = %02d, Day of year = %03d, Time = %02d:%02d:%02d, Minute tone = %d Hz, Hour tone = %d Hz.\n",
 		    Year, DayOfYear, Hour, Minute, Second, tone, HourTone);
-		sprintf(code, "%01d%03d%02d%02d%01d",
+		snprintf(code, sizeof(code), "%01d%03d%02d%02d%01d",
 		    Year / 10, DayOfYear, Hour, Minute, Year % 10);
 		if  (Verbose)
 			{
@@ -1371,8 +1371,9 @@ main(
 				Year++;
 			}
 			if (encode == WWV) {
-				sprintf(code, "%01d%03d%02d%02d%01d",
-				    Year / 10, DayOfYear, Hour, Minute, Year % 10);
+				snprintf(code, sizeof(code),
+				    "%01d%03d%02d%02d%01d", Year / 10,
+				    DayOfYear, Hour, Minute, Year % 10);
 				if  (Verbose)
 				    printf("\n Year = %2.2d, Day of year = %3d, Time = %2.2d:%2.2d:%2.2d, Code = %s", 
 						Year, DayOfYear, Hour, Minute, Second, code);
@@ -1441,17 +1442,20 @@ main(
 				ControlFunctions = 0;
 
 			/*
-			                   YearDay HourMin Sec
-			sprintf(code, "%04x%04d%06d%02d%02d%02d",
+						      YearDay HourMin Sec
+			snprintf(code, sizeof(code), "%04x%04d%06d%02d%02d%02d",
 				0, Year, DayOfYear, Hour, Minute, Second);
 			*/
 			if  (IrigIncludeYear) {
-				sprintf(ParityString, "%04X%02d%04d%02d%02d%02d",
-					ControlFunctions & 0x7FFF, Year, DayOfYear, Hour, Minute, Second);
-			}
-			else {
-				sprintf(ParityString, "%04X%02d%04d%02d%02d%02d",
-					ControlFunctions & 0x7FFF,    0, DayOfYear, Hour, Minute, Second);
+				snprintf(ParityString, sizeof(ParityString),
+				    "%04X%02d%04d%02d%02d%02d",
+				    ControlFunctions & 0x7FFF, Year,
+				    DayOfYear, Hour, Minute, Second);
+			} else {
+				snprintf(ParityString, sizeof(ParityString),
+				    "%04X%02d%04d%02d%02d%02d",
+				    ControlFunctions & 0x7FFF,
+				    0, DayOfYear, Hour, Minute, Second);
 			}
 
 			if  (IrigIncludeIeee)
@@ -1501,14 +1505,19 @@ main(
 			ControlFunctions |= ((ParityValue & 0x01) << 14);
 
 			if  (IrigIncludeYear) {
-				/*                 YearDay HourMin Sec*/
-				sprintf(code, "%05X%05X%02d%04d%02d%02d%02d",
-					StraightBinarySeconds, ControlFunctions, Year, DayOfYear, Hour, Minute, Second);
-			}
-			else {
-				/*                 YearDay HourMin Sec*/
-				sprintf(code, "%05X%05X%02d%04d%02d%02d%02d",
-					StraightBinarySeconds, ControlFunctions,    0, DayOfYear, Hour, Minute, Second);
+				snprintf(code, sizeof(code),
+				    /* YearDay HourMin Sec */
+				    "%05X%05X%02d%04d%02d%02d%02d",
+				    StraightBinarySeconds,
+				    ControlFunctions, Year, DayOfYear,
+				    Hour, Minute, Second);
+			} else {
+				snprintf(code, sizeof(code),
+				    /* YearDay HourMin Sec */
+				    "%05X%05X%02d%04d%02d%02d%02d",
+				    StraightBinarySeconds,
+				    ControlFunctions, 0, DayOfYear,
+				    Hour, Minute, Second);
 			}
 
 			if  (Debug)

#### ChangeSet ####
2011-04-11 21:24:15+00:00, davehart at shiny.ad.hartbrothers.com
  Remove never-used, incomplete ports/winnt/ntpd/refclock_trimbledc.[ch]
  On systems without C99-compliant (v)snprintf(), use C99-snprintf
    replacements.  (http://www.jhweiss.de/software/snprintf.html)

==== ChangeLog ====
2011-04-11 21:24:09+00:00, davehart at shiny.ad.hartbrothers.com +3 -0
  Remove never-used, incomplete ports/winnt/ntpd/refclock_trimbledc.[ch]
  On systems without C99-compliant (v)snprintf(), use C99-snprintf
    replacements.  (http://www.jhweiss.de/software/snprintf.html)

--- 1.839/ChangeLog	2011-04-09 03:09:09 -04:00
+++ 1.839.1.1/ChangeLog	2011-04-11 17:24:09 -04:00
@@ -1,3 +1,6 @@
+* Remove never-used, incomplete ports/winnt/ntpd/refclock_trimbledc.[ch]
+* On systems without C99-compliant (v)snprintf(), use C99-snprintf
+  replacements (http://www.jhweiss.de/software/snprintf.html)
 (4.2.7p148) 2011/04/09 Released by Harlan Stenn <stenn at ntp.org>
 * Use _mkgmtime() as timegm() in the Windows port, rather than
   libntp/mktime.c's timegm().  Fixed [Bug 1875] on Windows using the old

==== configure.ac ====
2011-04-11 21:24:09+00:00, davehart at shiny.ad.hartbrothers.com +2 -2
  On systems without C99-compliant (v)snprintf(), use C99-snprintf
    replacements.  (http://www.jhweiss.de/software/snprintf.html)

--- 1.521/configure.ac	2011-03-25 22:03:33 -04:00
+++ 1.521.1.1/configure.ac	2011-04-11 17:24:09 -04:00
@@ -800,7 +800,7 @@ case "$host" in
  *) AC_CHECK_FUNCS([sched_setscheduler])
     ;;
 esac
-AC_CHECK_FUNCS([setlinebuf setpgid setpriority setsid setvbuf snprintf])
+AC_CHECK_FUNCS([setlinebuf setpgid setpriority setsid setvbuf])
 AC_CHECK_FUNCS([strdup strerror setrlimit strchr])
 case "$host" in
  *-*-aix[[456]]*)
@@ -834,7 +834,7 @@ esac
 AC_DEFINE_UNQUOTED([WORKER_CHILD_EXIT], [$ntp_worker_child_exit],
 		   [routine worker child proc uses to exit.])
 
-AC_CHECK_FUNCS([umask uname updwtmp updwtmpx vsnprintf vsprintf])
+AC_CHECK_FUNCS([umask uname updwtmp updwtmpx])
 
 ###
 

==== include/l_stdlib.h ====
2011-04-11 21:24:09+00:00, davehart at shiny.ad.hartbrothers.com +6 -6
  On systems without C99-compliant (v)snprintf(), use C99-snprintf
    replacements.  (http://www.jhweiss.de/software/snprintf.html)

--- 1.18/include/l_stdlib.h	2010-01-27 13:45:22 -05:00
+++ 1.19/include/l_stdlib.h	2011-04-11 17:24:09 -04:00
@@ -131,14 +131,14 @@ struct sigvec;
 extern	int	sigvec		(int, struct sigvec *, struct sigvec *);
 #endif
 
-#ifndef HAVE_SNPRINTF
-/* PRINTFLIKE3 */
-extern	int	snprintf	(char *, size_t, const char *, ...);
+#if HW_WANT_RPL_VSNPRINTF
+#define vsnprintf rpl_vsnprintf
+int rpl_vsnprintf(char *, size_t, const char *, va_list);
 #endif
 
-/* HMS: does this need further protection? */
-#ifndef HAVE_VSNPRINTF
-extern	int	vsnprintf	(char *, size_t, const char *, va_list);
+#if HW_WANT_RPL_SNPRINTF
+#define snprintf rpl_snprintf
+int rpl_snprintf(char *, size_t, const char *, ...);
 #endif
 
 #ifdef DECL_STDIO_0

==== include/ntp_machine.h ====
2011-04-11 21:24:10+00:00, davehart at shiny.ad.hartbrothers.com +0 -1
  Remove unused MAXHOSTNAMELEN.

--- 1.34/include/ntp_machine.h	2011-03-25 22:03:33 -04:00
+++ 1.35/include/ntp_machine.h	2011-04-11 17:24:10 -04:00
@@ -255,7 +255,6 @@ struct servent *getservbyname (char *nam
 # define IN_CLASSD(i)	((((long)(i))&0xf0000000)==0xe0000000)
 # define IN_MULTICAST IN_CLASSD
 # define ITIMER_REAL 0
-# define MAXHOSTNAMELEN 64
 
 /* standard structures missing from MPE include files */
 

==== libntp/ntp_intres.c ====
2011-04-11 21:24:10+00:00, davehart at shiny.ad.hartbrothers.com +1 -1
  Remove unused MAXHOSTNAMELEN.

--- 1.94/libntp/ntp_intres.c	2011-03-05 17:35:33 -05:00
+++ 1.95/libntp/ntp_intres.c	2011-04-11 17:24:10 -04:00
@@ -69,7 +69,7 @@
 #include <arpa/inet.h>
 /**/
 #ifdef HAVE_SYS_PARAM_H
-# include <sys/param.h>		/* MAXHOSTNAMELEN (often) */
+# include <sys/param.h>
 #endif
 
 #if !defined(HAVE_RES_INIT) && defined(HAVE___RES_INIT)

==== libntp/snprintf.c ====
2011-04-11 21:24:10+00:00, davehart at shiny.ad.hartbrothers.com +2115 -44
  On systems without C99-compliant (v)snprintf(), use C99-snprintf
    replacements.  (http://www.jhweiss.de/software/snprintf.html)

--- 1.8/libntp/snprintf.c	2003-07-27 02:42:38 -04:00
+++ 1.9/libntp/snprintf.c	2011-04-11 17:24:10 -04:00
@@ -1,62 +1,2133 @@
+/*
+ * Modified by Dave Hart for integration into NTP 4.2.7 <hart at ntp.org>
+ *
+ * Changed in a backwards-incompatible way to separate HAVE_SNPRINTF
+ * from HW_WANT_RPL_SNPRINTF, etc. for each of the four replaced
+ * functions.
+ *
+ * Changed to honor hw_force_rpl_snprintf=yes, etc.  This is used by NTP
+ * to test rpl_snprintf() and rpl_vsnprintf() on platforms which provide
+ * C99-compliant implementations.
+ */
+
+/* $Id: snprintf.c,v 1.9 2008/01/20 14:02:00 holger Exp $ */
+
+/*
+ * Copyright (c) 1995 Patrick Powell.
+ *
+ * This code is based on code written by Patrick Powell <papowell at astart.com>.
+ * It may be used for any purpose as long as this notice remains intact on all
+ * source code distributions.
+ */
+
+/*
+ * Copyright (c) 2008 Holger Weiss.
+ *
+ * This version of the code is maintained by Holger Weiss <holger at jhweiss.de>.
+ * My changes to the code may freely be used, modified and/or redistributed for
+ * any purpose.  It would be nice if additions and fixes to this file (including
+ * trivial code cleanups) would be sent back in order to let me include them in
+ * the version available at <http://www.jhweiss.de/software/snprintf.html>.
+ * However, this is not a requirement for using or redistributing (possibly
+ * modified) versions of this file, nor is leaving this notice intact mandatory.
+ */
+
+/*
+ * History
+ *
+ * 2008-01-20 Holger Weiss <holger at jhweiss.de> for C99-snprintf 1.1:
+ *
+ * 	Fixed the detection of infinite floating point values on IRIX (and
+ * 	possibly other systems) and applied another few minor cleanups.
+ *
+ * 2008-01-06 Holger Weiss <holger at jhweiss.de> for C99-snprintf 1.0:
+ *
+ * 	Added a lot of new features, fixed many bugs, and incorporated various
+ * 	improvements done by Andrew Tridgell <tridge at samba.org>, Russ Allbery
+ * 	<rra at stanford.edu>, Hrvoje Niksic <hniksic at xemacs.org>, Damien Miller
+ * 	<djm at mindrot.org>, and others for the Samba, INN, Wget, and OpenSSH
+ * 	projects.  The additions include: support the "e", "E", "g", "G", and
+ * 	"F" conversion specifiers (and use conversion style "f" or "F" for the
+ * 	still unsupported "a" and "A" specifiers); support the "hh", "ll", "j",
+ * 	"t", and "z" length modifiers; support the "#" flag and the (non-C99)
+ * 	"'" flag; use localeconv(3) (if available) to get both the current
+ * 	locale's decimal point character and the separator between groups of
+ * 	digits; fix the handling of various corner cases of field width and
+ * 	precision specifications; fix various floating point conversion bugs;
+ * 	handle infinite and NaN floating point values; don't attempt to write to
+ * 	the output buffer (which may be NULL) if a size of zero was specified;
+ * 	check for integer overflow of the field width, precision, and return
+ * 	values and during the floating point conversion; use the OUTCHAR() macro
+ * 	instead of a function for better performance; provide asprintf(3) and
+ * 	vasprintf(3) functions; add new test cases.  The replacement functions
+ * 	have been renamed to use an "rpl_" prefix, the function calls in the
+ * 	main project (and in this file) must be redefined accordingly for each
+ * 	replacement function which is needed (by using Autoconf or other means).
+ * 	Various other minor improvements have been applied and the coding style
+ * 	was cleaned up for consistency.
+ *
+ * 2007-07-23 Holger Weiss <holger at jhweiss.de> for Mutt 1.5.13:
+ *
+ * 	C99 compliant snprintf(3) and vsnprintf(3) functions return the number
+ * 	of characters that would have been written to a sufficiently sized
+ * 	buffer (excluding the '\0').  The original code simply returned the
+ * 	length of the resulting output string, so that's been fixed.
+ *
+ * 1998-03-05 Michael Elkins <me at mutt.org> for Mutt 0.90.8:
+ *
+ * 	The original code assumed that both snprintf(3) and vsnprintf(3) were
+ * 	missing.  Some systems only have snprintf(3) but not vsnprintf(3), so
+ * 	the code is now broken down under HAVE_SNPRINTF and HAVE_VSNPRINTF.
+ *
+ * 1998-01-27 Thomas Roessler <roessler at does-not-exist.org> for Mutt 0.89i:
+ *
+ * 	The PGP code was using unsigned hexadecimal formats.  Unfortunately,
+ * 	unsigned formats simply didn't work.
+ *
+ * 1997-10-22 Brandon Long <blong at fiction.net> for Mutt 0.87.1:
+ *
+ * 	Ok, added some minimal floating point support, which means this probably
+ * 	requires libm on most operating systems.  Don't yet support the exponent
+ * 	(e,E) and sigfig (g,G).  Also, fmtint() was pretty badly broken, it just
+ * 	wasn't being exercised in ways which showed it, so that's been fixed.
+ * 	Also, formatted the code to Mutt conventions, and removed dead code left
+ * 	over from the original.  Also, there is now a builtin-test, run with:
+ * 	gcc -DTEST_SNPRINTF -o snprintf snprintf.c -lm && ./snprintf
+ *
+ * 2996-09-15 Brandon Long <blong at fiction.net> for Mutt 0.43:
+ *
+ * 	This was ugly.  It is still ugly.  I opted out of floating point
+ * 	numbers, but the formatter understands just about everything from the
+ * 	normal C string format, at least as far as I can tell from the Solaris
+ * 	2.5 printf(3S) man page.
+ */
+
+/*
+ * ToDo
+ *
+ * - Add wide character support.
+ * - Add support for "%a" and "%A" conversions.
+ * - Create test routines which predefine the expected results.  Our test cases
+ *   usually expose bugs in system implementations rather than in ours :-)
+ */
+
+/*
+ * Usage
+ *
+ * 1) The following preprocessor macros should be defined to 1 if the feature or
+ *    file in question is available on the target system (by using Autoconf or
+ *    other means), though basic functionality should be available as long as
+ *    HAVE_STDARG_H and HAVE_STDLIB_H are defined correctly:
+ *
+ *	HW_WANT_RPL_VSNPRINTF
+ *	HW_WANT_RPL_SNPRINTF
+ *	HW_WANT_RPL_VASPRINTF
+ *	HW_WANT_RPL_ASPRINTF
+ *	HAVE_VSNPRINTF
+ *	HAVE_SNPRINTF
+ *	HAVE_VASPRINTF
+ *	HAVE_ASPRINTF
+ *	HAVE_STDARG_H
+ *	HAVE_STDDEF_H
+ *	HAVE_STDINT_H
+ *	HAVE_STDLIB_H
+ *	HAVE_INTTYPES_H
+ *	HAVE_LOCALE_H
+ *	HAVE_LOCALECONV
+ *	HAVE_LCONV_DECIMAL_POINT
+ *	HAVE_LCONV_THOUSANDS_SEP
+ *	HAVE_LONG_DOUBLE
+ *	HAVE_LONG_LONG_INT
+ *	HAVE_UNSIGNED_LONG_LONG_INT
+ *	HAVE_INTMAX_T
+ *	HAVE_UINTMAX_T
+ *	HAVE_UINTPTR_T
+ *	HAVE_PTRDIFF_T
+ *	HAVE_VA_COPY
+ *	HAVE___VA_COPY
+ *
+ * 2) The calls to the functions which should be replaced must be redefined
+ *    throughout the project files (by using Autoconf or other means):
+ *
+ *	#if HW_WANT_RPL_VSNPRINTF
+ *	#define vsnprintf rpl_vsnprintf
+ *	#endif
+ *	#if HW_WANT_RPL_SNPRINTF
+ *	#define snprintf rpl_snprintf
+ *	#endif
+ *	#if HW_WANT_RPL_VASPRINTF
+ *	#define vasprintf rpl_vasprintf
+ *	#endif
+ *	#if HW_WANT_RPL_ASPRINTF
+ *	#define asprintf rpl_asprintf
+ *	#endif
+ *
+ * 3) The required replacement functions should be declared in some header file
+ *    included throughout the project files:
+ *
+ *	#if HAVE_CONFIG_H
+ *	#include <config.h>
+ *	#endif
+ *	#if HAVE_STDARG_H
+ *	#include <stdarg.h>
+ *	#if HW_WANT_RPL_VSNPRINTF
+ *	int rpl_vsnprintf(char *, size_t, const char *, va_list);
+ *	#endif
+ *	#if HW_WANT_RPL_SNPRINTF
+ *	int rpl_snprintf(char *, size_t, const char *, ...);
+ *	#endif
+ *	#if HW_WANT_RPL_VASPRINTF
+ *	int rpl_vasprintf(char **, const char *, va_list);
+ *	#endif
+ *	#if HW_WANT_RPL_ASPRINTF
+ *	int rpl_asprintf(char **, const char *, ...);
+ *	#endif
+ *	#endif
+ *
+ * Autoconf macros for handling step 1 and step 2 are available at
+ * <http://www.jhweiss.de/software/snprintf.html>.
+ */
+
+#if HAVE_CONFIG_H
 #include <config.h>
+#endif	/* HAVE_CONFIG_H */
 
-#if !HAVE_SNPRINTF
-#include <sys/types.h>
+#if TEST_SNPRINTF
+#include <math.h>	/* For pow(3), NAN, and INFINITY. */
+#include <string.h>	/* For strcmp(3). */
+#if defined(__NetBSD__) || \
+    defined(__FreeBSD__) || \
+    defined(__OpenBSD__) || \
+    defined(__NeXT__) || \
+    defined(__bsd__)
+#define OS_BSD 1
+#elif defined(sgi) || defined(__sgi)
+#ifndef __c99
+#define __c99	/* Force C99 mode to get <stdint.h> included on IRIX 6.5.30. */
+#endif	/* !defined(__c99) */
+#define OS_IRIX 1
+#define OS_SYSV 1
+#elif defined(__svr4__)
+#define OS_SYSV 1
+#elif defined(__linux__)
+#define OS_LINUX 1
+#endif	/* defined(__NetBSD__) || defined(__FreeBSD__) || [...] */
+#if HAVE_CONFIG_H	/* Undefine definitions possibly done in config.h. */
+#ifdef HAVE_SNPRINTF
+#undef HAVE_SNPRINTF
+#endif	/* defined(HAVE_SNPRINTF) */
+#ifdef HAVE_VSNPRINTF
+#undef HAVE_VSNPRINTF
+#endif	/* defined(HAVE_VSNPRINTF) */
+#ifdef HAVE_ASPRINTF
+#undef HAVE_ASPRINTF
+#endif	/* defined(HAVE_ASPRINTF) */
+#ifdef HAVE_VASPRINTF
+#undef HAVE_VASPRINTF
+#endif	/* defined(HAVE_VASPRINTF) */
+#ifdef snprintf
+#undef snprintf
+#endif	/* defined(snprintf) */
+#ifdef vsnprintf
+#undef vsnprintf
+#endif	/* defined(vsnprintf) */
+#ifdef asprintf
+#undef asprintf
+#endif	/* defined(asprintf) */
+#ifdef vasprintf
+#undef vasprintf
+#endif	/* defined(vasprintf) */
+#else	/* By default, we assume a modern system for testing. */
+#ifndef HAVE_STDARG_H
+#define HAVE_STDARG_H 1
+#endif	/* HAVE_STDARG_H */
+#ifndef HAVE_STDDEF_H
+#define HAVE_STDDEF_H 1
+#endif	/* HAVE_STDDEF_H */
+#ifndef HAVE_STDINT_H
+#define HAVE_STDINT_H 1
+#endif	/* HAVE_STDINT_H */
+#ifndef HAVE_STDLIB_H
+#define HAVE_STDLIB_H 1
+#endif	/* HAVE_STDLIB_H */
+#ifndef HAVE_INTTYPES_H
+#define HAVE_INTTYPES_H 1
+#endif	/* HAVE_INTTYPES_H */
+#ifndef HAVE_LOCALE_H
+#define HAVE_LOCALE_H 1
+#endif	/* HAVE_LOCALE_H */
+#ifndef HAVE_LOCALECONV
+#define HAVE_LOCALECONV 1
+#endif	/* !defined(HAVE_LOCALECONV) */
+#ifndef HAVE_LCONV_DECIMAL_POINT
+#define HAVE_LCONV_DECIMAL_POINT 1
+#endif	/* HAVE_LCONV_DECIMAL_POINT */
+#ifndef HAVE_LCONV_THOUSANDS_SEP
+#define HAVE_LCONV_THOUSANDS_SEP 1
+#endif	/* HAVE_LCONV_THOUSANDS_SEP */
+#ifndef HAVE_LONG_DOUBLE
+#define HAVE_LONG_DOUBLE 1
+#endif	/* !defined(HAVE_LONG_DOUBLE) */
+#ifndef HAVE_LONG_LONG_INT
+#define HAVE_LONG_LONG_INT 1
+#endif	/* !defined(HAVE_LONG_LONG_INT) */
+#ifndef HAVE_UNSIGNED_LONG_LONG_INT
+#define HAVE_UNSIGNED_LONG_LONG_INT 1
+#endif	/* !defined(HAVE_UNSIGNED_LONG_LONG_INT) */
+#ifndef HAVE_INTMAX_T
+#define HAVE_INTMAX_T 1
+#endif	/* !defined(HAVE_INTMAX_T) */
+#ifndef HAVE_UINTMAX_T
+#define HAVE_UINTMAX_T 1
+#endif	/* !defined(HAVE_UINTMAX_T) */
+#ifndef HAVE_UINTPTR_T
+#define HAVE_UINTPTR_T 1
+#endif	/* !defined(HAVE_UINTPTR_T) */
+#ifndef HAVE_PTRDIFF_T
+#define HAVE_PTRDIFF_T 1
+#endif	/* !defined(HAVE_PTRDIFF_T) */
+#ifndef HAVE_VA_COPY
+#define HAVE_VA_COPY 1
+#endif	/* !defined(HAVE_VA_COPY) */
+#ifndef HAVE___VA_COPY
+#define HAVE___VA_COPY 1
+#endif	/* !defined(HAVE___VA_COPY) */
+#endif	/* HAVE_CONFIG_H */
+#define snprintf rpl_snprintf
+#define vsnprintf rpl_vsnprintf
+#define asprintf rpl_asprintf
+#define vasprintf rpl_vasprintf
+#endif	/* TEST_SNPRINTF */
 
-#ifdef __STDC__
+#if HW_WANT_RPL_SNPRINTF || HW_WANT_RPL_VSNPRINTF || HW_WANT_RPL_ASPRINTF || HW_WANT_RPL_VASPRINTF
+#include <stdio.h>	/* For NULL, size_t, vsnprintf(3), and vasprintf(3). */
+#ifdef VA_START
+#undef VA_START
+#endif	/* defined(VA_START) */
+#ifdef VA_SHIFT
+#undef VA_SHIFT
+#endif	/* defined(VA_SHIFT) */
+#if HAVE_STDARG_H
 #include <stdarg.h>
-#else
+#define VA_START(ap, last) va_start(ap, last)
+#define VA_SHIFT(ap, value, type) /* No-op for ANSI C. */
+#else	/* Assume <varargs.h> is available. */
 #include <varargs.h>
-#endif
-#include <stdio.h>
+#define VA_START(ap, last) va_start(ap)	/* "last" is ignored. */
+#define VA_SHIFT(ap, value, type) value = va_arg(ap, type)
+#endif	/* HAVE_STDARG_H */
+
+#if HW_WANT_RPL_VASPRINTF
+#if HAVE_STDLIB_H
+#include <stdlib.h>	/* For malloc(3). */
+#endif	/* HAVE_STDLIB_H */
+#ifdef VA_COPY
+#undef VA_COPY
+#endif	/* defined(VA_COPY) */
+#ifdef VA_END_COPY
+#undef VA_END_COPY
+#endif	/* defined(VA_END_COPY) */
+#if HAVE_VA_COPY
+#define VA_COPY(dest, src) va_copy(dest, src)
+#define VA_END_COPY(ap) va_end(ap)
+#elif HAVE___VA_COPY
+#define VA_COPY(dest, src) __va_copy(dest, src)
+#define VA_END_COPY(ap) va_end(ap)
+#else
+#define VA_COPY(dest, src) (void)mymemcpy(&dest, &src, sizeof(va_list))
+#define VA_END_COPY(ap) /* No-op. */
+#define NEED_MYMEMCPY 1
+static void *mymemcpy(void *, void *, size_t);
+#endif	/* HAVE_VA_COPY */
+#endif	/* HW_WANT_RPL_VASPRINTF */
 
-#include "l_stdlib.h"
+#if HW_WANT_RPL_VSNPRINTF
+#include <errno.h>	/* For ERANGE and errno. */
+#include <limits.h>	/* For *_MAX. */
+#if HAVE_INTTYPES_H
+#include <inttypes.h>	/* For intmax_t (if not defined in <stdint.h>). */
+#endif	/* HAVE_INTTYPES_H */
+#if HAVE_LOCALE_H
+#include <locale.h>	/* For localeconv(3). */
+#endif	/* HAVE_LOCALE_H */
+#if HAVE_STDDEF_H
+#include <stddef.h>	/* For ptrdiff_t. */
+#endif	/* HAVE_STDDEF_H */
+#if HAVE_STDINT_H
+#include <stdint.h>	/* For intmax_t. */
+#endif	/* HAVE_STDINT_H */
 
-#ifdef __STDC__
-int snprintf(char *str, size_t n, const char *fmt, ...)
+/* Support for unsigned long long int.  We may also need ULLONG_MAX. */
+#ifndef ULONG_MAX	/* We may need ULONG_MAX as a fallback. */
+#ifdef UINT_MAX
+#define ULONG_MAX UINT_MAX
 #else
-int snprintf(str, n, fmt, va_alist)
-	char *str;
-	size_t n;
-	const char *fmt;
-	va_dcl
-#endif
+#define ULONG_MAX INT_MAX
+#endif	/* defined(UINT_MAX) */
+#endif	/* !defined(ULONG_MAX) */
+#ifdef ULLONG
+#undef ULLONG
+#endif	/* defined(ULLONG) */
+#if HAVE_UNSIGNED_LONG_LONG_INT
+#define ULLONG unsigned long long int
+#ifndef ULLONG_MAX
+#define ULLONG_MAX ULONG_MAX
+#endif	/* !defined(ULLONG_MAX) */
+#else
+#define ULLONG unsigned long int
+#ifdef ULLONG_MAX
+#undef ULLONG_MAX
+#endif	/* defined(ULLONG_MAX) */
+#define ULLONG_MAX ULONG_MAX
+#endif	/* HAVE_LONG_LONG_INT */
+
+/* Support for uintmax_t.  We also need UINTMAX_MAX. */
+#ifdef UINTMAX_T
+#undef UINTMAX_T
+#endif	/* defined(UINTMAX_T) */
+#if HAVE_UINTMAX_T || defined(uintmax_t)
+#define UINTMAX_T uintmax_t
+#ifndef UINTMAX_MAX
+#define UINTMAX_MAX ULLONG_MAX
+#endif	/* !defined(UINTMAX_MAX) */
+#else
+#define UINTMAX_T ULLONG
+#ifdef UINTMAX_MAX
+#undef UINTMAX_MAX
+#endif	/* defined(UINTMAX_MAX) */
+#define UINTMAX_MAX ULLONG_MAX
+#endif	/* HAVE_UINTMAX_T || defined(uintmax_t) */
+
+/* Support for long double. */
+#ifndef LDOUBLE
+#if HAVE_LONG_DOUBLE
+#define LDOUBLE long double
+#else
+#define LDOUBLE double
+#endif	/* HAVE_LONG_DOUBLE */
+#endif	/* !defined(LDOUBLE) */
+
+/* Support for long long int. */
+#ifndef LLONG
+#if HAVE_LONG_LONG_INT
+#define LLONG long long int
+#else
+#define LLONG long int
+#endif	/* HAVE_LONG_LONG_INT */
+#endif	/* !defined(LLONG) */
+
+/* Support for intmax_t. */
+#ifndef INTMAX_T
+#if HAVE_INTMAX_T || defined(intmax_t)
+#define INTMAX_T intmax_t
+#else
+#define INTMAX_T LLONG
+#endif	/* HAVE_INTMAX_T || defined(intmax_t) */
+#endif	/* !defined(INTMAX_T) */
+
+/* Support for uintptr_t. */
+#ifndef UINTPTR_T
+#if HAVE_UINTPTR_T || defined(uintptr_t)
+#define UINTPTR_T uintptr_t
+#else
+#define UINTPTR_T unsigned long int
+#endif	/* HAVE_UINTPTR_T || defined(uintptr_t) */
+#endif	/* !defined(UINTPTR_T) */
+
+/* Support for ptrdiff_t. */
+#ifndef PTRDIFF_T
+#if HAVE_PTRDIFF_T || defined(ptrdiff_t)
+#define PTRDIFF_T ptrdiff_t
+#else
+#define PTRDIFF_T long int
+#endif	/* HAVE_PTRDIFF_T || defined(ptrdiff_t) */
+#endif	/* !defined(PTRDIFF_T) */
+
+/*
+ * We need an unsigned integer type corresponding to ptrdiff_t (cf. C99:
+ * 7.19.6.1, 7).  However, we'll simply use PTRDIFF_T and convert it to an
+ * unsigned type if necessary.  This should work just fine in practice.
+ */
+#ifndef UPTRDIFF_T
+#define UPTRDIFF_T PTRDIFF_T
+#endif	/* !defined(UPTRDIFF_T) */
+
+/*
+ * We need a signed integer type corresponding to size_t (cf. C99: 7.19.6.1, 7).
+ * However, we'll simply use size_t and convert it to a signed type if
+ * necessary.  This should work just fine in practice.
+ */
+#ifndef SSIZE_T
+#define SSIZE_T size_t
+#endif	/* !defined(SSIZE_T) */
+
+/* Either ERANGE or E2BIG should be available everywhere. */
+#ifndef ERANGE
+#define ERANGE E2BIG
+#endif	/* !defined(ERANGE) */
+#ifndef EOVERFLOW
+#define EOVERFLOW ERANGE
+#endif	/* !defined(EOVERFLOW) */
+
+/*
+ * Buffer size to hold the octal string representation of UINT128_MAX without
+ * nul-termination ("3777777777777777777777777777777777777777777").
+ */
+#ifdef MAX_CONVERT_LENGTH
+#undef MAX_CONVERT_LENGTH
+#endif	/* defined(MAX_CONVERT_LENGTH) */
+#define MAX_CONVERT_LENGTH      43
+
+/* Format read states. */
+#define PRINT_S_DEFAULT         0
+#define PRINT_S_FLAGS           1
+#define PRINT_S_WIDTH           2
+#define PRINT_S_DOT             3
+#define PRINT_S_PRECISION       4
+#define PRINT_S_MOD             5
+#define PRINT_S_CONV            6
+
+/* Format flags. */
+#define PRINT_F_MINUS           (1 << 0)
+#define PRINT_F_PLUS            (1 << 1)
+#define PRINT_F_SPACE           (1 << 2)
+#define PRINT_F_NUM             (1 << 3)
+#define PRINT_F_ZERO            (1 << 4)
+#define PRINT_F_QUOTE           (1 << 5)
+#define PRINT_F_UP              (1 << 6)
+#define PRINT_F_UNSIGNED        (1 << 7)
+#define PRINT_F_TYPE_G          (1 << 8)
+#define PRINT_F_TYPE_E          (1 << 9)
+
+/* Conversion flags. */
+#define PRINT_C_CHAR            1
+#define PRINT_C_SHORT           2
+#define PRINT_C_LONG            3
+#define PRINT_C_LLONG           4
+#define PRINT_C_LDOUBLE         5
+#define PRINT_C_SIZE            6
+#define PRINT_C_PTRDIFF         7
+#define PRINT_C_INTMAX          8
+
+#ifndef MAX
+#define MAX(x, y) ((x >= y) ? x : y)
+#endif	/* !defined(MAX) */
+#ifndef CHARTOINT
+#define CHARTOINT(ch) (ch - '0')
+#endif	/* !defined(CHARTOINT) */
+#ifndef ISDIGIT
+#define ISDIGIT(ch) ('0' <= (unsigned char)ch && (unsigned char)ch <= '9')
+#endif	/* !defined(ISDIGIT) */
+#ifndef ISNAN
+#define ISNAN(x) (x != x)
+#endif	/* !defined(ISNAN) */
+#ifndef ISINF
+#define ISINF(x) (x != 0.0 && x + x == x)
+#endif	/* !defined(ISINF) */
+
+#ifdef OUTCHAR
+#undef OUTCHAR
+#endif	/* defined(OUTCHAR) */
+#define OUTCHAR(str, len, size, ch)                                          \
+do {                                                                         \
+	if (len + 1 < size)                                                  \
+		str[len] = ch;                                               \
+	(len)++;                                                             \
+} while (/* CONSTCOND */ 0)
+
+static void fmtstr(char *, size_t *, size_t, const char *, int, int, int);
+static void fmtint(char *, size_t *, size_t, INTMAX_T, int, int, int, int);
+static void fmtflt(char *, size_t *, size_t, LDOUBLE, int, int, int, int *);
+static void printsep(char *, size_t *, size_t);
+static int getnumsep(int);
+static int getexponent(LDOUBLE);
+static int convert(UINTMAX_T, char *, size_t, int, int);
+static UINTMAX_T cast(LDOUBLE);
+static UINTMAX_T myround(LDOUBLE);
+static LDOUBLE mypow10(int);
+
+extern int errno;
+
+int
+rpl_vsnprintf(char *str, size_t size, const char *format, va_list args);
+
+int
+rpl_vsnprintf(char *str, size_t size, const char *format, va_list args)
+{
+	LDOUBLE fvalue;
+	INTMAX_T value;
+	unsigned char cvalue;
+	const char *strvalue;
+	INTMAX_T *intmaxptr;
+	PTRDIFF_T *ptrdiffptr;
+	SSIZE_T *sizeptr;
+	LLONG *llongptr;
+	long int *longptr;
+	int *intptr;
+	short int *shortptr;
+	signed char *charptr;
+	size_t len = 0;
+	int overflow = 0;
+	int base = 0;
+	int cflags = 0;
+	int flags = 0;
+	int width = 0;
+	int precision = -1;
+	int state = PRINT_S_DEFAULT;
+	char ch = *format++;
+
+	/*
+	 * C99 says: "If `n' is zero, nothing is written, and `s' may be a null
+	 * pointer." (7.19.6.5, 2)  We're forgiving and allow a NULL pointer
+	 * even if a size larger than zero was specified.  At least NetBSD's
+	 * snprintf(3) does the same, as well as other versions of this file.
+	 * (Though some of these versions will write to a non-NULL buffer even
+	 * if a size of zero was specified, which violates the standard.)
+	 */
+	if (str == NULL && size != 0)
+		size = 0;
+
+	while (ch != '\0')
+		switch (state) {
+		case PRINT_S_DEFAULT:
+			if (ch == '%')
+				state = PRINT_S_FLAGS;
+			else
+				OUTCHAR(str, len, size, ch);
+			ch = *format++;
+			break;
+		case PRINT_S_FLAGS:
+			switch (ch) {
+			case '-':
+				flags |= PRINT_F_MINUS;
+				ch = *format++;
+				break;
+			case '+':
+				flags |= PRINT_F_PLUS;
+				ch = *format++;
+				break;
+			case ' ':
+				flags |= PRINT_F_SPACE;
+				ch = *format++;
+				break;
+			case '#':
+				flags |= PRINT_F_NUM;
+				ch = *format++;
+				break;
+			case '0':
+				flags |= PRINT_F_ZERO;
+				ch = *format++;
+				break;
+			case '\'':	/* SUSv2 flag (not in C99). */
+				flags |= PRINT_F_QUOTE;
+				ch = *format++;
+				break;
+			default:
+				state = PRINT_S_WIDTH;
+				break;
+			}
+			break;
+		case PRINT_S_WIDTH:
+			if (ISDIGIT(ch)) {
+				ch = CHARTOINT(ch);
+				if (width > (INT_MAX - ch) / 10) {
+					overflow = 1;
+					goto out;
+				}
+				width = 10 * width + ch;
+				ch = *format++;
+			} else if (ch == '*') {
+				/*
+				 * C99 says: "A negative field width argument is
+				 * taken as a `-' flag followed by a positive
+				 * field width." (7.19.6.1, 5)
+				 */
+				if ((width = va_arg(args, int)) < 0) {
+					flags |= PRINT_F_MINUS;
+					width = -width;
+				}
+				ch = *format++;
+				state = PRINT_S_DOT;
+			} else
+				state = PRINT_S_DOT;
+			break;
+		case PRINT_S_DOT:
+			if (ch == '.') {
+				state = PRINT_S_PRECISION;
+				ch = *format++;
+			} else
+				state = PRINT_S_MOD;
+			break;
+		case PRINT_S_PRECISION:
+			if (precision == -1)
+				precision = 0;
+			if (ISDIGIT(ch)) {
+				ch = CHARTOINT(ch);
+				if (precision > (INT_MAX - ch) / 10) {
+					overflow = 1;
+					goto out;
+				}
+				precision = 10 * precision + ch;
+				ch = *format++;
+			} else if (ch == '*') {
+				/*
+				 * C99 says: "A negative precision argument is
+				 * taken as if the precision were omitted."
+				 * (7.19.6.1, 5)
+				 */
+				if ((precision = va_arg(args, int)) < 0)
+					precision = -1;
+				ch = *format++;
+				state = PRINT_S_MOD;
+			} else
+				state = PRINT_S_MOD;
+			break;
+		case PRINT_S_MOD:
+			switch (ch) {
+			case 'h':
+				ch = *format++;
+				if (ch == 'h') {	/* It's a char. */
+					ch = *format++;
+					cflags = PRINT_C_CHAR;
+				} else
+					cflags = PRINT_C_SHORT;
+				break;
+			case 'l':
+				ch = *format++;
+				if (ch == 'l') {	/* It's a long long. */
+					ch = *format++;
+					cflags = PRINT_C_LLONG;
+				} else
+					cflags = PRINT_C_LONG;
+				break;
+			case 'L':
+				cflags = PRINT_C_LDOUBLE;
+				ch = *format++;
+				break;
+			case 'j':
+				cflags = PRINT_C_INTMAX;
+				ch = *format++;
+				break;
+			case 't':
+				cflags = PRINT_C_PTRDIFF;
+				ch = *format++;
+				break;
+			case 'z':
+				cflags = PRINT_C_SIZE;
+				ch = *format++;
+				break;
+			}
+			state = PRINT_S_CONV;
+			break;
+		case PRINT_S_CONV:
+			switch (ch) {
+			case 'd':
+				/* FALLTHROUGH */
+			case 'i':
+				switch (cflags) {
+				case PRINT_C_CHAR:
+					value = (signed char)va_arg(args, int);
+					break;
+				case PRINT_C_SHORT:
+					value = (short int)va_arg(args, int);
+					break;
+				case PRINT_C_LONG:
+					value = va_arg(args, long int);
+					break;
+				case PRINT_C_LLONG:
+					value = va_arg(args, LLONG);
+					break;
+				case PRINT_C_SIZE:
+					value = va_arg(args, SSIZE_T);
+					break;
+				case PRINT_C_INTMAX:
+					value = va_arg(args, INTMAX_T);
+					break;
+				case PRINT_C_PTRDIFF:
+					value = va_arg(args, PTRDIFF_T);
+					break;
+				default:
+					value = va_arg(args, int);
+					break;
+				}
+				fmtint(str, &len, size, value, 10, width,
+				    precision, flags);
+				break;
+			case 'X':
+				flags |= PRINT_F_UP;
+				/* FALLTHROUGH */
+			case 'x':
+				base = 16;
+				/* FALLTHROUGH */
+			case 'o':
+				if (base == 0)
+					base = 8;
+				/* FALLTHROUGH */
+			case 'u':
+				if (base == 0)
+					base = 10;
+				flags |= PRINT_F_UNSIGNED;
+				switch (cflags) {
+				case PRINT_C_CHAR:
+					value = (unsigned char)va_arg(args,
+					    unsigned int);
+					break;
+				case PRINT_C_SHORT:
+					value = (unsigned short int)va_arg(args,
+					    unsigned int);
+					break;
+				case PRINT_C_LONG:
+					value = va_arg(args, unsigned long int);
+					break;
+				case PRINT_C_LLONG:
+					value = va_arg(args, ULLONG);
+					break;
+				case PRINT_C_SIZE:
+					value = va_arg(args, size_t);
+					break;
+				case PRINT_C_INTMAX:
+					value = va_arg(args, UINTMAX_T);
+					break;
+				case PRINT_C_PTRDIFF:
+					value = va_arg(args, UPTRDIFF_T);
+					break;
+				default:
+					value = va_arg(args, unsigned int);
+					break;
+				}
+				fmtint(str, &len, size, value, base, width,
+				    precision, flags);
+				break;
+			case 'A':
+				/* Not yet supported, we'll use "%F". */
+				/* FALLTHROUGH */
+			case 'F':
+				flags |= PRINT_F_UP;
+			case 'a':
+				/* Not yet supported, we'll use "%f". */
+				/* FALLTHROUGH */
+			case 'f':
+				if (cflags == PRINT_C_LDOUBLE)
+					fvalue = va_arg(args, LDOUBLE);
+				else
+					fvalue = va_arg(args, double);
+				fmtflt(str, &len, size, fvalue, width,
+				    precision, flags, &overflow);
+				if (overflow)
+					goto out;
+				break;
+			case 'E':
+				flags |= PRINT_F_UP;
+				/* FALLTHROUGH */
+			case 'e':
+				flags |= PRINT_F_TYPE_E;
+				if (cflags == PRINT_C_LDOUBLE)
+					fvalue = va_arg(args, LDOUBLE);
+				else
+					fvalue = va_arg(args, double);
+				fmtflt(str, &len, size, fvalue, width,
+				    precision, flags, &overflow);
+				if (overflow)
+					goto out;
+				break;
+			case 'G':
+				flags |= PRINT_F_UP;
+				/* FALLTHROUGH */
+			case 'g':
+				flags |= PRINT_F_TYPE_G;
+				if (cflags == PRINT_C_LDOUBLE)
+					fvalue = va_arg(args, LDOUBLE);
+				else
+					fvalue = va_arg(args, double);
+				/*
+				 * If the precision is zero, it is treated as
+				 * one (cf. C99: 7.19.6.1, 8).
+				 */
+				if (precision == 0)
+					precision = 1;
+				fmtflt(str, &len, size, fvalue, width,
+				    precision, flags, &overflow);
+				if (overflow)
+					goto out;
+				break;
+			case 'c':
+				cvalue = va_arg(args, int);
+				OUTCHAR(str, len, size, cvalue);
+				break;
+			case 's':
+				strvalue = va_arg(args, char *);
+				fmtstr(str, &len, size, strvalue, width,
+				    precision, flags);
+				break;
+			case 'p':
+				/*
+				 * C99 says: "The value of the pointer is
+				 * converted to a sequence of printing
+				 * characters, in an implementation-defined
+				 * manner." (C99: 7.19.6.1, 8)
+				 */
+				if ((strvalue = va_arg(args, void *)) == NULL)
+					/*
+					 * We use the glibc format.  BSD prints
+					 * "0x0", SysV "0".
+					 */
+					fmtstr(str, &len, size, "(nil)", width,
+					    -1, flags);
+				else {
+					/*
+					 * We use the BSD/glibc format.  SysV
+					 * omits the "0x" prefix (which we emit
+					 * using the PRINT_F_NUM flag).
+					 */
+					flags |= PRINT_F_NUM;
+					flags |= PRINT_F_UNSIGNED;
+					fmtint(str, &len, size,
+					    (UINTPTR_T)strvalue, 16, width,
+					    precision, flags);
+				}
+				break;
+			case 'n':
+				switch (cflags) {
+				case PRINT_C_CHAR:
+					charptr = va_arg(args, signed char *);
+					*charptr = len;
+					break;
+				case PRINT_C_SHORT:
+					shortptr = va_arg(args, short int *);
+					*shortptr = len;
+					break;
+				case PRINT_C_LONG:
+					longptr = va_arg(args, long int *);
+					*longptr = len;
+					break;
+				case PRINT_C_LLONG:
+					llongptr = va_arg(args, LLONG *);
+					*llongptr = len;
+					break;
+				case PRINT_C_SIZE:
+					/*
+					 * C99 says that with the "z" length
+					 * modifier, "a following `n' conversion
+					 * specifier applies to a pointer to a
+					 * signed integer type corresponding to
+					 * size_t argument." (7.19.6.1, 7)
+					 */
+					sizeptr = va_arg(args, SSIZE_T *);
+					*sizeptr = len;
+					break;
+				case PRINT_C_INTMAX:
+					intmaxptr = va_arg(args, INTMAX_T *);
+					*intmaxptr = len;
+					break;
+				case PRINT_C_PTRDIFF:
+					ptrdiffptr = va_arg(args, PTRDIFF_T *);
+					*ptrdiffptr = len;
+					break;
+				default:
+					intptr = va_arg(args, int *);
+					*intptr = len;
+					break;
+				}
+				break;
+			case '%':	/* Print a "%" character verbatim. */
+				OUTCHAR(str, len, size, ch);
+				break;
+			default:	/* Skip other characters. */
+				break;
+			}
+			ch = *format++;
+			state = PRINT_S_DEFAULT;
+			base = cflags = flags = width = 0;
+			precision = -1;
+			break;
+		}
+out:
+	if (len < size)
+		str[len] = '\0';
+	else if (size > 0)
+		str[size - 1] = '\0';
+
+	if (overflow || len >= INT_MAX) {
+		errno = overflow ? EOVERFLOW : ERANGE;
+		return -1;
+	}
+	return (int)len;
+}
+
+static void
+fmtstr(char *str, size_t *len, size_t size, const char *value, int width,
+       int precision, int flags)
 {
+	int padlen, strln;	/* Amount to pad. */
+	int noprecision = (precision == -1);
+
+	if (value == NULL)	/* We're forgiving. */
+		value = "(null)";
+
+	/* If a precision was specified, don't read the string past it. */
+	for (strln = 0; value[strln] != '\0' &&
+	    (noprecision || strln < precision); strln++)
+		continue;
+
+	if ((padlen = width - strln) < 0)
+		padlen = 0;
+	if (flags & PRINT_F_MINUS)	/* Left justify. */
+		padlen = -padlen;
+
+	while (padlen > 0) {	/* Leading spaces. */
+		OUTCHAR(str, *len, size, ' ');
+		padlen--;
+	}
+	while (*value != '\0' && (noprecision || precision-- > 0)) {
+		OUTCHAR(str, *len, size, *value);
+		value++;
+	}
+	while (padlen < 0) {	/* Trailing spaces. */
+		OUTCHAR(str, *len, size, ' ');
+		padlen++;
+	}
+}
+
+static void
+fmtint(char *str, size_t *len, size_t size, INTMAX_T value, int base, int width,
+       int precision, int flags)
+{
+	UINTMAX_T uvalue;
+	char iconvert[MAX_CONVERT_LENGTH];
+	char sign = 0;
+	char hexprefix = 0;
+	int spadlen = 0;	/* Amount to space pad. */
+	int zpadlen = 0;	/* Amount to zero pad. */
+	int pos;
+	int separators = (flags & PRINT_F_QUOTE);
+	int noprecision = (precision == -1);
+
+	if (flags & PRINT_F_UNSIGNED)
+		uvalue = value;
+	else {
+		uvalue = (value >= 0) ? value : -value;
+		if (value < 0)
+			sign = '-';
+		else if (flags & PRINT_F_PLUS)	/* Do a sign. */
+			sign = '+';
+		else if (flags & PRINT_F_SPACE)
+			sign = ' ';
+	}
+
+	pos = convert(uvalue, iconvert, sizeof(iconvert), base,
+	    flags & PRINT_F_UP);
+
+	if (flags & PRINT_F_NUM && uvalue != 0) {
+		/*
+		 * C99 says: "The result is converted to an `alternative form'.
+		 * For `o' conversion, it increases the precision, if and only
+		 * if necessary, to force the first digit of the result to be a
+		 * zero (if the value and precision are both 0, a single 0 is
+		 * printed).  For `x' (or `X') conversion, a nonzero result has
+		 * `0x' (or `0X') prefixed to it." (7.19.6.1, 6)
+		 */
+		switch (base) {
+		case 8:
+			if (precision <= pos)
+				precision = pos + 1;
+			break;
+		case 16:
+			hexprefix = (flags & PRINT_F_UP) ? 'X' : 'x';
+			break;
+		}
+	}
+
+	if (separators)	/* Get the number of group separators we'll print. */
+		separators = getnumsep(pos);
+
+	zpadlen = precision - pos - separators;
+	spadlen = width                         /* Minimum field width. */
+	    - separators                        /* Number of separators. */
+	    - MAX(precision, pos)               /* Number of integer digits. */
+	    - ((sign != 0) ? 1 : 0)             /* Will we print a sign? */
+	    - ((hexprefix != 0) ? 2 : 0);       /* Will we print a prefix? */
+
+	if (zpadlen < 0)
+		zpadlen = 0;
+	if (spadlen < 0)
+		spadlen = 0;
+
+	/*
+	 * C99 says: "If the `0' and `-' flags both appear, the `0' flag is
+	 * ignored.  For `d', `i', `o', `u', `x', and `X' conversions, if a
+	 * precision is specified, the `0' flag is ignored." (7.19.6.1, 6)
+	 */
+	if (flags & PRINT_F_MINUS)	/* Left justify. */
+		spadlen = -spadlen;
+	else if (flags & PRINT_F_ZERO && noprecision) {
+		zpadlen += spadlen;
+		spadlen = 0;
+	}
+	while (spadlen > 0) {	/* Leading spaces. */
+		OUTCHAR(str, *len, size, ' ');
+		spadlen--;
+	}
+	if (sign != 0)	/* Sign. */
+		OUTCHAR(str, *len, size, sign);
+	if (hexprefix != 0) {	/* A "0x" or "0X" prefix. */
+		OUTCHAR(str, *len, size, '0');
+		OUTCHAR(str, *len, size, hexprefix);
+	}
+	while (zpadlen > 0) {	/* Leading zeros. */
+		OUTCHAR(str, *len, size, '0');
+		zpadlen--;
+	}
+	while (pos > 0) {	/* The actual digits. */
+		pos--;
+		OUTCHAR(str, *len, size, iconvert[pos]);
+		if (separators > 0 && pos > 0 && pos % 3 == 0)
+			printsep(str, len, size);
+	}
+	while (spadlen < 0) {	/* Trailing spaces. */
+		OUTCHAR(str, *len, size, ' ');
+		spadlen++;
+	}
+}
+
+static void
+fmtflt(char *str, size_t *len, size_t size, LDOUBLE fvalue, int width,
+       int precision, int flags, int *overflow)
+{
+	LDOUBLE ufvalue;
+	UINTMAX_T intpart;
+	UINTMAX_T fracpart;
+	UINTMAX_T mask;
+	const char *infnan = NULL;
+	char iconvert[MAX_CONVERT_LENGTH];
+	char fconvert[MAX_CONVERT_LENGTH];
+	char econvert[4];	/* "e-12" (without nul-termination). */
+	char esign = 0;
+	char sign = 0;
+	int leadfraczeros = 0;
+	int exponent = 0;
+	int emitpoint = 0;
+	int omitzeros = 0;
+	int omitcount = 0;
+	int padlen = 0;
+	int epos = 0;
+	int fpos = 0;
+	int ipos = 0;
+	int separators = (flags & PRINT_F_QUOTE);
+	int estyle = (flags & PRINT_F_TYPE_E);
+#if HAVE_LOCALECONV && HAVE_LCONV_DECIMAL_POINT
+	struct lconv *lc = localeconv();
+#endif	/* HAVE_LOCALECONV && HAVE_LCONV_DECIMAL_POINT */
+
+	/*
+	 * AIX' man page says the default is 0, but C99 and at least Solaris'
+	 * and NetBSD's man pages say the default is 6, and sprintf(3) on AIX
+	 * defaults to 6.
+	 */
+	if (precision == -1)
+		precision = 6;
+
+	if (fvalue < 0.0)
+		sign = '-';
+	else if (flags & PRINT_F_PLUS)	/* Do a sign. */
+		sign = '+';
+	else if (flags & PRINT_F_SPACE)
+		sign = ' ';
+
+	if (ISNAN(fvalue))
+		infnan = (flags & PRINT_F_UP) ? "NAN" : "nan";
+	else if (ISINF(fvalue))
+		infnan = (flags & PRINT_F_UP) ? "INF" : "inf";
+
+	if (infnan != NULL) {
+		if (sign != 0)
+			iconvert[ipos++] = sign;
+		while (*infnan != '\0')
+			iconvert[ipos++] = *infnan++;
+		fmtstr(str, len, size, iconvert, width, ipos, flags);
+		return;
+	}
+
+	/* "%e" (or "%E") or "%g" (or "%G") conversion. */
+	if (flags & PRINT_F_TYPE_E || flags & PRINT_F_TYPE_G) {
+		if (flags & PRINT_F_TYPE_G) {
+			/*
+			 * For "%g" (and "%G") conversions, the precision
+			 * specifies the number of significant digits, which
+			 * includes the digits in the integer part.  The
+			 * conversion will or will not be using "e-style" (like
+			 * "%e" or "%E" conversions) depending on the precision
+			 * and on the exponent.  However, the exponent can be
+			 * affected by rounding the converted value, so we'll
+			 * leave this decision for later.  Until then, we'll
+			 * assume that we're going to do an "e-style" conversion
+			 * (in order to get the exponent calculated).  For
+			 * "e-style", the precision must be decremented by one.
+			 */
+			precision--;
+			/*
+			 * For "%g" (and "%G") conversions, trailing zeros are
+			 * removed from the fractional portion of the result
+			 * unless the "#" flag was specified.
+			 */
+			if (!(flags & PRINT_F_NUM))
+				omitzeros = 1;
+		}
+		exponent = getexponent(fvalue);
+		estyle = 1;
+	}
+
+again:
+	/*
+	 * Sorry, we only support 9, 19, or 38 digits (that is, the number of
+	 * digits of the 32-bit, the 64-bit, or the 128-bit UINTMAX_MAX value
+	 * minus one) past the decimal point due to our conversion method.
+	 */
+	switch (sizeof(UINTMAX_T)) {
+	case 16:
+		if (precision > 38)
+			precision = 38;
+		break;
+	case 8:
+		if (precision > 19)
+			precision = 19;
+		break;
+	default:
+		if (precision > 9)
+			precision = 9;
+		break;
+	}
+
+	ufvalue = (fvalue >= 0.0) ? fvalue : -fvalue;
+	if (estyle)	/* We want exactly one integer digit. */
+		ufvalue /= mypow10(exponent);
+
+	if ((intpart = cast(ufvalue)) == UINTMAX_MAX) {
+		*overflow = 1;
+		return;
+	}
+
+	/*
+	 * Factor of ten with the number of digits needed for the fractional
+	 * part.  For example, if the precision is 3, the mask will be 1000.
+	 */
+	mask = mypow10(precision);
+	/*
+	 * We "cheat" by converting the fractional part to integer by
+	 * multiplying by a factor of ten.
+	 */
+	if ((fracpart = myround(mask * (ufvalue - intpart))) >= mask) {
+		/*
+		 * For example, ufvalue = 2.99962, intpart = 2, and mask = 1000
+		 * (because precision = 3).  Now, myround(1000 * 0.99962) will
+		 * return 1000.  So, the integer part must be incremented by one
+		 * and the fractional part must be set to zero.
+		 */
+		intpart++;
+		fracpart = 0;
+		if (estyle && intpart == 10) {
+			/*
+			 * The value was rounded up to ten, but we only want one
+			 * integer digit if using "e-style".  So, the integer
+			 * part must be set to one and the exponent must be
+			 * incremented by one.
+			 */
+			intpart = 1;
+			exponent++;
+		}
+	}
+
+	/*
+	 * Now that we know the real exponent, we can check whether or not to
+	 * use "e-style" for "%g" (and "%G") conversions.  If we don't need
+	 * "e-style", the precision must be adjusted and the integer and
+	 * fractional parts must be recalculated from the original value.
+	 *
+	 * C99 says: "Let P equal the precision if nonzero, 6 if the precision
+	 * is omitted, or 1 if the precision is zero.  Then, if a conversion
+	 * with style `E' would have an exponent of X:
+	 *
+	 * - if P > X >= -4, the conversion is with style `f' (or `F') and
+	 *   precision P - (X + 1).
+	 *
+	 * - otherwise, the conversion is with style `e' (or `E') and precision
+	 *   P - 1." (7.19.6.1, 8)
+	 *
+	 * Note that we had decremented the precision by one.
+	 */
+	if (flags & PRINT_F_TYPE_G && estyle &&
+	    precision + 1 > exponent && exponent >= -4) {
+		precision -= exponent;
+		estyle = 0;
+		goto again;
+	}
+
+	if (estyle) {
+		if (exponent < 0) {
+			exponent = -exponent;
+			esign = '-';
+		} else
+			esign = '+';
+
+		/*
+		 * Convert the exponent.  The sizeof(econvert) is 4.  So, the
+		 * econvert buffer can hold e.g. "e+99" and "e-99".  We don't
+		 * support an exponent which contains more than two digits.
+		 * Therefore, the following stores are safe.
+		 */
+		epos = convert(exponent, econvert, 2, 10, 0);
+		/*
+		 * C99 says: "The exponent always contains at least two digits,
+		 * and only as many more digits as necessary to represent the
+		 * exponent." (7.19.6.1, 8)
+		 */
+		if (epos == 1)
+			econvert[epos++] = '0';
+		econvert[epos++] = esign;
+		econvert[epos++] = (flags & PRINT_F_UP) ? 'E' : 'e';
+	}
+
+	/* Convert the integer part and the fractional part. */
+	ipos = convert(intpart, iconvert, sizeof(iconvert), 10, 0);
+	if (fracpart != 0)	/* convert() would return 1 if fracpart == 0. */
+		fpos = convert(fracpart, fconvert, sizeof(fconvert), 10, 0);
+
+	leadfraczeros = precision - fpos;
+
+	if (omitzeros) {
+		if (fpos > 0)	/* Omit trailing fractional part zeros. */
+			while (omitcount < fpos && fconvert[omitcount] == '0')
+				omitcount++;
+		else {	/* The fractional part is zero, omit it completely. */
+			omitcount = precision;
+			leadfraczeros = 0;
+		}
+		precision -= omitcount;
+	}
+
+	/*
+	 * Print a decimal point if either the fractional part is non-zero
+	 * and/or the "#" flag was specified.
+	 */
+	if (precision > 0 || flags & PRINT_F_NUM)
+		emitpoint = 1;
+	if (separators)	/* Get the number of group separators we'll print. */
+		separators = getnumsep(ipos);
+
+	padlen = width                  /* Minimum field width. */
+	    - ipos                      /* Number of integer digits. */
+	    - epos                      /* Number of exponent characters. */
+	    - precision                 /* Number of fractional digits. */
+	    - separators                /* Number of group separators. */
+	    - (emitpoint ? 1 : 0)       /* Will we print a decimal point? */
+	    - ((sign != 0) ? 1 : 0);    /* Will we print a sign character? */
+
+	if (padlen < 0)
+		padlen = 0;
+
+	/*
+	 * C99 says: "If the `0' and `-' flags both appear, the `0' flag is
+	 * ignored." (7.19.6.1, 6)
+	 */
+	if (flags & PRINT_F_MINUS)	/* Left justifty. */
+		padlen = -padlen;
+	else if (flags & PRINT_F_ZERO && padlen > 0) {
+		if (sign != 0) {	/* Sign. */
+			OUTCHAR(str, *len, size, sign);
+			sign = 0;
+		}
+		while (padlen > 0) {	/* Leading zeros. */
+			OUTCHAR(str, *len, size, '0');
+			padlen--;
+		}
+	}
+	while (padlen > 0) {	/* Leading spaces. */
+		OUTCHAR(str, *len, size, ' ');
+		padlen--;
+	}
+	if (sign != 0)	/* Sign. */
+		OUTCHAR(str, *len, size, sign);
+	while (ipos > 0) {	/* Integer part. */
+		ipos--;
+		OUTCHAR(str, *len, size, iconvert[ipos]);
+		if (separators > 0 && ipos > 0 && ipos % 3 == 0)
+			printsep(str, len, size);
+	}
+	if (emitpoint) {	/* Decimal point. */
+#if HAVE_LOCALECONV && HAVE_LCONV_DECIMAL_POINT
+		if (lc->decimal_point != NULL && *lc->decimal_point != '\0')
+			OUTCHAR(str, *len, size, *lc->decimal_point);
+		else	/* We'll always print some decimal point character. */
+#endif	/* HAVE_LOCALECONV && HAVE_LCONV_DECIMAL_POINT */
+			OUTCHAR(str, *len, size, '.');
+	}
+	while (leadfraczeros > 0) {	/* Leading fractional part zeros. */
+		OUTCHAR(str, *len, size, '0');
+		leadfraczeros--;
+	}
+	while (fpos > omitcount) {	/* The remaining fractional part. */
+		fpos--;
+		OUTCHAR(str, *len, size, fconvert[fpos]);
+	}
+	while (epos > 0) {	/* Exponent. */
+		epos--;
+		OUTCHAR(str, *len, size, econvert[epos]);
+	}
+	while (padlen < 0) {	/* Trailing spaces. */
+		OUTCHAR(str, *len, size, ' ');
+		padlen++;
+	}
+}
+
+static void
+printsep(char *str, size_t *len, size_t size)
+{
+#if HAVE_LOCALECONV && HAVE_LCONV_THOUSANDS_SEP
+	struct lconv *lc = localeconv();
+	int i;
+
+	if (lc->thousands_sep != NULL)
+		for (i = 0; lc->thousands_sep[i] != '\0'; i++)
+			OUTCHAR(str, *len, size, lc->thousands_sep[i]);
+	else
+#endif	/* HAVE_LOCALECONV && HAVE_LCONV_THOUSANDS_SEP */
+		OUTCHAR(str, *len, size, ',');
+}
+
+static int
+getnumsep(int digits)
+{
+	int separators = (digits - ((digits % 3 == 0) ? 1 : 0)) / 3;
+#if HAVE_LOCALECONV && HAVE_LCONV_THOUSANDS_SEP
+	int strln;
+	struct lconv *lc = localeconv();
+
+	/* We support an arbitrary separator length (including zero). */
+	if (lc->thousands_sep != NULL) {
+		for (strln = 0; lc->thousands_sep[strln] != '\0'; strln++)
+			continue;
+		separators *= strln;
+	}
+#endif	/* HAVE_LOCALECONV && HAVE_LCONV_THOUSANDS_SEP */
+	return separators;
+}
+
+static int
+getexponent(LDOUBLE value)
+{
+	LDOUBLE tmp = (value >= 0.0) ? value : -value;
+	int exponent = 0;
+
+	/*
+	 * We check for 99 > exponent > -99 in order to work around possible
+	 * endless loops which could happen (at least) in the second loop (at
+	 * least) if we're called with an infinite value.  However, we checked
+	 * for infinity before calling this function using our ISINF() macro, so
+	 * this might be somewhat paranoid.
+	 */
+	while (tmp < 1.0 && tmp > 0.0 && --exponent > -99)
+		tmp *= 10;
+	while (tmp >= 10.0 && ++exponent < 99)
+		tmp /= 10;
+
+	return exponent;
+}
+
+static int
+convert(UINTMAX_T value, char *buf, size_t size, int base, int caps)
+{
+	const char *digits = caps ? "0123456789ABCDEF" : "0123456789abcdef";
+	size_t pos = 0;
+
+	/* We return an unterminated buffer with the digits in reverse order. */
+	do {
+		buf[pos++] = digits[value % base];
+		value /= base;
+	} while (value != 0 && pos < size);
+
+	return (int)pos;
+}
+
+static UINTMAX_T
+cast(LDOUBLE value)
+{
+	UINTMAX_T result;
+
+	/*
+	 * We check for ">=" and not for ">" because if UINTMAX_MAX cannot be
+	 * represented exactly as an LDOUBLE value (but is less than LDBL_MAX),
+	 * it may be increased to the nearest higher representable value for the
+	 * comparison (cf. C99: 6.3.1.4, 2).  It might then equal the LDOUBLE
+	 * value although converting the latter to UINTMAX_T would overflow.
+	 */
+	if (value >= UINTMAX_MAX)
+		return UINTMAX_MAX;
+
+	result = value;
+	/*
+	 * At least on NetBSD/sparc64 3.0.2 and 4.99.30, casting long double to
+	 * an integer type converts e.g. 1.9 to 2 instead of 1 (which violates
+	 * the standard).  Sigh.
+	 */
+	return (result <= value) ? result : result - 1;
+}
+
+static UINTMAX_T
+myround(LDOUBLE value)
+{
+	UINTMAX_T intpart = cast(value);
+
+	return ((value -= intpart) < 0.5) ? intpart : intpart + 1;
+}
+
+static LDOUBLE
+mypow10(int exponent)
+{
+	LDOUBLE result = 1;
+
+	while (exponent > 0) {
+		result *= 10;
+		exponent--;
+	}
+	while (exponent < 0) {
+		result /= 10;
+		exponent++;
+	}
+	return result;
+}
+#endif	/* HW_WANT_RPL_VSNPRINTF */
+
+#if HW_WANT_RPL_VASPRINTF
+#if NEED_MYMEMCPY
+void *
+mymemcpy(void *dst, void *src, size_t len)
+{
+	const char *from = src;
+	char *to = dst;
+
+	/* No need for optimization, we use this only to replace va_copy(3). */
+	while (len-- > 0)
+		*to++ = *from++;
+	return dst;
+}
+#endif	/* NEED_MYMEMCPY */
+
+int
+rpl_vasprintf(char **ret, const char *format, va_list ap);
+
+int
+rpl_vasprintf(char **ret, const char *format, va_list ap)
+{
+	size_t size;
+	int len;
+	va_list aq;
+
+	VA_COPY(aq, ap);
+	len = vsnprintf(NULL, 0, format, aq);
+	VA_END_COPY(aq);
+	if (len < 0 || (*ret = malloc(size = len + 1)) == NULL)
+		return -1;
+	return vsnprintf(*ret, size, format, ap);
+}
+#endif	/* HW_WANT_RPL_VASPRINTF */
+
+#if HW_WANT_RPL_SNPRINTF
+#if HAVE_STDARG_H
+int
+rpl_snprintf(char *str, size_t size, const char *format, ...);
+
+int
+rpl_snprintf(char *str, size_t size, const char *format, ...)
+#else
+int
+rpl_snprintf(va_alist) va_dcl
+#endif	/* HAVE_STDARG_H */
+{
+#if !HAVE_STDARG_H
+	char *str;
+	size_t size;
+	char *format;
+#endif	/* HAVE_STDARG_H */
 	va_list ap;
-	int rval;
-#ifdef VSPRINTF_CHARSTAR
-	char *rp;
-#endif
-#ifdef __STDC__
-	va_start(ap, fmt);
-#else
-	va_start(ap);
-#endif
-#ifdef VSPRINTF_CHARSTAR
-	rp = vsprintf(str, fmt, ap);
+	int len;
+
+	VA_START(ap, format);
+	VA_SHIFT(ap, str, char *);
+	VA_SHIFT(ap, size, size_t);
+	VA_SHIFT(ap, format, const char *);
+	len = vsnprintf(str, size, format, ap);
 	va_end(ap);
-	return (strlen(rp));
+	return len;
+}
+#endif	/* HW_WANT_RPL_SNPRINTF */
+
+#if HW_WANT_RPL_ASPRINTF
+#if HAVE_STDARG_H
+int
+rpl_asprintf(char **ret, const char *format, ...);
+
+int
+rpl_asprintf(char **ret, const char *format, ...)
 #else
-	rval = vsprintf(str, fmt, ap);
+int
+rpl_asprintf(va_alist) va_dcl
+#endif	/* HAVE_STDARG_H */
+{
+#if !HAVE_STDARG_H
+	char **ret;
+	char *format;
+#endif	/* HAVE_STDARG_H */
+	va_list ap;
+	int len;
+
+	VA_START(ap, format);
+	VA_SHIFT(ap, ret, char **);
+	VA_SHIFT(ap, format, const char *);
+	len = vasprintf(ret, format, ap);
 	va_end(ap);
-	return (rval);
-#endif
+	return len;
 }
+#endif	/* HW_WANT_RPL_ASPRINTF */
+#else	/* Dummy declaration to avoid empty translation unit warnings. */
+int main(void);
+#endif	/* HW_WANT_RPL_SNPRINTF || HW_WANT_RPL_VSNPRINTF || HW_WANT_RPL_ASPRINTF || [...] */
 
+#if TEST_SNPRINTF
 int
-vsnprintf(
-	char *str,
-	size_t n,
-	const char *fmt,
-	va_list ap
-	)
+main(void)
 {
-#ifdef VSPRINTF_CHARSTAR
-	return (strlen(vsprintf(str, fmt, ap)));
-#else
-	return (vsprintf(str, fmt, ap));
-#endif
+	const char *float_fmt[] = {
+		/* "%E" and "%e" formats. */
+#if HAVE_LONG_LONG_INT && !OS_BSD && !OS_IRIX
+		"%.16e",
+		"%22.16e",
+		"%022.16e",
+		"%-22.16e",
+		"%#+'022.16e",
+#endif	/* HAVE_LONG_LONG_INT && !OS_BSD && !OS_IRIX */
+		"foo|%#+0123.9E|bar",
+		"%-123.9e",
+		"%123.9e",
+		"%+23.9e",
+		"%+05.8e",
+		"%-05.8e",
+		"%05.8e",
+		"%+5.8e",
+		"%-5.8e",
+		"% 5.8e",
+		"%5.8e",
+		"%+4.9e",
+#if !OS_LINUX	/* glibc sometimes gets these wrong. */
+		"%+#010.0e",
+		"%#10.1e",
+		"%10.5e",
+		"% 10.5e",
+		"%5.0e",
+		"%5.e",
+		"%#5.0e",
+		"%#5.e",
+		"%3.2e",
+		"%3.1e",
+		"%-1.5e",
+		"%1.5e",
+		"%01.3e",
+		"%1.e",
+		"%.1e",
+		"%#.0e",
+		"%+.0e",
+		"% .0e",
+		"%.0e",
+		"%#.e",
+		"%+.e",
+		"% .e",
+		"%.e",
+		"%4e",
+		"%e",
+		"%E",
+#endif	/* !OS_LINUX */
+		/* "%F" and "%f" formats. */
+#if !OS_BSD && !OS_IRIX
+		"% '022f",
+		"%+'022f",
+		"%-'22f",
+		"%'22f",
+#if HAVE_LONG_LONG_INT
+		"%.16f",
+		"%22.16f",
+		"%022.16f",
+		"%-22.16f",
+		"%#+'022.16f",
+#endif	/* HAVE_LONG_LONG_INT */
+#endif	/* !OS_BSD && !OS_IRIX */
+		"foo|%#+0123.9F|bar",
+		"%-123.9f",
+		"%123.9f",
+		"%+23.9f",
+		"%+#010.0f",
+		"%#10.1f",
+		"%10.5f",
+		"% 10.5f",
+		"%+05.8f",
+		"%-05.8f",
+		"%05.8f",
+		"%+5.8f",
+		"%-5.8f",
+		"% 5.8f",
+		"%5.8f",
+		"%5.0f",
+		"%5.f",
+		"%#5.0f",
+		"%#5.f",
+		"%+4.9f",
+		"%3.2f",
+		"%3.1f",
+		"%-1.5f",
+		"%1.5f",
+		"%01.3f",
+		"%1.f",
+		"%.1f",
+		"%#.0f",
+		"%+.0f",
+		"% .0f",
+		"%.0f",
+		"%#.f",
+		"%+.f",
+		"% .f",
+		"%.f",
+		"%4f",
+		"%f",
+		"%F",
+		/* "%G" and "%g" formats. */
+#if !OS_BSD && !OS_IRIX && !OS_LINUX
+		"% '022g",
+		"%+'022g",
+		"%-'22g",
+		"%'22g",
+#if HAVE_LONG_LONG_INT
+		"%.16g",
+		"%22.16g",
+		"%022.16g",
+		"%-22.16g",
+		"%#+'022.16g",
+#endif	/* HAVE_LONG_LONG_INT */
+#endif	/* !OS_BSD && !OS_IRIX && !OS_LINUX */
+		"foo|%#+0123.9G|bar",
+		"%-123.9g",
+		"%123.9g",
+		"%+23.9g",
+		"%+05.8g",
+		"%-05.8g",
+		"%05.8g",
+		"%+5.8g",
+		"%-5.8g",
+		"% 5.8g",
+		"%5.8g",
+		"%+4.9g",
+#if !OS_LINUX	/* glibc sometimes gets these wrong. */
+		"%+#010.0g",
+		"%#10.1g",
+		"%10.5g",
+		"% 10.5g",
+		"%5.0g",
+		"%5.g",
+		"%#5.0g",
+		"%#5.g",
+		"%3.2g",
+		"%3.1g",
+		"%-1.5g",
+		"%1.5g",
+		"%01.3g",
+		"%1.g",
+		"%.1g",
+		"%#.0g",
+		"%+.0g",
+		"% .0g",
+		"%.0g",
+		"%#.g",
+		"%+.g",
+		"% .g",
+		"%.g",
+		"%4g",
+		"%g",
+		"%G",
+#endif	/* !OS_LINUX */
+		NULL
+	};
+	double float_val[] = {
+		-4.136,
+		-134.52,
+		-5.04030201,
+		-3410.01234,
+		-999999.999999,
+		-913450.29876,
+		-913450.2,
+		-91345.2,
+		-9134.2,
+		-913.2,
+		-91.2,
+		-9.2,
+		-9.9,
+		4.136,
+		134.52,
+		5.04030201,
+		3410.01234,
+		999999.999999,
+		913450.29876,
+		913450.2,
+		91345.2,
+		9134.2,
+		913.2,
+		91.2,
+		9.2,
+		9.9,
+		9.96,
+		9.996,
+		9.9996,
+		9.99996,
+		9.999996,
+		9.9999996,
+		9.99999996,
+		0.99999996,
+		0.99999999,
+		0.09999999,
+		0.00999999,
+		0.00099999,
+		0.00009999,
+		0.00000999,
+		0.00000099,
+		0.00000009,
+		0.00000001,
+		0.0000001,
+		0.000001,
+		0.00001,
+		0.0001,
+		0.001,
+		0.01,
+		0.1,
+		1.0,
+		1.5,
+		-1.5,
+		-1.0,
+		-0.1,
+#if !OS_BSD	/* BSD sometimes gets these wrong. */
+#ifdef INFINITY
+		INFINITY,
+		-INFINITY,
+#endif	/* defined(INFINITY) */
+#ifdef NAN
+		NAN,
+#endif	/* defined(NAN) */
+#endif	/* !OS_BSD */
+		0
+	};
+	const char *long_fmt[] = {
+		"foo|%0123ld|bar",
+#if !OS_IRIX
+		"% '0123ld",
+		"%+'0123ld",
+		"%-'123ld",
+		"%'123ld",
+#endif	/* !OS_IRiX */
+		"%123.9ld",
+		"% 123.9ld",
+		"%+123.9ld",
+		"%-123.9ld",
+		"%0123ld",
+		"% 0123ld",
+		"%+0123ld",
+		"%-0123ld",
+		"%10.5ld",
+		"% 10.5ld",
+		"%+10.5ld",
+		"%-10.5ld",
+		"%010ld",
+		"% 010ld",
+		"%+010ld",
+		"%-010ld",
+		"%4.2ld",
+		"% 4.2ld",
+		"%+4.2ld",
+		"%-4.2ld",
+		"%04ld",
+		"% 04ld",
+		"%+04ld",
+		"%-04ld",
+		"%5.5ld",
+		"%+22.33ld",
+		"%01.3ld",
+		"%1.5ld",
+		"%-1.5ld",
+		"%44ld",
+		"%4ld",
+		"%4.0ld",
+		"%4.ld",
+		"%.44ld",
+		"%.4ld",
+		"%.0ld",
+		"%.ld",
+		"%ld",
+		NULL
+	};
+	long int long_val[] = {
+#ifdef LONG_MAX
+		LONG_MAX,
+#endif	/* LONG_MAX */
+#ifdef LONG_MIN
+		LONG_MIN,
+#endif	/* LONG_MIN */
+		-91340,
+		91340,
+		341,
+		134,
+		0203,
+		-1,
+		1,
+		0
+	};
+	const char *ulong_fmt[] = {
+		/* "%u" formats. */
+		"foo|%0123lu|bar",
+#if !OS_IRIX
+		"% '0123lu",
+		"%+'0123lu",
+		"%-'123lu",
+		"%'123lu",
+#endif	/* !OS_IRiX */
+		"%123.9lu",
+		"% 123.9lu",
+		"%+123.9lu",
+		"%-123.9lu",
+		"%0123lu",
+		"% 0123lu",
+		"%+0123lu",
+		"%-0123lu",
+		"%5.5lu",
+		"%+22.33lu",
+		"%01.3lu",
+		"%1.5lu",
+		"%-1.5lu",
+		"%44lu",
+		"%lu",
+		/* "%o" formats. */
+		"foo|%#0123lo|bar",
+		"%#123.9lo",
+		"%# 123.9lo",
+		"%#+123.9lo",
+		"%#-123.9lo",
+		"%#0123lo",
+		"%# 0123lo",
+		"%#+0123lo",
+		"%#-0123lo",
+		"%#5.5lo",
+		"%#+22.33lo",
+		"%#01.3lo",
+		"%#1.5lo",
+		"%#-1.5lo",
+		"%#44lo",
+		"%#lo",
+		"%123.9lo",
+		"% 123.9lo",
+		"%+123.9lo",
+		"%-123.9lo",
+		"%0123lo",
+		"% 0123lo",
+		"%+0123lo",
+		"%-0123lo",
+		"%5.5lo",
+		"%+22.33lo",
+		"%01.3lo",
+		"%1.5lo",
+		"%-1.5lo",
+		"%44lo",
+		"%lo",
+		/* "%X" and "%x" formats. */
+		"foo|%#0123lX|bar",
+		"%#123.9lx",
+		"%# 123.9lx",
+		"%#+123.9lx",
+		"%#-123.9lx",
+		"%#0123lx",
+		"%# 0123lx",
+		"%#+0123lx",
+		"%#-0123lx",
+		"%#5.5lx",
+		"%#+22.33lx",
+		"%#01.3lx",
+		"%#1.5lx",
+		"%#-1.5lx",
+		"%#44lx",
+		"%#lx",
+		"%#lX",
+		"%123.9lx",
+		"% 123.9lx",
+		"%+123.9lx",
+		"%-123.9lx",
+		"%0123lx",
+		"% 0123lx",
+		"%+0123lx",
+		"%-0123lx",
+		"%5.5lx",
+		"%+22.33lx",
+		"%01.3lx",
+		"%1.5lx",
+		"%-1.5lx",
+		"%44lx",
+		"%lx",
+		"%lX",
+		NULL
+	};
+	unsigned long int ulong_val[] = {
+#ifdef ULONG_MAX
+		ULONG_MAX,
+#endif	/* ULONG_MAX */
+		91340,
+		341,
+		134,
+		0203,
+		1,
+		0
+	};
+	const char *llong_fmt[] = {
+		"foo|%0123lld|bar",
+		"%123.9lld",
+		"% 123.9lld",
+		"%+123.9lld",
+		"%-123.9lld",
+		"%0123lld",
+		"% 0123lld",
+		"%+0123lld",
+		"%-0123lld",
+		"%5.5lld",
+		"%+22.33lld",
+		"%01.3lld",
+		"%1.5lld",
+		"%-1.5lld",
+		"%44lld",
+		"%lld",
+		NULL
+	};
+	LLONG llong_val[] = {
+#ifdef LLONG_MAX
+		LLONG_MAX,
+#endif	/* LLONG_MAX */
+#ifdef LLONG_MIN
+		LLONG_MIN,
+#endif	/* LLONG_MIN */
+		-91340,
+		91340,
+		341,
+		134,
+		0203,
+		-1,
+		1,
+		0
+	};
+	const char *string_fmt[] = {
+		"foo|%10.10s|bar",
+		"%-10.10s",
+		"%10.10s",
+		"%10.5s",
+		"%5.10s",
+		"%10.1s",
+		"%1.10s",
+		"%10.0s",
+		"%0.10s",
+		"%-42.5s",
+		"%2.s",
+		"%.10s",
+		"%.1s",
+		"%.0s",
+		"%.s",
+		"%4s",
+		"%s",
+		NULL
+	};
+	const char *string_val[] = {
+		"Hello",
+		"Hello, world!",
+		"Sound check: One, two, three.",
+		"This string is a little longer than the other strings.",
+		"1",
+		"",
+		NULL
+	};
+#if !OS_SYSV	/* SysV uses a different format than we do. */
+	const char *pointer_fmt[] = {
+		"foo|%p|bar",
+		"%42p",
+		"%p",
+		NULL
+	};
+	const char *pointer_val[] = {
+		*pointer_fmt,
+		*string_fmt,
+		*string_val,
+		NULL
+	};
+#endif	/* !OS_SYSV */
+	char buf1[1024], buf2[1024];
+	double value, digits = 9.123456789012345678901234567890123456789;
+	int i, j, r1, r2, failed = 0, num = 0;
+
+/*
+ * Use -DTEST_NILS in order to also test the conversion of nil values.  Might
+ * segfault on systems which don't support converting a NULL pointer with "%s"
+ * and lets some test cases fail against BSD and glibc due to bugs in their
+ * implementations.
+ */
+#ifndef TEST_NILS
+#define TEST_NILS 0
+#elif TEST_NILS
+#undef TEST_NILS
+#define TEST_NILS 1
+#endif	/* !defined(TEST_NILS) */
+#ifdef TEST
+#undef TEST
+#endif	/* defined(TEST) */
+#define TEST(fmt, val)                                                         \
+do {                                                                           \
+	for (i = 0; fmt[i] != NULL; i++)                                       \
+		for (j = 0; j == 0 || val[j - TEST_NILS] != 0; j++) {          \
+			r1 = sprintf(buf1, fmt[i], val[j]);                    \
+			r2 = snprintf(buf2, sizeof(buf2), fmt[i], val[j]);     \
+			if (strcmp(buf1, buf2) != 0 || r1 != r2) {             \
+				(void)printf("Results don't match, "           \
+				    "format string: %s\n"                      \
+				    "\t sprintf(3): [%s] (%d)\n"               \
+				    "\tsnprintf(3): [%s] (%d)\n",              \
+				    fmt[i], buf1, r1, buf2, r2);               \
+				failed++;                                      \
+			}                                                      \
+			num++;                                                 \
+		}                                                              \
+} while (/* CONSTCOND */ 0)
+
+#if HAVE_LOCALE_H
+	(void)setlocale(LC_ALL, "");
+#endif	/* HAVE_LOCALE_H */
+
+	(void)puts("Testing our snprintf(3) against your system's sprintf(3).");
+	TEST(float_fmt, float_val);
+	TEST(long_fmt, long_val);
+	TEST(ulong_fmt, ulong_val);
+	TEST(llong_fmt, llong_val);
+	TEST(string_fmt, string_val);
+#if !OS_SYSV	/* SysV uses a different format than we do. */
+	TEST(pointer_fmt, pointer_val);
+#endif	/* !OS_SYSV */
+	(void)printf("Result: %d out of %d tests failed.\n", failed, num);
+
+	(void)fputs("Checking how many digits we support: ", stdout);
+	for (i = 0; i < 100; i++) {
+		value = pow(10, i) * digits;
+		(void)sprintf(buf1, "%.1f", value);
+		(void)snprintf(buf2, sizeof(buf2), "%.1f", value);
+		if (strcmp(buf1, buf2) != 0) {
+			(void)printf("apparently %d.\n", i);
+			break;
+		}
+	}
+	return (failed == 0) ? 0 : 1;
 }
-#else
-int snprintf_bs;
-#endif
+#endif	/* TEST_SNPRINTF */
+
+/* vim: set joinspaces textwidth=80: */

==== ntpd/ntp_io.c ====
2011-04-11 21:24:10+00:00, davehart at shiny.ad.hartbrothers.com +3 -1
  Add #ifdef REFCLOCK to quiet input_handler() unused locals warning.

--- 1.351/ntpd/ntp_io.c	2011-04-05 03:05:45 -04:00
+++ 1.352/ntpd/ntp_io.c	2011-04-11 17:24:10 -04:00
@@ -3333,10 +3333,12 @@ input_handler(
 #endif
 	fd_set		fds;
 	size_t		select_count;
+	endpt *		ep;
+#ifdef REFCLOCK
 	struct refclockio *rp;
 	int		saved_errno;
 	const char *	clk;
-	endpt *		ep;
+#endif
 #ifdef HAS_ROUTING_SOCKET
 	struct asyncio_reader *asyncio_reader;
 #endif

==== ntpdate/ntpdate.c ====
2011-04-11 21:24:10+00:00, davehart at shiny.ad.hartbrothers.com +0 -51
  vsprintf() is required by ANSI C, remove fallback implementation.
  Remove #if 0'd signal_no_reset() replacement.

--- 1.87/ntpdate/ntpdate.c	2011-04-05 03:05:47 -04:00
+++ 1.88/ntpdate/ntpdate.c	2011-04-11 17:24:10 -04:00
@@ -2182,57 +2182,6 @@ printserver(
 			   lfptoa(&pp->offset, 6));
 }
 
-#if !defined(HAVE_VSPRINTF)
-int
-vsprintf(
-	char *str,
-	const char *fmt,
-	va_list ap
-	)
-{
-	FILE f;
-	int len;
-
-	f._flag = _IOWRT+_IOSTRG;
-	f._ptr = str;
-	f._cnt = 32767;
-	len = _doprnt(fmt, ap, &f);
-	*f._ptr = 0;
-	return (len);
-}
-#endif
-
-#if 0
-/* override function in library since SA_RESTART makes ALL syscalls restart */
-#ifdef SA_RESTART
-void
-signal_no_reset(
-	int sig,
-	void (*func)()
-	)
-{
-	int n;
-	struct sigaction vec;
-
-	vec.sa_handler = func;
-	sigemptyset(&vec.sa_mask);
-	vec.sa_flags = 0;
-
-	while (1)
-	{
-		n = sigaction(sig, &vec, NULL);
-		if (n == -1 && errno == EINTR)
-			continue;
-		break;
-	}
-	if (n == -1)
-	{
-		perror("sigaction");
-		exit(1);
-	}
-}
-#endif
-#endif
 
 #ifdef HAVE_NETINFO
 static ni_namelist *

==== ntpq/ntpq.c ====
2011-04-11 21:24:10+00:00, davehart at shiny.ad.hartbrothers.com +2 -2
  Correct printf() format mismatch on 64-bit systems.

--- 1.136/ntpq/ntpq.c	2011-04-09 02:20:31 -04:00
+++ 1.137/ntpq/ntpq.c	2011-04-11 17:24:10 -04:00
@@ -917,8 +917,8 @@ getresponse(
 		shouldbesize = (CTL_HEADER_LEN + count + 3) & ~3;
 
 		if (n < shouldbesize) {
-			printf("Response packet claims %u octets payload, above %d received\n",
-			       count, n - CTL_HEADER_LEN);
+			printf("Response packet claims %u octets payload, above %ld received\n",
+			       count, (long)n - CTL_HEADER_LEN);
 			return ERR_INCOMPLETE;
 		}
 

==== parseutil/Makefile.am ====
2011-04-11 21:24:10+00:00, davehart at shiny.ad.hartbrothers.com +1 -1
  dcfd needs libntp.a when using rpl_snprintf().

--- 1.15/parseutil/Makefile.am	2011-02-22 01:06:26 -05:00
+++ 1.16/parseutil/Makefile.am	2011-04-11 17:24:10 -04:00
@@ -10,7 +10,7 @@ AM_CFLAGS = $(CFLAGS_NTP)
 AM_CPPFLAGS  = $(NTP_INCS)
 AM_CPPFLAGS += $(CPPFLAGS_NTP)
 
-LDADD = $(LDADD_LIBNTP)
+LDADD = ../libntp/libntp.a $(LDADD_LIBNTP)
 
 ETAGS_ARGS = Makefile.am
 DISTCLEANFILES = $(EXTRA_PROGRAMS)

==== ports/winnt/include/config.h ====
2011-04-11 21:24:11+00:00, davehart at shiny.ad.hartbrothers.com +23 -24
  On systems without C99-compliant (v)snprintf(), use C99-snprintf
    replacements.  (http://www.jhweiss.de/software/snprintf.html)
  Remove unused MAXHOSTNAMELEN.

--- 1.94/ports/winnt/include/config.h	2011-04-07 22:02:46 -04:00
+++ 1.95/ports/winnt/include/config.h	2011-04-11 17:24:11 -04:00
@@ -246,7 +246,6 @@ typedef int socklen_t;
 #define TYPEOF_IP_MULTICAST_LOOP	BOOL
 #define SETSOCKOPT_ARG_CAST		(const char *)
 #define HAVE_RANDOM 
-#define MAXHOSTNAMELEN			64
 #define AUTOKEY
 #define SAVECONFIG			1
 
@@ -358,7 +357,6 @@ typedef __int32 int32_t;	/* define a typ
 # define NTP_POSIX_SOURCE
 
 # define SYSLOG_FILE			/* from libntp.mak */
-# define HAVE_GETCLOCK
 
 # define SIZEOF_SIGNED_CHAR	1
 # define SIZEOF_SHORT		2
@@ -366,49 +364,50 @@ typedef __int32 int32_t;	/* define a typ
 # define SIZEOF_LONG		4
 # define SIZEOF_LONG_LONG	8
 
-# define HAVE_ALLOCA
-# define HAVE_SETVBUF
-# define HAVE_VPRINTF
-# define HAVE_VSPRINTF
-# define HAVE_SNPRINTF
-# define HAVE_VSNPRINTF
-# define HAVE_MEMMOVE
-# define HAVE_TERMIOS_H
-# define HAVE_ERRNO_H
-# define HAVE_STDARG_H
-# define HAVE_NO_NICE
-# define HAVE_MKTIME
-# define HAVE_TIMEGM			/* actually _mkgmtime */
+# define HAVE_ERRNO_H			1
+# define HAVE_FCNTL_H			1
+# define HAVE_LIMITS_H			1
+# define HAVE_STDARG_H			1
+# define HAVE_SYS_RESOURCE_H		1
+# define HAVE_SYS_TIME_H		1
+# define HAVE_TERMIOS_H			1
+
+# define HAVE_ALLOCA			1
+# define HAVE_GETCLOCK			1
+# define HAVE_MEMMOVE			1
+# define HAVE_MKTIME			1
+# define HAVE_SETVBUF			1
+# define HAVE_STRCHR			1	/* for libopts */
+# define HAVE_STRDUP			1
+# define HAVE_TIMEGM			1	/* actually _mkgmtime */
+
 # define HAVE_STRUCT_TIMESPEC
-# define HAVE_SYS_TIME_H
 # define HAVE_IO_COMPLETION_PORT
 # define ISC_PLATFORM_NEEDNTOP
 # define ISC_PLATFORM_NEEDPTON
 
-#define HAVE_LIMITS_H	1
-#define HAVE_STRDUP
-#define HAVE_STRCHR			/* for libopts */
-#define HAVE_FCNTL_H	1
-#define HAVE_SYS_RESOURCE_H
 #define HAVE_BSD_NICE			/* emulate BSD setpriority() */
 
+#define HW_WANT_RPL_VSNPRINTF		1
+#define HW_WANT_RPL_SNPRINTF		1
+
 typedef char *caddr_t;
 
 #ifdef _WCTYPE_T_DEFINED	/* see vc/include/crtdefs.h */
-#define HAVE_WINT_T
+#define HAVE_WINT_T			1
 #endif
 
 #ifndef _INTPTR_T_DEFINED
 typedef long intptr_t;
 #define _INTPTR_T_DEFINED
 #endif
-#define HAVE_INTPTR_T
+#define HAVE_INTPTR_T			1
 
 #ifndef _UINTPTR_T_DEFINED
 typedef unsigned long uintptr_t;
 #define _UINTPTR_T_DEFINED
 #endif
-#define HAVE_UINTPTR_T
+#define HAVE_UINTPTR_T			1
 
 #if !defined( _W64 )
   /*

==== ports/winnt/ntpd/hopf_PCI_io.c ====
2011-04-11 21:24:11+00:00, davehart at shiny.ad.hartbrothers.com +6 -0
  #ifdef away unused code.

--- 1.7/ports/winnt/ntpd/hopf_PCI_io.c	2010-02-02 23:58:31 -05:00
+++ 1.8/ports/winnt/ntpd/hopf_PCI_io.c	2011-04-11 17:24:11 -04:00
@@ -135,6 +135,7 @@ ReadHopfDevice(void)
 }
 
 
+#ifdef NOTUSED
 void
 GetHardwareData(
 	LPDWORD	Data32,
@@ -147,6 +148,7 @@ GetHardwareData(
 	ReadHopfDevice();
 	*Data32 = iobuffer[0];
 }
+#endif	/* NOTUSED */
 
 
 void
@@ -194,6 +196,7 @@ GetHopfTime(
 }
 
 
+#ifdef NOTUSED
 void
 GetHopfLocalTime(
 	LPHOPFTIME Data
@@ -203,6 +206,7 @@ GetHopfLocalTime(
 
 	GetHopfTime(Data, Offset);
 }
+#endif	/* NOTUSED */
 
 
 void
@@ -216,6 +220,7 @@ GetHopfSystemTime(
 }
 
 
+#ifdef NOTUSED
 void
 GetSatData(
 	LPSATSTAT Data
@@ -324,4 +329,5 @@ GetDCFAntenne(
 	Data->bStatus	= LOBYTE(HIWORD(iobuffer[0]));
 	Data->wAntValue	= LOWORD(iobuffer[0]);
 }
+#endif	/* NOTUSED */
 

==== ports/winnt/vc6/libntp.dsp ====
2011-04-11 21:24:11+00:00, davehart at shiny.ad.hartbrothers.com +4 -0
  add libntp/snprintf.c reference.

--- 1.62/ports/winnt/vc6/libntp.dsp	2011-04-05 03:05:48 -04:00
+++ 1.63/ports/winnt/vc6/libntp.dsp	2011-04-11 17:24:11 -04:00
@@ -390,6 +390,10 @@ SOURCE=..\libntp\SetSystemTime.c
 # End Source File
 # Begin Source File
 
+SOURCE=..\..\..\libntp\snprintf.c
+# End Source File
+# Begin Source File
+
 SOURCE=..\..\..\lib\isc\sockaddr.c
 # End Source File
 # Begin Source File

==== ports/winnt/vs2003/libntp.vcproj ====
2011-04-11 21:24:11+00:00, davehart at shiny.ad.hartbrothers.com +4 -344
  add libntp/snprintf.c reference.

--- 1.20/ports/winnt/vs2003/libntp.vcproj	2011-04-05 03:05:48 -04:00
+++ 1.21/ports/winnt/vs2003/libntp.vcproj	2011-04-11 17:24:11 -04:00
@@ -1144,66 +1144,12 @@
 			</File>
 			<File
 				RelativePath="..\..\..\lib\isc\netaddr.c">
-				<FileConfiguration
-					Name="Debug|Win32">
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="0"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""
-						BasicRuntimeChecks="3"
-						BrowseInformation="1"/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Win32">
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="2"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""/>
-				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\..\libntp\netof.c">
-				<FileConfiguration
-					Name="Debug|Win32">
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="0"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""
-						BasicRuntimeChecks="3"
-						BrowseInformation="1"/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Win32">
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="2"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""/>
-				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\..\lib\isc\netscope.c">
-				<FileConfiguration
-					Name="Debug|Win32">
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="0"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""
-						BasicRuntimeChecks="3"
-						BrowseInformation="1"/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Win32">
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="2"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""/>
-				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\..\libntp\ntp_calendar.c">
@@ -1213,24 +1159,6 @@
 			</File>
 			<File
 				RelativePath="..\..\..\libntp\ntp_lineedit.c">
-				<FileConfiguration
-					Name="Debug|Win32">
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="0"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""
-						BasicRuntimeChecks="3"
-						BrowseInformation="1"/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Win32">
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="2"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""/>
-				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\..\libntp\ntp_libopts.c">
@@ -1249,195 +1177,36 @@
 			</File>
 			<File
 				RelativePath="..\..\..\libntp\numtohost.c">
-				<FileConfiguration
-					Name="Debug|Win32">
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="0"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""
-						BasicRuntimeChecks="3"
-						BrowseInformation="1"/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Win32">
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="2"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""/>
-				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\..\libntp\octtoint.c">
-				<FileConfiguration
-					Name="Debug|Win32">
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="0"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""
-						BasicRuntimeChecks="3"
-						BrowseInformation="1"/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Win32">
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="2"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""/>
-				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\..\lib\isc\win32\once.c">
-				<FileConfiguration
-					Name="Debug|Win32">
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="0"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""
-						BasicRuntimeChecks="3"
-						BrowseInformation="1"/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Win32">
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="2"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""/>
-				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\..\lib\isc\ondestroy.c">
 			</File>
 			<File
 				RelativePath="..\..\..\libntp\prettydate.c">
-				<FileConfiguration
-					Name="Debug|Win32">
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="0"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""
-						BasicRuntimeChecks="3"
-						BrowseInformation="1"/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Win32">
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="2"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""/>
-				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\libntp\randfile.c">
-				<FileConfiguration
-					Name="Debug|Win32">
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="0"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""
-						BasicRuntimeChecks="3"
-						BrowseInformation="1"/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Win32">
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="2"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""/>
-				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\..\libntp\recvbuff.c">
-				<FileConfiguration
-					Name="Debug|Win32">
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="0"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""
-						BasicRuntimeChecks="3"
-						BrowseInformation="1"/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Win32">
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="2"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""/>
-				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\..\libntp\refnumtoa.c">
-				<FileConfiguration
-					Name="Debug|Win32">
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="0"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""
-						BasicRuntimeChecks="3"
-						BrowseInformation="1"/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Win32">
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="2"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""/>
-				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\libntp\setpriority.c">
-				<FileConfiguration
-					Name="Debug|Win32">
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="0"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""
-						BasicRuntimeChecks="3"
-						BrowseInformation="1"/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Win32">
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="2"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""/>
-				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\libntp\SetSystemTime.c">
-				<FileConfiguration
-					Name="Debug|Win32">
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="0"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""
-						BasicRuntimeChecks="3"
-						BrowseInformation="1"/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Win32">
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="2"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""/>
-				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\..\libntp\snprintf.c">
 			</File>
 			<File
 				RelativePath="..\..\..\lib\isc\sockaddr.c">
@@ -1447,94 +1216,21 @@
 			</File>
 			<File
 				RelativePath="..\..\..\libntp\socktoa.c">
-				<FileConfiguration
-					Name="Debug|Win32">
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="0"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""
-						BasicRuntimeChecks="3"
-						BrowseInformation="1"/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Win32">
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="2"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""/>
-				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\..\libntp\socktohost.c">
-				<FileConfiguration
-					Name="Debug|Win32">
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="0"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""
-						BasicRuntimeChecks="3"
-						BrowseInformation="1"/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Win32">
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="2"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""/>
-				</FileConfiguration>
 			</File>
 			<File
-				RelativePath="..\..\..\libntp\ssl_init.c"
-				>
+				RelativePath="..\..\..\libntp\ssl_init.c">
 			</File>
 			<File
 				RelativePath="..\..\..\libntp\statestr.c">
-				<FileConfiguration
-					Name="Debug|Win32">
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="0"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""
-						BasicRuntimeChecks="3"
-						BrowseInformation="1"/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Win32">
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="2"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""/>
-				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\..\lib\isc\win32\stdtime.c">
 			</File>
 			<File
 				RelativePath="..\..\..\lib\isc\win32\strerror.c">
-				<FileConfiguration
-					Name="Debug|Win32">
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="0"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""
-						BasicRuntimeChecks="3"
-						BrowseInformation="1"/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Win32">
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="2"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""/>
-				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\..\libntp\strl_obsd.c">
@@ -1544,45 +1240,9 @@
 			</File>
 			<File
 				RelativePath="..\..\..\libntp\syssignal.c">
-				<FileConfiguration
-					Name="Debug|Win32">
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="0"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""
-						BasicRuntimeChecks="3"
-						BrowseInformation="1"/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Win32">
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="2"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""/>
-				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\..\libntp\systime.c">
-				<FileConfiguration
-					Name="Debug|Win32">
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="0"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""
-						BasicRuntimeChecks="3"
-						BrowseInformation="1"/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Win32">
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="2"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""/>
-				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\..\lib\isc\task.c">

==== ports/winnt/vs2005/libntp.vcproj ====
2011-04-11 21:24:11+00:00, davehart at shiny.ad.hartbrothers.com +4 -0
  add libntp/snprintf.c reference.

--- 1.18/ports/winnt/vs2005/libntp.vcproj	2011-04-05 03:05:48 -04:00
+++ 1.19/ports/winnt/vs2005/libntp.vcproj	2011-04-11 17:24:11 -04:00
@@ -469,6 +469,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\..\libntp\snprintf.c"
+				>
+			</File>
+			<File
 				RelativePath="..\..\..\lib\isc\sockaddr.c"
 				>
 			</File>

==== ports/winnt/vs2008/libntp/libntp.vcproj ====
2011-04-11 21:24:11+00:00, davehart at shiny.ad.hartbrothers.com +6 -2
  add libntp/snprintf.c reference.

--- 1.41/ports/winnt/vs2008/libntp/libntp.vcproj	2011-04-05 03:05:48 -04:00
+++ 1.42/ports/winnt/vs2008/libntp/libntp.vcproj	2011-04-11 17:24:11 -04:00
@@ -484,6 +484,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\..\..\libntp\snprintf.c"
+				>
+			</File>
+			<File
 				RelativePath="..\..\..\..\lib\isc\sockaddr.c"
 				>
 			</File>
@@ -901,11 +905,11 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\..\lib\isc\win32\include\isc\time.h"
+				RelativePath="..\..\include\sys\time.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\include\sys\time.h"
+				RelativePath="..\..\..\..\lib\isc\win32\include\isc\time.h"
 				>
 			</File>
 			<File

==== sntp/configure.ac ====
2011-04-11 21:24:11+00:00, davehart at shiny.ad.hartbrothers.com +1 -1
  On systems without C99-compliant (v)snprintf(), use C99-snprintf
    replacements.  (http://www.jhweiss.de/software/snprintf.html)

--- 1.58/sntp/configure.ac	2011-02-22 01:06:26 -05:00
+++ 1.58.1.1/sntp/configure.ac	2011-04-11 17:24:11 -04:00
@@ -105,7 +105,7 @@ AC_DEFINE([HAVE_NO_NICE], 1, [sntp does 
 AC_DEFINE([HAVE_TERMIOS], 1, [sntp does not care about TTY stuff])
 
 # Checks for library functions.
-AC_CHECK_FUNCS([socket vsnprintf vsprintf])
+AC_CHECK_FUNCS([socket])
 
 # HMS: if we don't find c++ we should not look for gtest.
 AC_PROG_CXX

==== sntp/m4/ntp_libntp.m4 ====
2011-04-11 21:24:11+00:00, davehart at shiny.ad.hartbrothers.com +27 -1
  On systems without C99-compliant (v)snprintf(), use C99-snprintf
    replacements.  (http://www.jhweiss.de/software/snprintf.html)

--- 1.9/sntp/m4/ntp_libntp.m4	2011-04-05 03:05:48 -04:00
+++ 1.9.1.1/sntp/m4/ntp_libntp.m4	2011-04-11 17:24:11 -04:00
@@ -40,6 +40,32 @@ NTP_LIB_M
 AC_FUNC_FORK
 AC_FUNC_ALLOCA
 
+AC_DEFUN([NTP_BEFORE_HW_FUNC_VSNPRINTF], [
+AC_BEFORE([$0], [HW_FUNC_VSNPRINTF])
+AC_BEFORE([$0], [HW_FUNC_SNPRINTF])
+AC_ARG_ENABLE(
+    [c99-snprintf],
+    [AS_HELP_STRING([--enable-c99-snprintf], [s force replacement])],
+    [force_c99_snprintf=$enableval],
+    [force_c99_snprintf=no]
+    )
+case "$force_c99_snprintf" in
+ yes)
+    hw_force_rpl_snprintf=yes
+    hw_force_rpl_vsnprintf=yes
+esac
+hw_nodef_snprintf=yes
+hw_nodef_vsnprintf=yes
+]) dnl end of AC_DEFUN of NTP_BEFORE_HW_FUNC_VSNPRINTF
+
+AC_DEFUN([NTP_C99_SNPRINTF], [
+AC_REQUIRE([NTP_BEFORE_HW_FUNC_VSNPRINTF])
+AC_REQUIRE([HW_FUNC_VSNPRINTF])
+AC_REQUIRE([HW_FUNC_SNPRINTF])
+]) dnl end of DEFUN of NTP_C99_SNPRINTF
+
+NTP_C99_SNPRINTF
+
 ac_busted_vpath_in_make=no
 case "$build" in
  *-*-irix6.1*)	# 64 bit only
@@ -298,7 +324,7 @@ AC_CHECK_HEADERS([semaphore.h])
 AC_CHECK_FUNCS([socketpair])
 AC_ARG_ENABLE(
     [thread-support],
-    [AS_HELP_STRING([--disable-thread-support, do not use threads])],
+    [AS_HELP_STRING([--disable-thread-support], [s do not use threads])],
     [],
     [enable_thread_support=yes]
     )

==== sntp/m4/snprintf.m4 ====
2011-04-11 21:24:11+00:00, davehart at shiny.ad.hartbrothers.com +293 -0
  BitKeeper file C:/ntp/ntp-dev-C99-snprintf/sntp/m4/snprintf.m4
  ---
  Adapt snprintf.m4 for integration in NTP.

--- /dev/null	2011-04-13 00:29:13 -04:00
+++ 1.1/sntp/m4/snprintf.m4	2011-04-11 17:24:11 -04:00
@@ -0,0 +1,293 @@
+# Modified by Dave Hart for integration into NTP 4.2.7 <hart at ntp.org>
+#
+# Changed in a backwards-incompatible way to separate HAVE_SNPRINTF from
+# HW_WANT_RPL_SNPRINTF, etc. for each of the four replaced functions.
+# HAVE_* will always be set if the corresponding HW_FUNC_* macro is
+# invoked, directly or indirectly.  This allows 3rd-party modules like
+# libopts to avoid their own replacement of snprintf.
+#
+# Changed to honor hw_nodef_snprintf, etc. which prevent config.h from
+# aliasing snprintf to rpl_snprintf, etc.  NTP uses this to defer that
+# definition until after system include files to avoid problems seen
+# on Linux building sntp/tests:
+# /usr/include/c++/4.4/cstdio:165: error: '::snprintf' has not been declared
+# This cstdio #undef's snprintf and then re-declares ::snprintf, however
+# the earlier stdio.h had its declarations aliased to rpl_snprintf, etc.
+#
+# Changed to honor hw_force_rpl_snprintf=yes, etc.  This is used by NTP
+# to test rpl_snprintf() and rpl_vsnprintf() on platforms which provide
+# C99-compliant implementations.
+#
+
+# $Id: snprintf.m4,v 1.1.1.1 2008/01/06 03:24:00 holger Exp $
+
+# Copyright (c) 2008 Holger Weiss <holger at jhweiss.de>.
+#
+# This code may freely be used, modified and/or redistributed for any purpose.
+# It would be nice if additions and fixes to this file (including trivial code
+# cleanups) would be sent back in order to let me include them in the version
+# available at <http://www.jhweiss.de/software/snprintf.html>.  However, this is
+# not a requirement for using or redistributing (possibly modified) versions of
+# this file, nor is leaving this notice intact mandatory.
+
+# HW_HEADER_STDARG_H
+# ------------------
+# Define HAVE_STDARG_H to 1 if <stdarg.h> is available.
+AC_DEFUN([HW_HEADER_STDARG_H],
+[
+  AC_PREREQ([2.60])dnl Older releases should work if AC_CHECK_HEADERS is used.
+  AC_CHECK_HEADERS_ONCE([stdarg.h])
+])# HW_HEADER_STDARG_H
+
+# HW_HEADER_VARARGS_H
+# -------------------
+# Define HAVE_VARARGS_H to 1 if <varargs.h> is available.
+AC_DEFUN([HW_HEADER_VARARGS_H],
+[
+  AC_PREREQ([2.60])dnl Older releases should work if AC_CHECK_HEADERS is used.
+  AC_CHECK_HEADERS_ONCE([varargs.h])
+])# HW_HEADER_VARARGS_H
+
+# HW_FUNC_VA_COPY
+# ---------------
+# Set $hw_cv_func_va_copy to "yes" or "no".  Define HAVE_VA_COPY to 1 if
+# $hw_cv_func_va_copy is set to "yes".  Note that it's "unspecified whether
+# va_copy and va_end are macros or identifiers declared with external linkage."
+# (C99: 7.15.1, 1)  Therefore, the presence of va_copy(3) cannot simply "be
+# tested with #ifdef", as suggested by the Autoconf manual (5.5.1).
+AC_DEFUN([HW_FUNC_VA_COPY],
+[
+  AC_REQUIRE([HW_HEADER_STDARG_H])dnl Our check evaluates HAVE_STDARG_H.
+  AC_REQUIRE([HW_HEADER_VARARGS_H])dnl Our check evaluates HAVE_VARARGS_H.
+  AC_CACHE_CHECK([for va_copy],
+    [hw_cv_func_va_copy],
+    [AC_RUN_IFELSE(
+      [AC_LANG_PROGRAM(
+        [[#if HAVE_STDARG_H
+        #include <stdarg.h>
+        #elif HAVE_VARARGS_H
+        #include <varargs.h>
+        #endif]],
+        [[va_list ap, aq; va_copy(aq, ap);]])],
+      [hw_cv_func_va_copy=yes],
+      [hw_cv_func_va_copy=no],
+      [hw_cv_func_va_copy=no])])
+  AS_IF([test "$hw_cv_func_va_copy" = yes],
+    [AC_DEFINE([HAVE_VA_COPY], [1],
+      [Define to 1 if you have the `va_copy' function or macro.])])
+])# HW_FUNC_VA_COPY
+
+# HW_FUNC___VA_COPY
+# -----------------
+# Set $hw_cv_func___va_copy to "yes" or "no".  Define HAVE___VA_COPY to 1 if
+# $hw_cv_func___va_copy is set to "yes".
+AC_DEFUN([HW_FUNC___VA_COPY],
+[
+  AC_REQUIRE([HW_HEADER_STDARG_H])dnl Our check evaluates HAVE_STDARG_H.
+  AC_REQUIRE([HW_HEADER_VARARGS_H])dnl Our check evaluates HAVE_VARARGS_H.
+  AC_CACHE_CHECK([for __va_copy],
+    [hw_cv_func___va_copy],
+    [AC_RUN_IFELSE(
+      [AC_LANG_PROGRAM(
+        [[#if HAVE_STDARG_H
+        #include <stdarg.h>
+        #elif HAVE_VARARGS_H
+        #include <varargs.h>
+        #endif]],
+        [[va_list ap, aq; __va_copy(aq, ap);]])],
+      [hw_cv_func___va_copy=yes],
+      [hw_cv_func___va_copy=no],
+      [hw_cv_func___va_copy=no])])
+  AS_IF([test "$hw_cv_func___va_copy" = yes],
+    [AC_DEFINE([HAVE___VA_COPY], [1],
+      [Define to 1 if you have the `__va_copy' function or macro.])])
+])# HW_FUNC___VA_COPY
+
+# HW_FUNC_VSNPRINTF
+# -----------------
+# Set $hw_cv_func_vsnprintf and $hw_cv_func_vsnprintf_c99 to "yes" or
+# "no", respectively.  If either $hw_force_rpl_vsnprintf is "yes" or
+# $hw_cv_func_vsnprintf_c99 is "no", define HW_WANT_RPL_VSNPRINTF and
+# define vsnprintf to rpl_vsnprintf.
+AC_DEFUN([HW_FUNC_VSNPRINTF],
+[
+  AC_PREREQ([2.60])dnl 2.59 should work if some AC_TYPE_* macros are replaced.
+  AC_REQUIRE([HW_HEADER_STDARG_H])dnl Our check evaluates HAVE_STDARG_H.
+  AC_CHECK_FUNC([vsnprintf],
+    [hw_cv_func_vsnprintf=yes],
+    [hw_cv_func_vsnprintf=no])
+  AS_IF([test "$hw_cv_func_vsnprintf" = yes],
+    [AC_CACHE_CHECK([whether vsnprintf is C99 compliant],
+      [hw_cv_func_vsnprintf_c99],
+      [AC_RUN_IFELSE(
+        [AC_LANG_PROGRAM(
+          [[#if HAVE_STDARG_H
+          #include <stdarg.h>
+          #endif
+          #include <stdio.h>
+          static int testprintf(char *buf, size_t size, const char *format, ...)
+          {
+            int result;
+            va_list ap;
+            va_start(ap, format);
+            result = vsnprintf(buf, size, format, ap);
+            va_end(ap);
+            return result;
+          }]],
+          [[char buf[43];
+          if (testprintf(buf, 4, "The answer is %27.2g.", 42.0) != 42 ||
+              testprintf(buf, 0, "No, it's %32zu.", (size_t)42) != 42 ||
+              buf[0] != 'T' || buf[3] != '\0')
+            return 1;]])],
+        [hw_cv_func_vsnprintf_c99=yes],
+        [hw_cv_func_vsnprintf_c99=no],
+        [hw_cv_func_vsnprintf_c99=no])])],
+    [hw_cv_func_vsnprintf_c99=no])
+  AC_DEFINE([HAVE_VSNPRINTF], [1],
+      [Define if C99-compliant `vsnprintf' is available.])
+  AC_MSG_CHECKING([if C99-snprintf replacement vsnprintf will be used])
+  AS_IF([test "${hw_force_rpl_vsnprintf=no}" = yes -o "$hw_cv_func_vsnprintf_c99" = no],
+    [hw_use_rpl_vsnprintf=yes],
+    [hw_use_rpl_vsnprintf=no])
+  AC_MSG_RESULT([$hw_use_rpl_vsnprintf])
+  AS_IF([test "$hw_use_rpl_vsnprintf" = yes],
+    [AC_DEFINE([HW_WANT_RPL_VSNPRINTF], [1],
+      [Define to provide `rpl_vsnprintf' function.])
+    AS_IF([test ${hw_nodef_vsnprintf=yes} = no],
+      [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_MEMBERS([struct lconv.decimal_point, struct lconv.thousands_sep],
+      [], [], [#include <locale.h>])
+    AC_TYPE_LONG_DOUBLE
+    AC_TYPE_LONG_LONG_INT
+    AC_TYPE_UNSIGNED_LONG_LONG_INT
+    AC_TYPE_SIZE_T
+    AC_TYPE_INTMAX_T
+    AC_TYPE_UINTMAX_T
+    AC_TYPE_UINTPTR_T
+    AC_CHECK_TYPES([ptrdiff_t])
+    AC_CHECK_FUNCS([localeconv])
+    _HW_FUNC_XPRINTF_REPLACE])
+])# HW_FUNC_VSNPRINTF
+
+# HW_FUNC_SNPRINTF
+# ----------------
+# Set $hw_cv_func_snprintf and $hw_cv_func_snprintf_c99 to "yes" or
+# "no", respectively.  If either $hw_force_rpl_snprintf is "yes" or
+# $hw_cv_func_snprintf_c99 is "no", define HW_WANT_RPL_SNPRINTF and
+# define snprintf to rpl_snprintf.
+# The same will be done for vsnprintf, as if HW_FUNC_VSNPRINTF were
+# used.
+AC_DEFUN([HW_FUNC_SNPRINTF],
+[
+  AC_REQUIRE([HW_FUNC_VSNPRINTF])dnl Our snprintf(3) calls vsnprintf(3).
+  AC_CHECK_FUNC([snprintf],
+    [hw_cv_func_snprintf=yes],
+    [hw_cv_func_snprintf=no])
+  AS_IF([test "$hw_cv_func_snprintf" = yes],
+    [AC_CACHE_CHECK([whether snprintf is C99 compliant],
+      [hw_cv_func_snprintf_c99],
+      [AC_RUN_IFELSE(
+        [AC_LANG_PROGRAM([[#include <stdio.h>]],
+          [[char buf[43];
+          if (snprintf(buf, 4, "The answer is %27.2g.", 42.0) != 42 ||
+              snprintf(buf, 0, "No, it's %32zu.", (size_t)42) != 42 ||
+              buf[0] != 'T' || buf[3] != '\0')
+            return 1;]])],
+        [hw_cv_func_snprintf_c99=yes],
+        [hw_cv_func_snprintf_c99=no],
+        [hw_cv_func_snprintf_c99=no])])],
+    [hw_cv_func_snprintf_c99=no])
+  AC_DEFINE([HAVE_SNPRINTF], [1],
+      [Define if C99-compliant `snprintf' is available.])
+  AC_MSG_CHECKING([if C99-snprintf replacement snprintf will be used])
+  AS_IF([test "${hw_force_rpl_snprintf=no}" = yes -o "$hw_cv_func_snprintf_c99" = no],
+    [hw_use_rpl_snprintf=yes],
+    [hw_use_rpl_snprintf=no])
+  AC_MSG_RESULT([$hw_use_rpl_snprintf])
+  AS_IF([test "$hw_use_rpl_snprintf" = yes],
+    [AC_DEFINE([HW_WANT_RPL_SNPRINTF], [1],
+      [Define to provide `rpl_snprintf' function.])
+    AS_IF([test ${hw_nodef_snprintf=yes} = no],
+      [AC_DEFINE([snprintf], [rpl_snprintf],
+        [Define to rpl_snprintf if the replacement function should be used.])])
+    _HW_FUNC_XPRINTF_REPLACE])
+])# HW_FUNC_SNPRINTF
+
+# HW_FUNC_VASPRINTF
+# -----------------
+# Set $hw_cv_func_vasprintf to "yes" or "no".  If either
+# $hw_force_rpl_vasprintf is "yes" or $hw_cv_func_vasprintf is "no",
+# define HW_WANT_RPL_VASPRINTF and define vasprintf to rpl_vasprintf.
+# The same will be done for vsnprintf, as if HW_FUNC_VSNPRINTF were
+# used.
+AC_DEFUN([HW_FUNC_VASPRINTF],
+[
+  AC_REQUIRE([HW_FUNC_VSNPRINTF])dnl Our vasprintf(3) calls vsnprintf(3).
+  AC_CHECK_FUNCS([vasprintf],
+    [hw_cv_func_vasprintf=yes],
+    [hw_cv_func_vasprintf=no])
+  AC_DEFINE([HAVE_VASPRINTF], [1],
+      [Define if `vasprintf' is available.])
+  AC_MSG_CHECKING([if C99-snprintf replacement vasprintf will be used])
+  AS_IF([test "${hw_force_rpl_vasprintf=no}" = yes -o "$hw_cv_func_vasprintf" = no],
+    [hw_use_rpl_vasprintf=yes],
+    [hw_use_rpl_vasprintf=no])
+  AC_MSG_RESULT([$hw_use_rpl_vasprintf])
+  AS_IF([test "$hw_use_rpl_vasprintf" = yes],
+    [AC_DEFINE([HW_WANT_RPL_VASPRINTF], [1],
+      [Define to provide `rpl_vasprintf' function.])
+    AS_IF([test ${hw_nodef_vasprintf=yes} = no],
+      [AC_DEFINE([vasprintf], [rpl_vasprintf],
+      [Define to rpl_vasprintf if the replacement function should be used.])])
+    AC_CHECK_HEADERS([stdlib.h])
+    HW_FUNC_VA_COPY
+    AS_IF([test "$hw_cv_func_va_copy" = no],
+      [HW_FUNC___VA_COPY])
+    _HW_FUNC_XPRINTF_REPLACE])
+])# HW_FUNC_VASPRINTF
+
+# HW_FUNC_ASPRINTF
+# ----------------
+# Set $hw_cv_func_asprintf to "yes" or "no".  If either
+# $hw_force_rpl_asprintf is "yes" or $hw_cv_func_asprintf is "no",
+# define HW_WANT_RPL_ASPRINTF and define asprintf to rpl_asprintf.
+# The same will be done for vasprintf, as if HW_FUNC_VASPRINTF were
+# used.
+AC_DEFUN([HW_FUNC_ASPRINTF],
+[
+  AC_REQUIRE([HW_FUNC_VASPRINTF])dnl Our asprintf(3) calls vasprintf(3).
+  AC_CHECK_FUNCS([asprintf],
+    [hw_cv_func_asprintf=yes],
+    [hw_cv_func_asprintf=no])
+  AC_DEFINE([HAVE_ASPRINTF], [1],
+      [Define if `asprintf' is available.])
+  AC_MSG_CHECKING([if C99-snprintf replacement asprintf will be used])
+  AS_IF([test "${hw_force_rpl_asprintf=no}" = yes -o "$hw_cv_func_asprintf" = no],
+    [hw_use_rpl_asprintf=yes],
+    [hw_use_rpl_asprintf=no])
+  AC_MSG_RESULT([$hw_use_rpl_asprintf])
+  AS_IF([test "$hw_use_rpl_asprintf" = yes],
+    [AC_DEFINE([HW_WANT_RPL_ASPRINTF], [1],
+      [Define to provide `rpl_asprintf' function.])
+    AS_IF([test ${hw_nodef_asprintf=yes} = no],
+      [AC_DEFINE([asprintf], [rpl_asprintf],
+      [Define to rpl_asprintf if the replacement function should be used.])])
+    _HW_FUNC_XPRINTF_REPLACE])
+])# HW_FUNC_ASPRINTF
+
+# _HW_FUNC_XPRINTF_REPLACE
+# ------------------------
+# Arrange for building snprintf.c.  Must be called if one or more of the
+# functions provided by snprintf.c are needed.
+AC_DEFUN([_HW_FUNC_XPRINTF_REPLACE],
+[
+  AS_IF([test "x$_hw_cv_func_xprintf_replace_done" != xyes],
+    [AC_C_CONST
+    HW_HEADER_STDARG_H
+    AC_LIBOBJ([snprintf])
+    _hw_cv_func_xprintf_replace_done=yes])
+])# _HW_FUNC_XPRINTF_REPLACE
+
+dnl vim: set joinspaces textwidth=80:

==== sntp/m4/snprintf.m4 ====
2011-04-11 21:24:11+00:00, davehart at shiny.ad.hartbrothers.com +0 -0


More information about the bk-ntp-dev-send mailing list