Use vsprintf if vasprintf is not available.

This commit is contained in:
mainzelm 2002-05-23 09:51:24 +00:00
parent 6dd03e81a2
commit e8fe6105bf
2 changed files with 17 additions and 8 deletions

View File

@ -343,7 +343,7 @@ esac
AC_CHECK_HEADERS(libgen.h sys/timeb.h posix/time.h sys/select.h nlist.h) AC_CHECK_HEADERS(libgen.h sys/timeb.h posix/time.h sys/select.h nlist.h)
AC_CHECK_HEADERS(sys/un.h) AC_CHECK_HEADERS(sys/un.h)
AC_CHECK_HEADERS(crypt.h) AC_CHECK_HEADERS(crypt.h)
AC_CHECK_FUNCS(gettimeofday ftime nlist select setitimer sigaction) AC_CHECK_FUNCS(gettimeofday ftime nlist select setitimer sigaction vasprintf)
SCSH_SOCKLEN_T SCSH_SOCKLEN_T
AC_CHECK_FUNC(dlopen, AC_DEFINE(HAVE_DLOPEN), AC_CHECK_FUNC(dlopen, AC_DEFINE(HAVE_DLOPEN),
AC_CHECK_FUNC(nlist, [LIBOBJS="$LIBOBJS c/fake/libdl1.o"], AC_CHECK_FUNC(nlist, [LIBOBJS="$LIBOBJS c/fake/libdl1.o"],

View File

@ -6,6 +6,7 @@
#include <stdio.h> #include <stdio.h>
#include "scheme48.h" #include "scheme48.h"
#include "libscsh.h" #include "libscsh.h"
#include "sysdep.h"
s48_value s48_command_binding; s48_value s48_command_binding;
s48_value s48_to_string_binding; s48_value s48_to_string_binding;
@ -22,17 +23,25 @@ s48_value s48_vcommand (char* fmt, va_list ap)
char* command; char* command;
s48_value ret; s48_value ret;
if (vasprintf(&command, fmt, ap) == -1){ #ifdef HAVE_VASPRINTF
fprintf(stderr, "error in vasprintf\n"); if (vasprintf(&command, fmt, ap) == -1){
exit(1); fprintf(stderr, "error in vasprintf\n");
} exit(1);
}
#else
command = (char *)calloc (1000, sizeof (char));
if (vsprintf(command, fmt, ap) == -1){
fprintf(stderr, "error in vsprintf\n");
exit(1);
}
#endif
fprintf (stderr,"The command is: %s\n", command); fprintf (stderr,"The command is: %s\n", command);
S48_SHARED_BINDING_CHECK (s48_command_binding); S48_SHARED_BINDING_CHECK (s48_command_binding);
ret = s48_call_scheme (S48_SHARED_BINDING_REF (s48_command_binding), ret = s48_call_scheme (S48_SHARED_BINDING_REF (s48_command_binding),
1, 1,
s48_enter_string (command)); s48_enter_string (command));
free (command); free (command);
va_end (ap); va_end (ap);
return ret; return ret;