From: Howard Chu Date: Fri, 6 Sep 2002 20:54:22 +0000 (+0000) Subject: Remove dependencies on HAVE_VSNPRINTF, use replacement in liblutil/stdio.c X-Git-Tag: NO_SLAP_OP_BLOCKS~1014 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=4d8a2e2815a692084828afb8636e130d3db53b13;p=openldap Remove dependencies on HAVE_VSNPRINTF, use replacement in liblutil/stdio.c if needed. Same check for snprintf. --- diff --git a/configure.in b/configure.in index 8ac2dda8d1..2057f3d8b8 100644 --- a/configure.in +++ b/configure.in @@ -2420,7 +2420,7 @@ AC_FUNC_VPRINTF if test $ac_cv_func_vprintf = yes ; then dnl check for vsnprintf - AC_CHECK_FUNCS(vsnprintf vsprintf) + AC_CHECK_FUNCS(snprintf vsnprintf) fi AC_CHECK_FUNCS( \ @@ -2485,6 +2485,16 @@ AC_REPLACE_FUNCS(getopt) if test "$ac_cv_func_getopt" != yes; then LIBSRCS="$LIBSRCS getopt.c" fi +if test "$ac_cv_func_snprintf" != yes -o "$ac_cv_func_vsnprintf" != yes; then + LIBSRCS="$LIBSRCS stdio.c" + LIBOBJS="$LIBOBJS stdio.o" + if test "$ac_cv_func_snprintf" != yes; then + AC_DEFINE(snprintf, lutil_snprintf, [define to snprintf routine]) + fi + if test "$ac_cv_func_vsnprintf" != yes; then + AC_DEFINE(vsnprintf, lutil_vsnprintf, [define to snprintf routine]) + fi +fi dnl ---------------------------------------------------------------- # Check Configuration diff --git a/libraries/liblber/bprint.c b/libraries/liblber/bprint.c index 23ebf88853..0535603b0c 100644 --- a/libraries/liblber/bprint.c +++ b/libraries/liblber/bprint.c @@ -87,15 +87,8 @@ int ber_pvt_log_output( { int level; ber_get_option( NULL, LBER_OPT_BER_DEBUG, &level ); -#ifdef HAVE_VSNPRINTF buf[sizeof(buf) - 1] = '\0'; vsnprintf( buf, sizeof(buf)-1, fmt, vl ); -#elif HAVE_VSPRINTF - vsprintf( buf, fmt, vl ); /* hope it's not too long */ -#else - /* use doprnt() */ -#error "vsprintf() required."; -#endif if ( ber_log_check( LDAP_DEBUG_BER, level ) ) (*ber_pvt_log_print)( buf ); } @@ -117,15 +110,8 @@ int ber_pvt_log_printf( int errlvl, int loglvl, const char *fmt, ... ) va_start( ap, fmt ); -#ifdef HAVE_VSNPRINTF buf[sizeof(buf) - 1] = '\0'; vsnprintf( buf, sizeof(buf)-1, fmt, ap ); -#elif HAVE_VSPRINTF - vsprintf( buf, fmt, ap ); /* hope it's not too long */ -#else - /* use doprnt() */ -#error "vsprintf() required." -#endif va_end(ap); diff --git a/libraries/liblber/debug.c b/libraries/liblber/debug.c index 8d182d83f2..13ab67c30b 100644 --- a/libraries/liblber/debug.c +++ b/libraries/liblber/debug.c @@ -311,11 +311,7 @@ void (lutil_debug)( int debug, int level, const char *fmt, ... ) #endif va_start( vl, fmt ); -#ifdef HAVE_VSNPRINTF vsnprintf( buffer, sizeof(buffer), fmt, vl ); -#else - vsprintf( buffer, fmt, vl ); -#endif buffer[sizeof(buffer)-1] = '\0'; if( log_file != NULL ) { diff --git a/libraries/libldap/print.c b/libraries/libldap/print.c index bbd21b36e1..7ea14d63a3 100644 --- a/libraries/libldap/print.c +++ b/libraries/libldap/print.c @@ -43,15 +43,8 @@ int ldap_log_printf( LDAP *ld, int loglvl, const char *fmt, ... ) va_start( ap, fmt ); -#ifdef HAVE_VSNPRINTF buf[sizeof(buf) - 1] = '\0'; vsnprintf( buf, sizeof(buf)-1, fmt, ap ); -#elif HAVE_VSPRINTF - vsprintf( buf, fmt, ap ); /* hope it's not too long */ -#else - /* use doprnt() */ - chokeme = "choke me! I don't have a doprnt manual handy!"; -#endif va_end(ap); diff --git a/libraries/liblutil/setproctitle.c b/libraries/liblutil/setproctitle.c index 6d1ab6a032..8a095e2c5d 100644 --- a/libraries/liblutil/setproctitle.c +++ b/libraries/liblutil/setproctitle.c @@ -42,15 +42,8 @@ void setproctitle( const char *fmt, ... ) va_start(ap, fmt); -#ifdef HAVE_VSNPRINTF buf[sizeof(buf) - 1] = '\0'; vsnprintf( buf, sizeof(buf)-1, fmt, ap ); -#elif HAVE_VPRINTF - vsprintf( buf, fmt, ap ); /* hope it's not too long */ -#else - /* use doprnt() */ - chokeme = "choke me! I don't have a doprnt() manual handy"; -#endif va_end(ap); diff --git a/libraries/liblutil/stdio.c b/libraries/liblutil/stdio.c index adf4187185..39d8a37541 100644 --- a/libraries/liblutil/stdio.c +++ b/libraries/liblutil/stdio.c @@ -12,7 +12,7 @@ #include -#ifndef HAVE_VSNPRINTF +#if !defined(HAVE_VSNPRINTF) && !defined(HAVE_EBCDIC) /* Write at most n characters to the buffer in str, return the * number of chars written or -1 if the buffer would have been * overflowed. @@ -30,13 +30,12 @@ * broken pipe, and the write will be terminated. * -- hyc, 2002-07-19 */ -#ifndef HAVE_EBCDIC /* This emulation uses vfprintf; on OS/390 we're also emulating * that function so it's more efficient just to have a separate * version of vsnprintf there. */ #include -int vsnprintf( char *str, size_t n, const char *fmt, va_list ap ) +int lutil_vsnprintf( char *str, size_t n, const char *fmt, va_list ap ) { int fds[2], res; FILE *f; @@ -62,7 +61,8 @@ int vsnprintf( char *str, size_t n, const char *fmt, va_list ap ) } #endif -int snprintf( char *str, size_t n, const char *fmt, ... ) +#ifndef HAVE_SNPRINTF +int lutil_snprintf( char *str, size_t n, const char *fmt, ... ) { va_list ap; int res; @@ -116,7 +116,7 @@ int lutil_fputs( const char *str, FILE *fp ) * may need to be extended to recognize other qualifiers but so * far this seems to be enough. */ -int vsnprintf( char *str, size_t n, const char *fmt, va_list ap ) +int lutil_vsnprintf( char *str, size_t n, const char *fmt, va_list ap ) { char *ptr, *pct, *s2, *f2, *end; char fm2[64];