summaryrefslogtreecommitdiff
path: root/acinclude.m4
diff options
context:
space:
mode:
authorMatthias Clasen <matthiasc@src.gnome.org>2002-11-21 00:35:15 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2002-11-21 00:35:15 +0000
commitbc54ea6edf251c7623c3afa797da8a67a882fbd2 (patch)
tree092d2287894eea17c508f7f0a68e8d9f42a28f6a /acinclude.m4
parentdc645ce354f06c93f982a0177951c9f98627d751 (diff)
Include a printf implementation supporting C99 snprintf and SUS
positional parameters: (#79488) * glib/gstrfuncs.c: * glib/gspawn-win32.c: * glib/gscanner.c: * glib/gconvert.c: * glib/gbacktrace.c: Use _g_printf wrappers. * glib/gutils.c (g_vsnprintf): Simplify, since we can assume C99 snprintf semantics now. * glib/gmessages.c (printf_string_upper_bound): No longer needed, since we can assume C99 snprintf semantics now. (g_logv): Simplify. * acinclude.m4 (AC_FUNC_PRINTF_UNIX98): New macro to check wether printf supports SUS positional parameters. * configure.in: New option --enable-included-printf to force compilation of trio; otherwise trio is compiled if the system printf misses either C99 snprintf semantics of SUS positional parameters. * glib/Makefile.am (SUBDIRS): Conditionally compile trio. (libglib_2_0_la_SOURCES): Add gprintf.c and gprintfint.h. (glibsubinclude_HEADERS): Add gprintf.h. * glib/gprintfint.h: New private wrapping either system printf or trio printf variants in _g_printf wrappers for use inside glib. * glib/gprintf.h: New public header declaring g_printf variants. * glib/gprintf.c: Corresponding implementations. * glib/trio/*: New directory, containing the trio-1.9 sources. * glib/tmpl/string_utils.sgml: Add note on including gprintf.h, move some docs inline. * glib/glib-sections.txt: Add g_printf, g_vprintf, g_fprintf, g_vfprintf, g_sprintf, g_vsprintf.
Diffstat (limited to 'acinclude.m4')
-rw-r--r--acinclude.m434
1 files changed, 34 insertions, 0 deletions
diff --git a/acinclude.m4 b/acinclude.m4
index 4fe1e02fb..a969c7037 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -327,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
+
+
+
+