From: Arvid Norlander Date: Thu, 20 Nov 2008 16:47:22 +0000 (-0500) Subject: Add autoconf test for vsnprintf to make the ifdef in ick_snprintf_or_die() correct... X-Git-Tag: 0.29~173 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=6a88f3b49a38188ab220d50184138ebbb7325bed;p=intercal.git Add autoconf test for vsnprintf to make the ifdef in ick_snprintf_or_die() correct. Add splint annotation to ick_snprintf_or_die(). --- diff --git a/configure.ac b/configure.ac index dec0117..d46c5fd 100644 --- a/configure.ac +++ b/configure.ac @@ -64,7 +64,7 @@ fi AC_DEFINE_UNQUOTED([EXEEXT],"$EXEEXT",[Extension to use on executable files.]) dnl Checks for library functions. -AC_CHECK_FUNCS(gettimeofday gethrtime strdup strtol strtoul snprintf) +AC_CHECK_FUNCS(gettimeofday gethrtime strdup strtol strtoul snprintf vsnprintf) ICK_SAVECFLAGS=$CFLAGS CFLAGS="$CFLAGS -lrt" AC_CHECK_FUNCS(clock_gettime) diff --git a/src/uncommon.c b/src/uncommon.c index 0dc93e3..d792daf 100644 --- a/src/uncommon.c +++ b/src/uncommon.c @@ -168,12 +168,12 @@ int ick_printfopens=0; * Invoke snprintf(), if supported. Otherwise invoke sprintf() and abort * if we did overflow. */ -int ick_snprintf_or_die(char *str, size_t size, const char *format, ...) +int ick_snprintf_or_die(/*@out@*/ char *str, size_t size, /*@observer@*/ const char *format, ...) { va_list ap; int retval; va_start(ap, format); -#ifdef HAVE_SNPRINTF +#ifdef HAVE_VSNPRINTF retval = vsnprintf(str, size, format, ap); #else retval = vsprintf(str, format, ap); diff --git a/src/uncommon.h b/src/uncommon.h index 3144680..c3c25cd 100644 --- a/src/uncommon.h +++ b/src/uncommon.h @@ -6,7 +6,7 @@ /*@null@*/ /*@dependent@*/ extern FILE* ick_findandfopen(/*@observer@*/ const char*, /*@observer@*/ const char*, /*@observer@*/ const char*, /*@observer@*/ const char*); /*@observer@*/ /*@null@*/ extern const char* ick_findandtestopen(/*@observer@*/ const char*, /*@observer@*/ const char*, /*@observer@*/ const char*, /*@observer@*/ const char*); /*@null@*/ /*@dependent@*/ extern FILE* ick_findandfreopen(/*@observer@*/ const char*, /*@observer@*/ const char*, /*@observer@*/ const char*, /*@observer@*/ const char*, FILE*); -extern int ick_snprintf_or_die(char *str, size_t size, const char *format, ...) +extern int ick_snprintf_or_die(/*@out@*/ char *str, size_t size, /*@observer@*/ const char *format, ...) #ifdef __GNUC__ __attribute__ ((format(printf, 3, 4))) #endif