Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perlapi: Combine Strtod, my_strtod #22349

Merged
merged 1 commit into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 25 additions & 9 deletions numeric.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,34 @@ S_strtod(pTHX_ const char * const s, char ** e)

/*

=for apidoc my_strtod
=for apidoc my_strtod
=for apidoc_item Strtod

This function is equivalent to the libc strtod() function, and is available
even on platforms that lack plain strtod(). Its return value is the best
available precision depending on platform capabilities and F<Configure>
options.
These are identical.

They act like the libc C<L<strtod(3)>> function, with three exceptions:

=over

=item 1.

Their return value is an NV. Plain C<strod> returns a double precision value.

=item 2.

Plain C<strtod> always is expecting the radix character (or string) to be the
one specified by the underlying locale the program is executing in. This is
almost universally a dot (U+002E) or a comma (U+002C).

In contrast, these expect the radix to be a dot, except when called from within
the scope of S<C<use locale>>, in which case they act like plain C<strtod>,
expecting the radix to be that specified by the current locale.

=item 3.

It properly handles the locale radix character, meaning it expects a dot except
when called from within the scope of S<C<use locale>>, in which case the radix
character should be that specified by the current locale.
These are are available even on platforms that lack plain strtod().

The synonym Strtod() may be used instead.
=back

=cut

Expand Down
4 changes: 1 addition & 3 deletions perl.h
Original file line number Diff line number Diff line change
Expand Up @@ -7910,9 +7910,7 @@ END_EXTERN_C

=for apidoc_section $numeric

=for apidoc AmTR|NV|Strtod|NN const char * const s|NULLOK char ** e

This is a synonym for L</my_strtod>.
=for apidoc_defn AmTR|NV|Strtod|NN const char * const s|NULLOK char **e

=for apidoc AmTR|NV|Strtol|NN const char * const s|NULLOK char ** e|int base

Expand Down
1 change: 1 addition & 0 deletions t/porting/known_pod_issues.dat
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ String::Base
String::Scanf
String::Util
strstr(3)
strtod(3)
strtok(3)
strtol(3)
Switch
Expand Down