lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Sorry for the multiple posts, next time I will try to devise more test
situations before posting patches. Though, in fairness, all the errors I
knew about at the time were being solved by the patches... I just failed
to take into account the pathological conditions! :)

Attached to this post is a patch file (loopfix.patch) and a test file
(loopfix-test.lua) for testing the various edge cases. All integer and
floating-point loops with a step size from 1 to maxindex, positive or
negative, should work without encountering any overflow situations. The test
script runs a variety of sample loops in both decimal and floating contexts
and tests both the number of iterations and the expected results.

The only real change from the previous patch is the addition of a cast and
the modification of the 'intop' macro. I created a new 'uintop' macro and
changed 'intop' to use it. This allows me to compare the unsigned loop
remainder with the unsigned step size, if the remaining loop size is greater
or equal to the step size then the loop will iterate.

Thanks for the comments and help with debugging the patch... I do believe it
should be fully working at this point. However, if anyone does find any edge
cases that need to be addressed please let me know! For those who use the
Lua Test Suite I also attached a patch file (loopfix-test-db.patch) to fix
the 'test\db.lua' file.

~Paige

Attachment: loopfix.patch
Description: Binary data

 

Attachment: loopfix-test.lua
Description: Binary data

Attachment: loopfix-test-db.patch
Description: Binary data