From e8fe6105bf67067e5313a3c63e3ef3d5c2a20ccb Mon Sep 17 00:00:00 2001 From: mainzelm Date: Thu, 23 May 2002 09:51:24 +0000 Subject: [PATCH] Use vsprintf if vasprintf is not available. --- configure.in | 2 +- scsh/libscsh.c | 23 ++++++++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/configure.in b/configure.in index d690f95..62487e4 100644 --- a/configure.in +++ b/configure.in @@ -343,7 +343,7 @@ esac 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(crypt.h) - AC_CHECK_FUNCS(gettimeofday ftime nlist select setitimer sigaction) + AC_CHECK_FUNCS(gettimeofday ftime nlist select setitimer sigaction vasprintf) SCSH_SOCKLEN_T AC_CHECK_FUNC(dlopen, AC_DEFINE(HAVE_DLOPEN), AC_CHECK_FUNC(nlist, [LIBOBJS="$LIBOBJS c/fake/libdl1.o"], diff --git a/scsh/libscsh.c b/scsh/libscsh.c index cf7f4b9..2aa91d3 100644 --- a/scsh/libscsh.c +++ b/scsh/libscsh.c @@ -6,6 +6,7 @@ #include #include "scheme48.h" #include "libscsh.h" +#include "sysdep.h" s48_value s48_command_binding; s48_value s48_to_string_binding; @@ -22,17 +23,25 @@ s48_value s48_vcommand (char* fmt, va_list ap) char* command; s48_value ret; - if (vasprintf(&command, fmt, ap) == -1){ - fprintf(stderr, "error in vasprintf\n"); - exit(1); - } +#ifdef HAVE_VASPRINTF + if (vasprintf(&command, fmt, ap) == -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); S48_SHARED_BINDING_CHECK (s48_command_binding); - + ret = s48_call_scheme (S48_SHARED_BINDING_REF (s48_command_binding), 1, - s48_enter_string (command)); - + s48_enter_string (command)); + free (command); va_end (ap); return ret;