mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-20 22:59:34 -05:00
Remove dependencies on HAVE_VSNPRINTF, use replacement in liblutil/stdio.c
if needed. Same check for snprintf.
This commit is contained in:
parent
b623e4495b
commit
4d8a2e2815
6 changed files with 16 additions and 38 deletions
12
configure.in
12
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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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 ) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
#include <lutil.h>
|
||||
|
||||
#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 <ac/signal.h>
|
||||
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];
|
||||
|
|
|
|||
Loading…
Reference in a new issue