Include a printf implementation supporting C99 snprintf and SUS
[platform/upstream/glib.git] / acinclude.m4
index 54f0f75..a969c70 100644 (file)
@@ -101,7 +101,8 @@ AC_DEFUN(AM_GLIB_WITH_NLS,
                             gt_cv_func_dgettext_libintl=yes)])
 
            if test "$gt_cv_func_dgettext_libc" != "yes" ; then
-              AC_MSG_NOTICE([Seeing if -liconv is needed to use gettext])
+              AC_MSG_CHECKING([if -liconv is needed to use gettext])
+              AC_MSG_RESULT([])
               AC_CHECK_LIB(intl, dcgettext,
                            [gt_cv_func_dgettext_libintl=yes
                             libintl_extra_libs=-liconv],
@@ -326,3 +327,37 @@ if test $ac_cv_func_vsnprintf_c99 = yes; then
 fi
 ])# AC_FUNC_VSNPRINTF_C99
 
+
+dnl @synopsis AC_FUNC_PRINTF_UNIX98
+dnl
+dnl Check whether the printf() family supports Unix98 %n$ positional parameters 
+dnl
+AC_DEFUN([AC_FUNC_PRINTF_UNIX98],
+[AC_CACHE_CHECK(whether printf supports positional parameters,
+  ac_cv_func_printf_unix98,
+[AC_TRY_RUN(
+[#include <stdio.h>
+
+int
+main (void)
+{
+  char buffer[128];
+
+  sprintf (buffer, "%2\$d %3\$d %1\$d", 1, 2, 3);
+  if (strcmp ("2 3 1", buffer) == 0)
+    exit (0);
+  exit (1);
+}], ac_cv_func_printf_unix98=yes, ac_cv_func_printf_unix98=no, ac_cv_func_printf_unix98=no)])
+dnl Note that the default is to be pessimistic in the case of cross compilation.
+dnl If you know that the target printf() supports positional parameters, you can get around 
+dnl this by setting ac_func_printf_unix98 to yes, as described in the Autoconf manual.
+if test $ac_cv_func_printf_unix98 = yes; then
+  AC_DEFINE(HAVE_UNIX98_PRINTF, 1,
+            [Define if your printf function family supports positional parameters
+             as specified by Unix98.])
+fi
+])# AC_FUNC_PRINTF_UNIX98
+
+
+
+