mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-16 12:45:13 +01:00
Improve g_ascii_formatd docs and preconditions
This commit is contained in:
parent
185e0565e0
commit
6749b343fe
@ -927,7 +927,7 @@ g_ascii_dtostr (gchar *buffer,
|
|||||||
* @buffer: A buffer to place the resulting string in
|
* @buffer: A buffer to place the resulting string in
|
||||||
* @buf_len: The length of the buffer.
|
* @buf_len: The length of the buffer.
|
||||||
* @format: The printf()-style format to use for the
|
* @format: The printf()-style format to use for the
|
||||||
* code to use for converting.
|
* code to use for converting
|
||||||
* @d: The #gdouble to convert
|
* @d: The #gdouble to convert
|
||||||
*
|
*
|
||||||
* Converts a #gdouble to a string, using the '.' as
|
* Converts a #gdouble to a string, using the '.' as
|
||||||
@ -935,6 +935,9 @@ g_ascii_dtostr (gchar *buffer,
|
|||||||
* a printf()-style format string. Allowed conversion
|
* a printf()-style format string. Allowed conversion
|
||||||
* specifiers are 'e', 'E', 'f', 'F', 'g' and 'G'.
|
* specifiers are 'e', 'E', 'f', 'F', 'g' and 'G'.
|
||||||
*
|
*
|
||||||
|
* The @format must just be a single format specifier
|
||||||
|
* starting with `%`, expecting a #gdouble argument.
|
||||||
|
*
|
||||||
* The returned buffer is guaranteed to be nul-terminated.
|
* The returned buffer is guaranteed to be nul-terminated.
|
||||||
*
|
*
|
||||||
* If you just want to want to serialize the value into a
|
* If you just want to want to serialize the value into a
|
||||||
@ -951,6 +954,10 @@ g_ascii_formatd (gchar *buffer,
|
|||||||
#ifdef USE_XLOCALE
|
#ifdef USE_XLOCALE
|
||||||
locale_t old_locale;
|
locale_t old_locale;
|
||||||
|
|
||||||
|
g_return_val_if_fail (buffer != NULL, NULL);
|
||||||
|
g_return_val_if_fail (format[0] == '%', NULL);
|
||||||
|
g_return_val_if_fail (strpbrk (format + 1, "'l%") == NULL, NULL);
|
||||||
|
|
||||||
old_locale = uselocale (get_C_locale ());
|
old_locale = uselocale (get_C_locale ());
|
||||||
_g_snprintf (buffer, buf_len, format, d);
|
_g_snprintf (buffer, buf_len, format, d);
|
||||||
uselocale (old_locale);
|
uselocale (old_locale);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user