-
Notifications
You must be signed in to change notification settings - Fork 190
fix: to_num_from_stream pointer position correction #1000
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
Conversation
@@ -109,7 +109,7 @@ module stdlib_str2num | |||
integer(int8) :: err | |||
!---------------------------------------------- | |||
call to_num_base(s,v,p,err) | |||
p = min( p , len(s, kind = int8) ) | |||
p = min( p , len(s) ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As p
is declared as integer(int8)
, similar issues might still happen. Maybe also declare p
as integer :: p
? Or do you think it is not needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not needed as the kind is converted as an output of min
. It could happen if an individual number is written on more than 127 characters. But even a quad number would fit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @jalvesz . LGTM. See my suggestion below.
This PR fixes the computation of the position in a character stream for the
to_num_from_stream
function to properly advance when the character is a long chain. Otherwise, negative numbers can be obtained fromlen(s, lind=int8)
if the string is in effect larger than 127.