Add g_strtod & co.

2001-10-24  Alex Larsson  <alexl@redhat.com>

	* docs/reference/glib/glib-sections.txt:
	Add g_strtod & co.

	* docs/reference/glib/tmpl/string_utils.sgml:
	Add docs for G_ASCII_DTOSTR_BUF_SIZE.

	* glib/gstrfuncs.[ch]:
	Added g_ascii_strtod, g_ascii_dtostr and g_ascii_formatd.

	* tests/Makefile.am:
	* tests/strtod-test.c:
	Add tests for g_ascii_strtod & co.
This commit is contained in:
Alex Larsson
2001-10-24 18:00:11 +00:00
committed by Alexander Larsson
parent b0facb3863
commit 3c39c8fcd0
14 changed files with 557 additions and 26 deletions

View File

@@ -922,6 +922,12 @@ g_strncasecmp
<SUBSECTION>
g_strreverse
<SUBSECTION>
G_ASCII_DTOSTR_BUF_SIZE
g_ascii_strtod
g_ascii_dtostr
g_ascii_formatd
g_strtod
<SUBSECTION>

View File

@@ -562,19 +562,68 @@ For example, g_strreverse ("abcdef") will result in "fedcba".
@Returns: the same pointer passed in as @string.
<!-- ##### FUNCTION g_strtod ##### -->
<!-- ##### MACRO G_ASCII_DTOSTR_BUF_SIZE ##### -->
<para>
Converts a string to a gdouble value.
It calls the standard <function>strtod()</function> function
to handle the conversion, but if the string is not completely converted
it attempts the conversion again in the "C" locale, and returns the best
match.
A good size for a buffer to be passed into <function>g_ascii_dtostr</function>.
It is guaranteed to be enough for all output of that function on systems with
64bit IEEE compatible doubles.
</para>
<para>
The typical usage would be something like:
</para>
<para>
<literal>
char buf[G_ASCII_DTOSTR_BUF_SIZE];
fprintf (out, "value=%s\n", g_ascii_dtostr (buf, sizeof (buf), value));
</literal>
</para>
@nptr: the string to convert to a numeric value.
@endptr: if non-NULL, it returns the character after the last character used
in the conversion.
@Returns: the gdouble value.
<!-- ##### FUNCTION g_ascii_strtod ##### -->
<para>
</para>
@nptr:
@endptr:
@Returns:
<!-- ##### FUNCTION g_ascii_dtostr ##### -->
<para>
</para>
@buffer:
@buf_len:
@d:
@Returns:
<!-- # Unused Parameters # -->
@format:
<!-- ##### FUNCTION g_ascii_formatd ##### -->
<para>
</para>
@buffer:
@buf_len:
@format:
@d:
@Returns:
<!-- ##### FUNCTION g_strtod ##### -->
<para>
</para>
@nptr:
@endptr:
@Returns:
<!-- ##### FUNCTION g_strchug ##### -->