[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gawk] Overflow to Infinity
From: |
arnold |
Subject: |
Re: [bug-gawk] Overflow to Infinity |
Date: |
Fri, 22 Jun 2018 03:15:16 -0600 |
User-agent: |
Heirloom mailx 12.4 7/29/08 |
Hi Andy.
> So gawk sets the numeric value to zero and decides that the input is
> actually a string, not a number.
Yes.
> I'm not sure about the language lawyering on this topic. Perhaps one could
> argue that an exception should be made for ERANGE.
This thread had brought up two issues. Input is not getting converted
"correctly", and gawk can output "inf" and/or "nan" since it relies on
the output of the C library printf in such cases.
I am going to delay dealing with the second issue for now.
> With this patch, gawk does what you want (on my Linux system):
>
> diff --git a/node.c b/node.c
> index fcd2bf3..b879e64 100644
> --- a/node.c
> +++ b/node.c
> @@ -140,7 +140,7 @@ r_force_number(NODE *n)
> *cpend = save;
> }
>
> - if (errno == 0) {
> + if (errno == 0 || errno == ERANGE){
You need a space between the close paren and the open brace.
> Note: I'm not sure whether this patch is ideal, since it neglects to
> reset errno to zero, as happens in the "else" clause. I don't know whether
> that errno reset is actually needed...
Reseting errno won't hurt and should probably be done.
Andy, please update your patch and go ahead and push it to gawk-4.2-stable.
Let's use Daniel's code as a new test case also, once you've added in
your patch. Can you handle that for me?
I want to think some more about handling output.
Thanks,
Arnold
Re: [bug-gawk] Overflow to Infinity, Daniel Pettet, 2018/06/19