Rick, thanks, this makes the tests run fine.
Committed revision [r11076].
On Wed, Jun 29, 2016 at 4:39 PM, Rick McGuire <[email protected]> wrote:
> Ok, here's a bit more robust fix. This patch also eliminates the compile
> warnings for this file.
>
> Index: interpreter/classes/NumberStringClass.cpp
> ===================================================================
> --- interpreter/classes/NumberStringClass.cpp (revision 11074)
> +++ interpreter/classes/NumberStringClass.cpp (working copy)
> @@ -2329,8 +2329,8 @@
> }
>
> inline bool atEnd() { return current >= end; }
> - inline unsigned int getChar() { return (unsigned char)*current;}
> - inline unsigned int nextChar() { return (unsigned char)*current++; }
> + inline char getChar() { return *current;}
> + inline char nextChar() { return *current++; }
> inline void stepPosition() { current++; }
> inline bool moreChars() { return current < end; }
>
> @@ -2366,6 +2366,7 @@
> // digit.
> scannedDigits = 0;
> haveNonZero = false;
> + invalidExponent = false;
> }
>
> void addDigit(char d)
> @@ -2424,7 +2425,19 @@
>
> void addExponentDigit(char d)
> {
> - exponent = (exponent * 10) + (d - RexxString::ch_ZERO);
> + wholenumber_t new_exponent = (exponent * 10) + (d -
> RexxString::ch_ZERO);
> + // now we need to check for an exponent that is too large or one that
> + // caused an overflow
> + if (new_exponent > Numerics::MAX_EXPONENT || new_exponent < exponent)
> + {
> + // set this to an invalid exponent so we can flag this as
> invalid later
> + invalidExponent = true;
> + }
> + else
> + {
> + // this is a good value (so far)
> + exponent = new_exponent;
> + }
> }
>
> bool finish()
> @@ -2443,15 +2456,27 @@
> number->setZero();
> return true;
> }
> +
> + // if the exponent was larger than 9-nines, this is invalid
> + if (invalidExponent)
> + {
> + return false;
> + }
> +
> // set the count of digits in the number
> number->digitsCount = current - number->numberDigits;
> // get the final exponent value
> number->numberExponent = (exponent * exponentSign) - decimals;
> // a couple of final exponent checks
> + // since the number of decimals enters into the exponent, we need to
> + // verify that the calculated exponent did not cause an underflow
> if (Numerics::abs(number->numberExponent) > Numerics::MAX_EXPONENT)
> {
> return false;
> }
> +
> + // we can also go the other way, where the number of digits can
> cause the exponent
> + // to overflow if expressed in scientific notation.
> if ((number->numberExponent + number->digitsCount - 1) >
> Numerics::MAX_EXPONENT)
> {
> return false;
> @@ -2468,6 +2493,7 @@
> wholenumber_t decimals; // the decimal shift on the exponent
> wholenumber_t scannedDigits; // indicate we've seen digits
> bool haveNonZero; // we've seen a non-zero digit
> + bool invalidExponent; // the exponent is larger than
> 9-nines
> };
>
>
> @@ -2492,7 +2518,7 @@
> NumberStringBuilder builder(this);
>
> // get the current character to start this off
> - unsigned int inch = scanner.getChar();
> + char inch = scanner.getChar();
> // ok, loop through the token until we've consumed it all.
> for (;;)
> {
>
>
> On Wed, Jun 29, 2016 at 10:06 AM, Erich Steinböck <
> [email protected]> wrote:
>
>> Rick, with this patch applied (on both 32- and 64-bit) two failing sign()
>> tests uncover the following invalid behaviour:
>>
>> rexx -e "do e = 1 to 25; n = '0.1e'||1~copies(e); say n~dataType~left(4)
>> n; end;"
>> NUM 0.1e1
>> NUM 0.1e11
>> NUM 0.1e111
>> NUM 0.1e1111
>> NUM 0.1e11111
>> NUM 0.1e111111
>> NUM 0.1e1111111
>> NUM 0.1e11111111
>> NUM 0.1e111111111
>> NUM 0.1e1111111111
>> NUM 0.1e11111111111
>> NUM 0.1e111111111111
>> NUM 0.1e1111111111111
>> NUM 0.1e11111111111111
>> NUM 0.1e111111111111111
>> NUM 0.1e1111111111111111
>> NUM 0.1e11111111111111111
>> NUM 0.1e111111111111111111
>> NUM 0.1e1111111111111111111
>> NUM 0.1e11111111111111111111
>> NUM 0.1e111111111111111111111
>> NUM 0.1e1111111111111111111111
>> NUM 0.1e11111111111111111111111
>> NUM 0.1e111111111111111111111111
>> NUM 0.1e1111111111111111111111111
>>
>>
>> On Wed, Jun 29, 2016 at 12:38 AM, Rick McGuire <[email protected]>
>> wrote:
>>
>>> Having some issues with building a 32-bit version currently so I can't
>>> test this out, but I suspect this patch will fix this problem.
>>>
>>> Index: interpreter/classes/NumberStringClass.cpp
>>> ===================================================================
>>> --- interpreter/classes/NumberStringClass.cpp (revision 11070)
>>> +++ interpreter/classes/NumberStringClass.cpp (working copy)
>>> @@ -2422,9 +2422,31 @@
>>> exponentSign = s == RexxString::ch_MINUS ? -1 : 1;
>>> }
>>>
>>> + /**
>>> + * Add an exponent digit to this scan. This also validates
>>> + * the size of the exponent with each addition.
>>> + *
>>> + * @param d The next character in the exponent.
>>> + */
>>> void addExponentDigit(char d)
>>> {
>>> - exponent = (exponent * 10) + (d - RexxString::ch_ZERO);
>>> + // if the exponent is still valid, add this digit
>>> + if (exponent <= Numerics::MAX_EXPONENT)
>>> + {
>>> + wholenumber_t new_exponent = (exponent * 10) + (d -
>>> RexxString::ch_ZERO);
>>> + // now we need to check for an exponent that is too large or
>>> one that
>>> + // caused an overflow
>>> + if (new_exponent > Numerics::MAX_EXPONENT || new_exponent <
>>> exponent)
>>> + {
>>> + // set this to an invalid exponent so we can flag this as
>>> invalid later
>>> + exponent = Numerics::MAX_EXPONENT + 1;
>>> + }
>>> + else
>>> + {
>>> + // this is a good value (so far)
>>> + exponent = new_exponent;
>>> + }
>>> + }
>>> }
>>>
>>> bool finish()
>>>
>>>
>>> On Tue, Jun 28, 2016 at 3:07 PM, Erich Steinböck <
>>> [email protected]> wrote:
>>>
>>>> I have a suspicion this test in NumberString::checkIntengerDigits is
>>>>> wrong.
>>>>>
>>>> Yes, that was exactly what was needed!!!
>>>> Thanks, saved me a *lot* of time to investigate.
>>>>
>>>>
>>>> Now, there's a strange last one, again 32-bit-only, issue left:
>>>>
>>>> rexx -e "do e = 1 to 25; n = '123e'||1~copies(e); say
>>>> n~dataType~left(4) n; end;"
>>>> NUM 123e1
>>>> NUM 123e11
>>>> NUM 123e111
>>>> NUM 123e1111
>>>> NUM 123e11111
>>>> NUM 123e111111
>>>> NUM 123e1111111
>>>> NUM 123e11111111
>>>> NUM 123e111111111
>>>> CHAR 123e1111111111
>>>> CHAR 123e11111111111
>>>> NUM 123e111111111111
>>>> CHAR 123e1111111111111
>>>> NUM 123e11111111111111
>>>> NUM 123e111111111111111
>>>> CHAR 123e1111111111111111
>>>> NUM 123e11111111111111111
>>>> CHAR 123e111111111111111111
>>>> NUM 123e1111111111111111111
>>>> CHAR 123e11111111111111111111
>>>> NUM 123e111111111111111111111
>>>> NUM 123e1111111111111111111111
>>>> CHAR 123e11111111111111111111111
>>>> CHAR 123e111111111111111111111111
>>>> CHAR 123e1111111111111111111111111
>>>>
>>>>
>>
>> ------------------------------------------------------------------------------
>> Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
>> Francisco, CA to explore cutting-edge tech and listen to tech luminaries
>> present their vision of the future. This family event has something for
>> everyone, including kids. Get more information and register today.
>> http://sdm.link/attshape
>> _______________________________________________
>> Oorexx-devel mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/oorexx-devel
>>
>>
>
>
> ------------------------------------------------------------------------------
> Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
> Francisco, CA to explore cutting-edge tech and listen to tech luminaries
> present their vision of the future. This family event has something for
> everyone, including kids. Get more information and register today.
> http://sdm.link/attshape
> _______________________________________________
> Oorexx-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/oorexx-devel
>
>
------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
Oorexx-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/oorexx-devel