Initial import from FreeBSD RELENG_4:
[dragonfly.git] / crypto / kerberosIV / cf / broken-snprintf.m4
1 dnl $Id: broken-snprintf.m4,v 1.3 1999/03/01 09:52:22 joda Exp $
2 dnl
3 AC_DEFUN(AC_BROKEN_SNPRINTF, [
4 AC_CACHE_CHECK(for working snprintf,ac_cv_func_snprintf_working,
5 ac_cv_func_snprintf_working=yes
6 AC_TRY_RUN([
7 #include <stdio.h>
8 #include <string.h>
9 int main()
10 {
11 changequote(`,')dnl
12         char foo[3];
13 changequote([,])dnl
14         snprintf(foo, 2, "12");
15         return strcmp(foo, "1");
16 }],:,ac_cv_func_snprintf_working=no,:))
17
18 if test "$ac_cv_func_snprintf_working" = yes; then
19         AC_DEFINE_UNQUOTED(HAVE_SNPRINTF, 1, [define if you have a working snprintf])
20 fi
21 if test "$ac_cv_func_snprintf_working" = yes; then
22 AC_NEED_PROTO([#include <stdio.h>],snprintf)
23 fi
24 ])
25
26 AC_DEFUN(AC_BROKEN_VSNPRINTF,[
27 AC_CACHE_CHECK(for working vsnprintf,ac_cv_func_vsnprintf_working,
28 ac_cv_func_vsnprintf_working=yes
29 AC_TRY_RUN([
30 #include <stdio.h>
31 #include <string.h>
32 #include <stdarg.h>
33
34 int foo(int num, ...)
35 {
36 changequote(`,')dnl
37         char bar[3];
38 changequote([,])dnl
39         va_list arg;
40         va_start(arg, num);
41         vsnprintf(bar, 2, "%s", arg);
42         va_end(arg);
43         return strcmp(bar, "1");
44 }
45
46
47 int main()
48 {
49         return foo(0, "12");
50 }],:,ac_cv_func_vsnprintf_working=no,:))
51
52 if test "$ac_cv_func_vsnprintf_working" = yes; then
53         AC_DEFINE_UNQUOTED(HAVE_VSNPRINTF, 1, [define if you have a working vsnprintf])
54 fi
55 if test "$ac_cv_func_vsnprintf_working" = yes; then
56 AC_NEED_PROTO([#include <stdio.h>],vsnprintf)
57 fi
58 ])