1*ebfedea0SLionel Sambucdnl Id 2*ebfedea0SLionel Sambucdnl 3*ebfedea0SLionel SambucAC_DEFUN([AC_BROKEN_SNPRINTF], [ 4*ebfedea0SLionel SambucAC_CACHE_CHECK(for working snprintf,ac_cv_func_snprintf_working, 5*ebfedea0SLionel Sambucac_cv_func_snprintf_working=yes 6*ebfedea0SLionel SambucAC_RUN_IFELSE([AC_LANG_SOURCE([[ 7*ebfedea0SLionel Sambuc#include <stdio.h> 8*ebfedea0SLionel Sambuc#include <string.h> 9*ebfedea0SLionel Sambucint main(int argc, char **argv) 10*ebfedea0SLionel Sambuc{ 11*ebfedea0SLionel Sambuc char foo[[3]]; 12*ebfedea0SLionel Sambuc snprintf(foo, 2, "12"); 13*ebfedea0SLionel Sambuc return strcmp(foo, "1") || snprintf(NULL, 0, "%d", 12) != 2; 14*ebfedea0SLionel Sambuc}]])],[:],[ac_cv_func_snprintf_working=no],[:])) 15*ebfedea0SLionel Sambuc 16*ebfedea0SLionel Sambucif test "$ac_cv_func_snprintf_working" = yes; then 17*ebfedea0SLionel Sambuc AC_DEFINE_UNQUOTED(HAVE_SNPRINTF, 1, [define if you have a working snprintf]) 18*ebfedea0SLionel Sambucfi 19*ebfedea0SLionel Sambucif test "$ac_cv_func_snprintf_working" = yes; then 20*ebfedea0SLionel SambucAC_NEED_PROTO([#include <stdio.h>],snprintf) 21*ebfedea0SLionel Sambucfi 22*ebfedea0SLionel Sambuc]) 23*ebfedea0SLionel Sambuc 24*ebfedea0SLionel SambucAC_DEFUN([AC_BROKEN_VSNPRINTF],[ 25*ebfedea0SLionel SambucAC_CACHE_CHECK(for working vsnprintf,ac_cv_func_vsnprintf_working, 26*ebfedea0SLionel Sambucac_cv_func_vsnprintf_working=yes 27*ebfedea0SLionel SambucAC_RUN_IFELSE([AC_LANG_SOURCE([[ 28*ebfedea0SLionel Sambuc#include <stdio.h> 29*ebfedea0SLionel Sambuc#include <string.h> 30*ebfedea0SLionel Sambuc#include <stdarg.h> 31*ebfedea0SLionel Sambuc 32*ebfedea0SLionel Sambucint foo(int num, ...) 33*ebfedea0SLionel Sambuc{ 34*ebfedea0SLionel Sambuc char bar[[3]]; 35*ebfedea0SLionel Sambuc va_list arg; 36*ebfedea0SLionel Sambuc va_start(arg, num); 37*ebfedea0SLionel Sambuc vsnprintf(bar, 2, "%s", arg); 38*ebfedea0SLionel Sambuc va_end(arg); 39*ebfedea0SLionel Sambuc return strcmp(bar, "1"); 40*ebfedea0SLionel Sambuc} 41*ebfedea0SLionel Sambuc 42*ebfedea0SLionel Sambucint bar(int num, int len, ...) 43*ebfedea0SLionel Sambuc{ 44*ebfedea0SLionel Sambuc int r; 45*ebfedea0SLionel Sambuc va_list arg; 46*ebfedea0SLionel Sambuc va_start(arg, len); 47*ebfedea0SLionel Sambuc r = vsnprintf(NULL, 0, "%s", arg); 48*ebfedea0SLionel Sambuc va_end(arg); 49*ebfedea0SLionel Sambuc return r != len; 50*ebfedea0SLionel Sambuc} 51*ebfedea0SLionel Sambuc 52*ebfedea0SLionel Sambucint main(int argc, char **argv) 53*ebfedea0SLionel Sambuc{ 54*ebfedea0SLionel Sambuc return foo(0, "12") || bar(0, 2, "12"); 55*ebfedea0SLionel Sambuc}]])],[:],[ac_cv_func_vsnprintf_working=no],[:])) 56*ebfedea0SLionel Sambuc 57*ebfedea0SLionel Sambucif test "$ac_cv_func_vsnprintf_working" = yes; then 58*ebfedea0SLionel Sambuc AC_DEFINE_UNQUOTED(HAVE_VSNPRINTF, 1, [define if you have a working vsnprintf]) 59*ebfedea0SLionel Sambucfi 60*ebfedea0SLionel Sambucif test "$ac_cv_func_vsnprintf_working" = yes; then 61*ebfedea0SLionel SambucAC_NEED_PROTO([#include <stdio.h>],vsnprintf) 62*ebfedea0SLionel Sambucfi 63*ebfedea0SLionel Sambuc]) 64