+Sat Mar 4 11:53:36 2006 Ben Pfaff <blp@gnu.org>
+
+ * acinclude.m4: Remove BLP_RANDOM. Its results were unused.
+ Remove BLP_IS_SPRINTF_GOOD. We now assume that the system's
+ sprintf() returns the correct value.
+
+ * configure.ac: Don't call those macros.
+
+John Darrington:
+
* Deleted Make.build (inserted its contents into Makefile.am).
* Moved the version number to 0.4.1
`long's.])
AC_MSG_RESULT($blp_int_digits) ])dnl
-dnl Check quality of this machine's sprintf implementation.
-
-AC_DEFUN([BLP_IS_SPRINTF_GOOD],
-[
-AC_MSG_CHECKING(if sprintf returns a char count)
-AC_CACHE_VAL(blp_is_sprintf_good,
- [AC_TRY_RUN([#include <stdio.h>
- int
- main()
- {
- char s[8];
- exit((int)sprintf(s, "abcdefg")!=7);
- }
- ],
- eval "blp_is_sprintf_good=yes",
- eval "blp_is_sprintf_good=no",
- eval "blp_is_sprintf_good=no")
- ])
-if test "$blp_is_sprintf_good" = yes; then
- AC_DEFINE([HAVE_GOOD_SPRINTF], 1,
- [Define if sprintf() returns the number of characters written
- to the destination string, excluding the null terminator.])
- AC_MSG_RESULT(yes)
-else
- AC_MSG_RESULT(no)
-fi
-])dnl
-
-dnl Check for proper random number generator.
-
-AC_DEFUN([BLP_RANDOM],
-[
-AC_MSG_CHECKING(random number generator)
-AC_CACHE_VAL(blp_random_good,
- AC_TRY_COMPILE([#include <stdlib.h>], [int x=RAND_MAX;],
- blp_random_good=yes, blp_random_good=no))
-if test "$blp_random_good" = yes; then
- AC_DEFINE([HAVE_GOOD_RANDOM], 1,
- [Define if rand() and company work according to ANSI.])
- AC_MSG_RESULT(good)
-else
- AC_MSG_RESULT(bad)
-fi
-])dnl
-
dnl Check for readline and history libraries.
dnl Modified for PSPP by Ben Pfaff, based on readline.m4 serial 3 from
AC_C_BIGENDIAN
-
-
-
-BLP_IS_SPRINTF_GOOD
BLP_INT_DIGITS
-BLP_RANDOM
AC_FUNC_VPRINTF
AC_CHECK_FUNCS([strchr strrchr __setfpucw isinf isnan finite getpid feholdexcept])
+John Darrington:
+
* Replaced '_' with '-' in most filenames.
* Renamed files as follows:
+Sat Mar 4 11:55:16 2006 Ben Pfaff <blp@gnu.org>
+
+ * str.h: Now assume that sprintf() returns the correct value.
+ Always implement spprintf as a static inline function. Change
+ nsprintf, nvsprintf to simple macros that call sprintf, vsprintf.
+
+ * str.c: Remove spprintf, nsprintf, nvsprintf conditional
+ definitions.
+
Thu Mar 2 08:40:33 WST 2006 John Darrington <john@darrington.wattle.id.au>
* Moved files from src directory
#include "alloc.h"
#include "message.h"
\f
-/* sprintf() wrapper functions for convenience. */
-
-#if !__GNUC__
-char *
-spprintf (char *buf, const char *format,...)
-{
-#if HAVE_GOOD_SPRINTF
- int count;
-#endif
- va_list args;
-
- va_start (args, format);
-#if HAVE_GOOD_SPRINTF
- count =
-#endif
- vsprintf (buf, format, args);
- va_end (args);
-
-#if HAVE_GOOD_SPRINTF
- return &buf[count];
-#else
- return strchr (buf, 0);
-#endif
-}
-#endif /* !__GNUC__ */
-
-#if !__GNUC__ && !HAVE_GOOD_SPRINTF
-int
-nsprintf (char *buf, const char *format,...)
-{
- va_list args;
-
- va_start (args, format);
- vsprintf (buf, format, args);
- va_end (args);
-
- return strlen (buf);
-}
-
-int
-nvsprintf (char *buf, const char *format, va_list args)
-{
- vsprintf (buf, format, args);
- return strlen (buf);
-}
-#endif /* Not GNU C and not good sprintf(). */
-\f
/* Reverses the order of NBYTES bytes at address P, thus converting
between little- and big-endian byte orders. */
void
#define strrchr rindex
#endif
\f
-/* sprintf() wrapper functions for convenience. */
-
-/* spprintf() calls sprintf() and returns the address of the null
- terminator in the resulting string. It should be portable the way
- it's been implemented. */
-#if __GNUC__
- #if HAVE_GOOD_SPRINTF
- #define spprintf(BUF, FORMAT, ARGS...) \
- ((BUF) + sprintf ((BUF), (FORMAT) , ## ARGS))
- #else
- #define spprintf(BUF, FORMAT, ARGS...) \
- ({ sprintf ((BUF), (FORMAT) , ## ARGS); \
- strchr ((BUF), 0); })
- #endif
-#else /* Not GNU C. */
- char *spprintf (char *buf, const char *format, ...);
-#endif /* Not GNU C. */
-
-/* nsprintf() calls sprintf() and returns the strlen() of the
- resulting string. It should be portable the way it's been
- implemented. */
-#if __GNUC__
- #if HAVE_GOOD_SPRINTF
- #define nsprintf(BUF, FORMAT, ARGS...) \
- (sprintf ((BUF), (FORMAT) , ## ARGS))
- #define nvsprintf(BUF, FORMAT, ARGS) \
- (vsprintf ((BUF), (FORMAT), (ARGS)))
- #else /* Not good sprintf(). */
- #define nsprintf(BUF, FORMAT, ARGS...) \
- ({ \
- char *pbuf = BUF; \
- sprintf ((pbuf), (FORMAT) , ## ARGS); \
- strlen (pbuf); \
- })
- #define nvsprintf(BUF, FORMAT, ARGS) \
- ({ \
- char *pbuf = BUF; \
- vsprintf ((pbuf), (FORMAT), (ARGS)); \
- strlen (pbuf); \
- })
- #endif /* Not good sprintf(). */
-#else /* Not GNU C. */
- #if HAVE_GOOD_SPRINTF
- #define nsprintf sprintf
- #define nvsprintf vsprintf
- #else /* Not good sprintf(). */
- int nsprintf (char *buf, const char *format, ...);
- int nvsprintf (char *buf, const char *format, va_list args);
- #endif /* Not good sprintf(). */
-#endif /* Not GNU C. */
-\f
/* Miscellaneous. */
void buf_reverse (char *, size_t);
}
#endif
+#define nsprintf sprintf
+#define nvsprintf vsprintf
+
+/* Formats FORMAT into DST, as with sprintf(), and returns the
+ address of the terminating null written to DST. */
+static inline char *
+spprintf (char *dst, const char *format, ...)
+{
+ va_list args;
+ int count;
+
+ va_start (args, format);
+ count = nvsprintf (dst, format, args);
+ va_end (args);
+
+ return dst + count;
+}
+
#endif /* str_h */