Skip to content

Commit

Permalink
perlapi: Combine Strtod, my_strtod
Browse files Browse the repository at this point in the history
And clarify the pod
  • Loading branch information
khwilliamson committed Jul 1, 2024
1 parent c714cf1 commit f841d64
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
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 @@ -7915,9 +7915,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

0 comments on commit f841d64

Please sign in to comment.