* glib/gutils.c (g_snprintf, g_vsnprintf): Switch to C99-[v]snprintf().

        * tests/strfunc-test.c: Add some tests for g_snprintf().
This commit is contained in:
Matthias Clasen
2001-12-12 22:05:55 +00:00
parent 3fa33317b7
commit a99e75d0a8
12 changed files with 123 additions and 60 deletions

View File

@@ -173,17 +173,28 @@ See also g_strdup_printf().
<note>
<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.
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>
<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 null
@n: the maximum number of characters to produce (including the terminating nul
character).
@format: the format string. See the <function>sprintf()</function>
@format: the format string. See the <function>sprintf()</function>.
documentation.
@Varargs: the arguments to insert in the output.
@Returns: the length of the output string.
@Returns: the number of characters which would be produced if the buffer was
large enough.
<!-- ##### FUNCTION g_vsnprintf ##### -->
@@ -200,16 +211,27 @@ See also g_strdup_vprintf().
<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>
<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 null
@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 length of the output string.
@Returns: the number of characters which would be produced if the buffer was
large enough.
<!-- ##### FUNCTION g_printf_string_upper_bound ##### -->