Commit bc54ea6e authored by Matthias Clasen's avatar Matthias Clasen

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.
parent dc645ce3
2002-11-21 Matthias Clasen <maclas@gmx.de>
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.
2002-11-20 Matthias Clasen <maclas@gmx.de>
* glib/gmessages.h (g_return_if_fail):
......
2002-11-21 Matthias Clasen <maclas@gmx.de>
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.
2002-11-20 Matthias Clasen <maclas@gmx.de>
* glib/gmessages.h (g_return_if_fail):
......
2002-11-21 Matthias Clasen <maclas@gmx.de>
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.
2002-11-20 Matthias Clasen <maclas@gmx.de>
* glib/gmessages.h (g_return_if_fail):
......
2002-11-21 Matthias Clasen <maclas@gmx.de>
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.
2002-11-20 Matthias Clasen <maclas@gmx.de>
* glib/gmessages.h (g_return_if_fail):
......
2002-11-21 Matthias Clasen <maclas@gmx.de>
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.
2002-11-20 Matthias Clasen <maclas@gmx.de>
* glib/gmessages.h (g_return_if_fail):
......
2002-11-21 Matthias Clasen <maclas@gmx.de>
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.
2002-11-20 Matthias Clasen <maclas@gmx.de>
* glib/gmessages.h (g_return_if_fail):
......
2002-11-21 Matthias Clasen <maclas@gmx.de>
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.
2002-11-20 Matthias Clasen <maclas@gmx.de>
* glib/gmessages.h (g_return_if_fail):
......
......@@ -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
......@@ -712,6 +712,32 @@ AC_MSG_RESULT(unsigned $glib_size_type)
AC_CHECK_FUNCS(lstat strerror strsignal memmove mkstemp vsnprintf stpcpy strcasecmp strncasecmp poll getcwd nanosleep vasprintf unsetenv getc_unlocked)
AC_FUNC_VSNPRINTF_C99
AC_FUNC_PRINTF_UNIX98
#
# Check whether to use trio printf
#
AC_ARG_ENABLE(included-printf, [ --enable-included-printf use included 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.
......@@ -2355,6 +2381,7 @@ build/win32/Makefile
build/win32/dirent/Makefile
glib/Makefile
glib/libcharset/Makefile
glib/trio/Makefile
gmodule/gmoduleconf.h
gmodule/Makefile
gobject/Makefile
......
2002-11-21 Matthias Clasen <maclas@gmx.de>
* 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.
2002-11-20 Matthias Clasen <maclas@gmx.de>
* glib/tmpl/macros_misc.sgml: Document G_LIKELY, G_UNLIKELY.
......
......@@ -896,6 +896,12 @@ g_strlcat
<SUBSECTION>
g_strdup_printf
g_strdup_vprintf
g_printf
g_vprintf
g_fprintf
g_vfprintf
g_sprintf
g_vsprintf
g_snprintf
g_vsnprintf
g_printf_string_upper_bound
......
......@@ -9,6 +9,15 @@ various string-related functions.
This section describes a number of utility functions for creating,
duplicating, and manipulating strings.
</para>
<para>
Note that the functions g_printf(), g_fprintf(), g_sprintf(), g_snprintf(),
g_vprintf(), g_vfprintf(), g_vsprintf() and g_vsnprintf() are declared in
the header <filename>gprintf.h</filename> which is <emphasis>not</emphasis>
included in <filename>glib.h</filename> (otherwise using
<filename>glib.h</filename> would drag in <filename>stdio.h</filename>), so
you'll have to explicitly include <literal>&lt;glib/gprintf.h&gt;</literal>
in order to use the printf() functions.
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
......@@ -180,78 +189,90 @@ The returned string should be freed when no longer needed.
@Returns: a newly-allocated string holding the result.
<!-- ##### FUNCTION g_snprintf ##### -->
<!-- ##### FUNCTION g_printf ##### -->
<para>
A safer form of the standard <function>sprintf()</function> function.
The output is guaranteed to not exceed @n characters (including the
terminating nul character), so it is easy to ensure that a buffer overflow
cannot occur.
</para>
@format:
@Varargs:
@Returns:
<!-- ##### FUNCTION g_vprintf ##### -->
<para>
See also g_strdup_printf().
</para>
<note>
@format:
@args:
@Returns:
<!-- ##### FUNCTION g_fprintf ##### -->
<para>
In versions of GLib prior to 1.2.3, this function may return -1 if the output
was truncated, and the truncated string may not be nul-terminated.
In versions prior to 1.3.12, this function returns the length of the output
string.
</para>
</note>
<note>
@file:
@format:
@Varargs:
@Returns:
<!-- ##### FUNCTION g_vfprintf ##### -->
<para>
The return value of g_snprintf() conforms to the <function>snprintf()</function>
function as standardized in ISO C99. Note that this is different from
traditional <function>snprintf()</function>, which returns the length of
the output string.
</para>
</note>
@string: the buffer to hold the output.
@n: the maximum number of characters to produce (including the terminating nul
character).
@format: the format string. See the <function>sprintf()</function>.
documentation.
@Varargs: the arguments to insert in the output.
@Returns: the number of characters which would be produced if the buffer was
large enough.
@file:
@format:
@args:
@Returns:
<!-- ##### FUNCTION g_vsnprintf ##### -->
<!-- ##### FUNCTION g_sprintf ##### -->
<para>
A safer form of the standard <function>vsprintf()</function> function.
The output is guaranteed to not exceed @n characters (including the
terminating nul character), so it is easy to ensure that a buffer overflow
cannot occur.
</para>
@string:
@format:
@Varargs:
@Returns:
<!-- ##### FUNCTION g_vsprintf ##### -->
<para>
See also g_strdup_vprintf().
</para>
<note>
@string:
@format:
@args:
@Returns:
<!-- ##### FUNCTION g_snprintf ##### -->
<para>
In versions of GLib prior to 1.2.3, this function may return -1 if the output
was truncated, and the truncated string may not be nul-terminated.
In versions prior to 1.3.12, this function returns the length of the output
string.
</para>
</note>
<note>
@string:
@n:
@format:
@Varargs:
@Returns:
<!-- ##### FUNCTION g_vsnprintf ##### -->
<para>
The return value of g_vsnprintf() conforms to the <function>vsnprintf()</function>
function as standardized in ISO C99. Note that this is different from
traditional <function>vsnprintf()</function>, which returns the length of
the output string.
</para>
</note>
@string: the buffer to hold the output.
@n: the maximum number of characters to produce (including the terminating nul
character).
@format: the format string. See the <function>sprintf()</function>
documentation.
@args: the list of arguments to insert in the output.
@Returns: the number of characters which would be produced if the buffer was
large enough.
@string:
@n:
@format:
@args:
@Returns:
<!-- ##### FUNCTION g_printf_string_upper_bound ##### -->
......
## Process this file with automake to produce Makefile.in
SUBDIRS=libcharset
if HAVE_GOOD_PRINTF
else
TRIO_SUBDIR = trio
endif
SUBDIRS = libcharset $(TRIO_SUBDIR)
DIST_SUBDIRS = libcharset trio
INCLUDES = -I$(top_srcdir) -DG_LOG_DOMAIN=\"GLib\" \
@GLIB_DEBUG_FLAGS@ -DG_DISABLE_DEPRECATED -DGLIB_COMPILATION
......@@ -82,7 +89,9 @@ libglib_2_0_la_SOURCES = \
gunidecomp.h \
gunidecomp.c \
gutils.c \
gdebug.h
gdebug.h \
gprintf.c \
gprintfint.h
EXTRA_libglib_2_0_la_SOURCES = \
giounix.c \
......@@ -140,7 +149,8 @@ glibsubinclude_HEADERS = \
gtypes.h \
gunicode.h \
gutils.h \
gwin32.h
gwin32.h \
gprintf.h
install-data-local: install-ms-lib install-libtool-import-lib
@if test -f $(glibincludedir)/glist.h ; then \
......
......@@ -38,6 +38,8 @@
#include <stdio.h>
#include <stdlib.h>
#include "glib.h"
#include "gprintfint.h"
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
......@@ -98,19 +100,19 @@ g_on_error_query (const gchar *prg_name)
retry:
if (prg_name)
fprintf (stdout,
"%s (pid:%u): %s%s%s: ",
prg_name,
(guint) getpid (),
query1,
query2,
query3);
_g_fprintf (stdout,
"%s (pid:%u): %s%s%s: ",
prg_name,
(guint) getpid (),
query1,
query2,
query3);
else
fprintf (stdout,
"(process:%u): %s%s: ",
(guint) getpid (),
query1,
query3);
_g_fprintf (stdout,
"(process:%u): %s%s: ",
(guint) getpid (),
query1,
query3);
fflush (stdout);
if (isatty(0) && isatty(1))
......@@ -163,7 +165,7 @@ g_on_error_stack_trace (const gchar *prg_name)
if (!prg_name)
return;
sprintf (buf, "%u", (guint) getpid ());
_g_sprintf (buf, "%u", (guint) getpid ());
args[1] = (gchar*) prg_name;
args[2] = buf;
......@@ -276,7 +278,7 @@ stack_trace (char **args)
if ((c == '\n') || (c == '\r'))
{
buffer[index] = 0;
fprintf (stdout, "%s", buffer);
_g_fprintf (stdout, "%s", buffer);
state = 0;
index = 0;
}
......
......@@ -29,6 +29,7 @@
#include <stdlib.h>
#include "glib.h"
#include "gprintfint.h"
#ifdef G_PLATFORM_WIN32
#define STRICT
......@@ -338,7 +339,7 @@ open_converter (const gchar *to_codeset,
/* create our key */
key = g_alloca (strlen (from_codeset) + strlen (to_codeset) + 2);
sprintf (key, "%s:%s", from_codeset, to_codeset);
_g_sprintf (key, "%s:%s", from_codeset, to_codeset);
G_LOCK (iconv_cache_lock);
......
......@@ -44,6 +44,7 @@
#include <locale.h>
#include <errno.h>
#include "gdebug.h"
#include "gprintfint.h"
#ifdef G_OS_WIN32
typedef FILE* GFileDescriptor;
......@@ -71,14 +72,6 @@ struct _GLogHandler
};
/* --- prototypes --- */
#ifndef HAVE_C99_VSNPRINTF
static gsize printf_string_upper_bound (const gchar *format,
gboolean may_warn,
va_list args);
#endif /* !HAVE_C99_VSNPRINTF */
/* --- variables --- */
static GMutex *g_messages_lock = NULL;
static GLogDomain *g_log_domains = NULL;
......@@ -409,10 +402,6 @@ g_logv (const gchar *log_domain,
gboolean was_recursion = (log_level & G_LOG_FLAG_RECURSION) != 0;
gint i;
#ifndef HAVE_VSNPRINTF
va_list args2;
#endif /* HAVE_VSNPRINTF */
log_level &= G_LOG_LEVEL_MASK;
if (!log_level)
return;
......@@ -420,21 +409,7 @@ g_logv (const gchar *log_domain,
/* we use a stack buffer of fixed size, because we might get called
* 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(). */
/* we are out of luck here */
strncpy (buffer, format, 1024);
buffer[1024] = 0;
}
va_end (args2);
#endif /* !HAVE_VSNPRINTF */
_g_vsnprintf (buffer, 1024, format, args1);
for (i = g_bit_nth_msf (log_level, -1); i >= 0; i = g_bit_nth_msf (log_level, i))
{
......@@ -548,7 +523,7 @@ strdup_convert (const gchar *string,
if (!warned)
{
warned = TRUE;
fprintf (stderr, "GLib: Cannot convert message: %s\n", err->message);
_g_fprintf (stderr, "GLib: Cannot convert message: %s\n", err->message);
}
g_error_free (err);
......@@ -909,333 +884,12 @@ g_printerr (const gchar *format,
g_free (string);
}
#ifndef MB_LEN_MAX
# define MB_LEN_MAX 8
#endif
#ifndef HAVE_C99_VSNPRINTF
typedef struct
{
guint min_width;
guint precision;
gboolean alternate_format, zero_padding, adjust_left, locale_grouping;
gboolean add_space, add_sign, possible_sign, seen_precision;
gboolean mod_half, mod_long, mod_extra_long;
} PrintfArgSpec;
static gsize
printf_string_upper_bound (const gchar *format,
gboolean may_warn,
va_list args)
{
static const gboolean honour_longs = SIZEOF_LONG > 4 || SIZEOF_VOID_P > 4;
gsize len = 1;
if (!format)
return len;
while (*format)
{
register gchar c = *format++;