1 | dnl @synopsis AC_FUNC_VSNPRINTF_C99 |
---|
2 | dnl |
---|
3 | dnl Check whether there is a vsnprintf() function with C99 semantics installed. |
---|
4 | dnl |
---|
5 | AC_DEFUN([AC_FUNC_VSNPRINTF_C99], |
---|
6 | [AC_CACHE_CHECK(for C99 vsnprintf, |
---|
7 | ac_cv_func_vsnprintf_c99, |
---|
8 | [AC_TRY_RUN( |
---|
9 | [#include <stdio.h> |
---|
10 | #include <stdarg.h> |
---|
11 | |
---|
12 | int |
---|
13 | doit(char * s, ...) |
---|
14 | { |
---|
15 | char buffer[32]; |
---|
16 | va_list args; |
---|
17 | int r; |
---|
18 | |
---|
19 | va_start(args, s); |
---|
20 | r = vsnprintf(buffer, 5, s, args); |
---|
21 | va_end(args); |
---|
22 | |
---|
23 | if (r != 7) |
---|
24 | exit(1); |
---|
25 | |
---|
26 | exit(0); |
---|
27 | } |
---|
28 | |
---|
29 | int |
---|
30 | main(void) |
---|
31 | { |
---|
32 | doit("1234567"); |
---|
33 | exit(1); |
---|
34 | }], ac_cv_func_vsnprintf_c99=yes, ac_cv_func_vsnprintf_c99=no, ac_cv_func_vsnprintf_c99=no)]) |
---|
35 | dnl Note that the default is to be pessimistic in the case of cross compilation. |
---|
36 | dnl If you know that the target has a C99 vsnprintf(), you can get around this |
---|
37 | dnl by setting ac_func_vsnprintf_c99 to yes, as described in the Autoconf manual. |
---|
38 | if test $ac_cv_func_vsnprintf_c99 = yes; then |
---|
39 | AC_DEFINE(HAVE_C99_VSNPRINTF, 1, |
---|
40 | [Define if you have a version of the vsnprintf function |
---|
41 | with semantics as specified by the ISO C99 standard.]) |
---|
42 | fi |
---|
43 | ])# AC_FUNC_VSNPRINTF_C99 |
---|
44 | |
---|
45 | |
---|
46 | dnl @synopsis AC_FUNC_PRINTF_UNIX98 |
---|
47 | dnl |
---|
48 | dnl Check whether the printf() family supports Unix98 %n$ positional parameters |
---|
49 | dnl |
---|
50 | AC_DEFUN([AC_FUNC_PRINTF_UNIX98], |
---|
51 | [AC_CACHE_CHECK(whether printf supports positional parameters, |
---|
52 | ac_cv_func_printf_unix98, |
---|
53 | [AC_TRY_RUN( |
---|
54 | [#include <stdio.h> |
---|
55 | |
---|
56 | int |
---|
57 | main (void) |
---|
58 | { |
---|
59 | char buffer[128]; |
---|
60 | |
---|
61 | sprintf (buffer, "%2\$d %3\$d %1\$d", 1, 2, 3); |
---|
62 | if (strcmp ("2 3 1", buffer) == 0) |
---|
63 | exit (0); |
---|
64 | exit (1); |
---|
65 | }], ac_cv_func_printf_unix98=yes, ac_cv_func_printf_unix98=no, ac_cv_func_printf_unix98=no)]) |
---|
66 | dnl Note that the default is to be pessimistic in the case of cross compilation. |
---|
67 | dnl If you know that the target printf() supports positional parameters, you can get around |
---|
68 | dnl this by setting ac_func_printf_unix98 to yes, as described in the Autoconf manual. |
---|
69 | if test $ac_cv_func_printf_unix98 = yes; then |
---|
70 | AC_DEFINE(HAVE_UNIX98_PRINTF, 1, |
---|
71 | [Define if your printf function family supports positional parameters |
---|
72 | as specified by Unix98.]) |
---|
73 | fi |
---|
74 | ])# AC_FUNC_PRINTF_UNIX98 |
---|
75 | |
---|
76 | |
---|
77 | |
---|
78 | |
---|