From: Ben Pfaff Date: Sat, 4 Mar 2006 20:15:32 +0000 (+0000) Subject: Remove BLP_RANDOM. Its results were unused. Remove X-Git-Tag: v0.6.0~1055 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cf4da7ffcb1c9f1016c4fa013deb8ce40c431e19;p=pspp-builds.git Remove BLP_RANDOM. Its results were unused. Remove BLP_IS_SPRINTF_GOOD. We now assume that the system's sprintf() returns the correct value. --- diff --git a/ChangeLog b/ChangeLog index c1ebc605..c7220fe7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Sat Mar 4 11:53:36 2006 Ben Pfaff + + * 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 diff --git a/acinclude.m4 b/acinclude.m4 index aa6e4d77..e45a9be4 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -38,51 +38,6 @@ AC_DEFINE_UNQUOTED([INT_DIGITS], $blp_int_digits, `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 - 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 ], [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 diff --git a/configure.ac b/configure.ac index d5c2a7c9..1528d72c 100644 --- a/configure.ac +++ b/configure.ac @@ -103,12 +103,7 @@ AC_DEFINE(FPREP_IEEE754, 1, 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]) diff --git a/src/ChangeLog b/src/ChangeLog index e649e803..3bee27f3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,5 @@ +John Darrington: + * Replaced '_' with '-' in most filenames. * Renamed files as follows: diff --git a/src/libpspp/ChangeLog b/src/libpspp/ChangeLog index 4a96aeb9..e78ba849 100644 --- a/src/libpspp/ChangeLog +++ b/src/libpspp/ChangeLog @@ -1,3 +1,12 @@ +Sat Mar 4 11:55:16 2006 Ben Pfaff + + * 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 * Moved files from src directory diff --git a/src/libpspp/str.c b/src/libpspp/str.c index 530d1cec..6b207ee2 100644 --- a/src/libpspp/str.c +++ b/src/libpspp/str.c @@ -26,53 +26,6 @@ #include "alloc.h" #include "message.h" -/* 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(). */ - /* Reverses the order of NBYTES bytes at address P, thus converting between little- and big-endian byte orders. */ void diff --git a/src/libpspp/str.h b/src/libpspp/str.h index 22adc29f..0b50b031 100644 --- a/src/libpspp/str.h +++ b/src/libpspp/str.h @@ -43,57 +43,6 @@ #define strrchr rindex #endif -/* 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. */ - /* Miscellaneous. */ void buf_reverse (char *, size_t); @@ -238,4 +187,22 @@ ds_end (const struct string *st) } #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 */