source: trunk/third/glib2/acinclude.m4 @ 18159

Revision 18159, 2.1 KB checked in by ghudson, 22 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r18158, which included commits to RCS files with non-trunk default branches.
Line 
1dnl @synopsis AC_FUNC_VSNPRINTF_C99
2dnl
3dnl Check whether there is a vsnprintf() function with C99 semantics installed.
4dnl
5AC_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
12int
13doit(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
29int
30main(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)])
35dnl Note that the default is to be pessimistic in the case of cross compilation.
36dnl If you know that the target has a C99 vsnprintf(), you can get around this
37dnl by setting ac_func_vsnprintf_c99 to yes, as described in the Autoconf manual.
38if 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.])
42fi
43])# AC_FUNC_VSNPRINTF_C99
44
45
46dnl @synopsis AC_FUNC_PRINTF_UNIX98
47dnl
48dnl Check whether the printf() family supports Unix98 %n$ positional parameters
49dnl
50AC_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
56int
57main (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)])
66dnl Note that the default is to be pessimistic in the case of cross compilation.
67dnl If you know that the target printf() supports positional parameters, you can get around
68dnl this by setting ac_func_printf_unix98 to yes, as described in the Autoconf manual.
69if 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.])
73fi
74])# AC_FUNC_PRINTF_UNIX98
75
76
77
78
Note: See TracBrowser for help on using the repository browser.