Index: acinclude.m4
===================================================================
RCS file: /cvs/gnome/glib/acinclude.m4,v
retrieving revision 1.12
diff -u -b -B -p -n -r1.12 acinclude.m4
*** acinclude.m4	16 Jan 2002 19:29:15 -0000	1.12
--- acinclude.m4	23 Apr 2002 22:28:07 -0000
*************** if test $ac_cv_func_vsnprintf_c99 = yes;
*** 270,272 ****
--- 270,306 ----
  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
+ 
+ 
+ 
+ 
Index: configure.in
===================================================================
RCS file: /cvs/gnome/glib/configure.in,v
retrieving revision 1.279
diff -u -b -B -p -n -r1.279 configure.in
*** configure.in	7 Apr 2002 23:09:08 -0000	1.279
--- configure.in	23 Apr 2002 22:28:13 -0000
*************** AC_CHECK_FUNCS(bind_textdomain_codeset)
*** 295,301 ****
  
  dnl Initialize libtool
  AM_DISABLE_STATIC
! AC_LIBTOOL_WIN32_DLL
  AM_PROG_LIBTOOL
  
  if test "x$GCC" = "xyes"; then
--- 295,301 ----
  
  dnl Initialize libtool
  AM_DISABLE_STATIC
! cd gAC_LIBTOOL_WIN32_DLL
  AM_PROG_LIBTOOL
  
  if test "x$GCC" = "xyes"; then
*************** GLIB_SIZEOF([$size_includes], intmax_t, 
*** 582,587 ****
--- 582,613 ----
  AC_CHECK_FUNCS(lstat strerror strsignal memmove mkstemp vsnprintf stpcpy strcasecmp strncasecmp poll getcwd nanosleep vasprintf unsetenv)
  
  AC_FUNC_VSNPRINTF_C99
+ AC_FUNC_PRINTF_UNIX98
+ 
+ #
+ # Check whether to use trio printf
+ #
+ 
+ AC_ARG_ENABLE(trio-printf, [  --enable-trio-printf    use trio printf [default=auto]], enable_trio="$enableval")
+ 
+ if test "$enable_trio" != "no" ; then
+   if test "$ac_cv_func_vsnprintf_c99" != "yes" ; then
+     enable_trio = yes
+   fi
+   if test "$ac_cv_func_printf_unix98" != "yes" ; then
+     enable_trio = yes
+   fi
+ fi
+ 
+ AM_CONDITIONAL(HAVE_GOOD_PRINTF, test "$enable_trio" != "yes")
+ if test "$enable_trio" != "yes" ; then 
+   AC_DEFINE(HAVE_GOOD_PRINTF,1,[define to use system printf])
+   AC_DEFINE(HAVE_VASPRINTF,1)
+   AC_DEFINE(HAVE_C99_VSNPRINTF,1)
+   AC_DEFINE(HAVE_UNIX98_PRINTF,1)
+ else
+   AC_DEFINE(HAVE_GOOD_PRINTF,0)
+ fi
  
  # Check if bcopy can be used for overlapping copies, if memmove isn't found.
  # The check is borrowed from the PERL Configure script.
*************** build/win32/Makefile
*** 2209,2214 ****
--- 2235,2241 ----
  build/win32/dirent/Makefile
  glib/Makefile
  glib/libcharset/Makefile
+ glib/trio/Makefile
  gmodule/gmoduleconf.h
  gmodule/Makefile
  gobject/Makefile
Index: glib/Makefile.am
===================================================================
RCS file: /cvs/gnome/glib/glib/Makefile.am,v
retrieving revision 1.101
diff -u -b -B -p -n -r1.101 Makefile.am
*** glib/Makefile.am	5 Mar 2002 05:17:39 -0000	1.101
--- glib/Makefile.am	23 Apr 2002 22:28:14 -0000
***************
*** 1,6 ****
  ## Process this file with automake to produce Makefile.in
  
! SUBDIRS=libcharset
  
  INCLUDES = -I$(top_srcdir) -DG_LOG_DOMAIN=\"GLib\" \
  	@GLIB_DEBUG_FLAGS@ -DG_DISABLE_DEPRECATED -DGLIB_COMPILATION 
--- 1,11 ----
  ## Process this file with automake to produce Makefile.in
  
! if HAVE_GOOD_PRINTF
! else
! TRIO_SUBDIR = trio
! endif
! 
! SUBDIRS=libcharset $(TRIO_SUBDIR)
  
  INCLUDES = -I$(top_srcdir) -DG_LOG_DOMAIN=\"GLib\" \
  	@GLIB_DEBUG_FLAGS@ -DG_DISABLE_DEPRECATED -DGLIB_COMPILATION 
*************** libglib_2_0_la_SOURCES = 	\
*** 82,88 ****
  	gunidecomp.h		\
  	gunidecomp.c		\
  	gutils.c		\
! 	gdebug.h
  
  EXTRA_libglib_2_0_la_SOURCES = \
  	giounix.c	\
--- 87,94 ----
  	gunidecomp.h		\
  	gunidecomp.c		\
  	gutils.c		\
! 	gdebug.h		\
! 	gprintf.h
  
  EXTRA_libglib_2_0_la_SOURCES = \
  	giounix.c	\
*************** install-libtool-import-lib:
*** 168,175 ****
  uninstall-libtool-import-lib:
  endif
  
! libglib_2_0_la_LIBADD = libcharset/libcharset.la @GIO@ @GSPAWN@ @PLATFORMDEP@ @G_LIB_WIN32_RESOURCE@ @ICONV_LIBS@ @G_LIBS_EXTRA@ 
! libglib_2_0_la_DEPENDENCIES = libcharset/libcharset.la @GIO@ @GSPAWN@ @PLATFORMDEP@ @G_LIB_WIN32_RESOURCE@ @GLIB_DEF@
  
  libglib_2_0_la_LDFLAGS = \
  	-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
--- 174,186 ----
  uninstall-libtool-import-lib:
  endif
  
! if HAVE_GOOD_PRINTF
! else
! TRIO_LIBS = trio/libtrio.la -lm
! endif
! 
! libglib_2_0_la_LIBADD = libcharset/libcharset.la $(TRIO_LIBS) @GIO@ @GSPAWN@ @PLATFORMDEP@ @G_LIB_WIN32_RESOURCE@ @ICONV_LIBS@ @G_LIBS_EXTRA@ 
! libglib_2_0_la_DEPENDENCIES = libcharset/libcharset.la $(TRIO_LIBS) @GIO@ @GSPAWN@ @PLATFORMDEP@ @G_LIB_WIN32_RESOURCE@ @GLIB_DEF@
  
  libglib_2_0_la_LDFLAGS = \
  	-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
Index: glib/gmessages.c
===================================================================
RCS file: /cvs/gnome/glib/glib/gmessages.c,v
retrieving revision 1.47
diff -u -b -B -p -n -r1.47 gmessages.c
*** glib/gmessages.c	28 Mar 2002 23:24:21 -0000	1.47
--- glib/gmessages.c	23 Apr 2002 22:28:22 -0000
***************
*** 44,49 ****
--- 44,50 ----
  #include <locale.h>
  #include <errno.h>
  #include "gdebug.h"
+ #include "gprintf.h"
  
  #ifdef G_OS_WIN32
  typedef FILE* GFileDescriptor;
*************** g_logv (const gchar   *log_domain,
*** 421,431 ****
     * recursively.
     */
  #ifdef  HAVE_VSNPRINTF
!   vsnprintf (buffer, 1024, format, args1);
! #else	/* !HAVE_VSNPRINTF */
    G_VA_COPY (args2, args1);
    if (printf_string_upper_bound (format, FALSE, args1) < 1024)
!     vsprintf (buffer, format, args2);
    else
      {
        /* since we might be out of memory, we can't use g_vsnprintf(). */
--- 422,432 ----
     * recursively.
     */
  #ifdef  HAVE_VSNPRINTF
!   _g_vsnprintf (buffer, 1024, format, args1);
! trio_#else	/* !HAVE_VSNPRINTF */
    G_VA_COPY (args2, args1);
    if (printf_string_upper_bound (format, FALSE, args1) < 1024)
!     _g_vsprintf (buffer, format, args2);
    else
      {
        /* since we might be out of memory, we can't use g_vsnprintf(). */
*************** g_printf_string_upper_bound (const gchar
*** 1212,1218 ****
  {
  #if HAVE_C99_VSNPRINTF
    gchar c;
!   return vsnprintf (&c, 1, format, args) + 1;
  #else
    return printf_string_upper_bound (format, TRUE, args);
  #endif
--- 1213,1219 ----
  {
  #if HAVE_C99_VSNPRINTF
    gchar c;
!   return _g_vsnprintf (&c, 1, format, args) + 1;
  #else
    return printf_string_upper_bound (format, TRUE, args);
  #endif
Index: glib/gstrfuncs.c
===================================================================
RCS file: /cvs/gnome/glib/glib/gstrfuncs.c,v
retrieving revision 1.82
diff -u -b -B -p -n -r1.82 gstrfuncs.c
*** glib/gstrfuncs.c	28 Mar 2002 23:24:21 -0000	1.82
--- glib/gstrfuncs.c	23 Apr 2002 22:28:27 -0000
***************
*** 45,50 ****
--- 45,51 ----
  #include <signal.h>
  #endif
  #include "glib.h"
+ #include "gprintf.h"
  
  #ifdef G_OS_WIN32
  #include <windows.h>
*************** g_strdup_vprintf (const gchar *format,
*** 183,189 ****
  {
    gchar *buffer;
  #ifdef HAVE_VASPRINTF
!   if (vasprintf (&buffer, format, args1) < 0)
      buffer = NULL;
    else if (!g_mem_is_system_malloc ()) 
      {
--- 184,190 ----
  {
    gchar *buffer;
  #ifdef HAVE_VASPRINTF
!   if (_g_vasprintf (&buffer, format, args1) < 0)
      buffer = NULL;
    else if (!g_mem_is_system_malloc ()) 
      {
*************** g_strdup_vprintf (const gchar *format,
*** 198,204 ****
  
    buffer = g_new (gchar, g_printf_string_upper_bound (format, args1));
  
!   vsprintf (buffer, format, args2);
    va_end (args2);
  #endif
    return buffer;
--- 199,205 ----
  
    buffer = g_new (gchar, g_printf_string_upper_bound (format, args1));
  
!   _g_vsprintf (buffer, format, args2);
    va_end (args2);
  #endif
    return buffer;
Index: glib/gutils.c
===================================================================
RCS file: /cvs/gnome/glib/glib/gutils.c,v
retrieving revision 1.109
diff -u -b -B -p -n -r1.109 gutils.c
*** glib/gutils.c	8 Mar 2002 05:48:03 -0000	1.109
--- glib/gutils.c	23 Apr 2002 22:28:31 -0000
***************
*** 53,58 ****
--- 53,59 ----
  #define	G_IMPLEMENT_INLINES 1
  #define	__G_UTILS_C__
  #include "glib.h"
+ #include "gprintf.h"
  
  #ifdef	MAXPATHLEN
  #define	G_PATH_LENGTH	MAXPATHLEN
*************** g_vsnprintf (gchar	 *str,
*** 366,372 ****
    g_return_val_if_fail (n == 0 || str != NULL, 0);
    g_return_val_if_fail (fmt != NULL, 0);
  
!   return vsnprintf (str, n, fmt, args);
  #else	/* !HAVE_VSNPRINTF_C99 */
    gchar *printed;
    gint retval;
--- 367,373 ----
    g_return_val_if_fail (n == 0 || str != NULL, 0);
    g_return_val_if_fail (fmt != NULL, 0);
  
!   return _g_vsnprintf (str, n, fmt, args);
  #else	/* !HAVE_VSNPRINTF_C99 */
    gchar *printed;
    gint retval;
