rzel / kahlua

Automatically exported from code.google.com/p/kahlua
0 stars 0 forks source link

string.sub does not accept out-of-range parameters #23

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
the following tests fail in kahlua, on StringIndexOutOfRangeException:

s = "Hello world"
testAssertEqual(s:sub(-500,500),"Hello world")
testAssertEqual(s:sub(#s + 1, 1000),"")

official Lua can eat those numbers without trouble, it seems to limit
itself to string length automatically.

the attached patch implements this behavior

Original issue reported on code.google.com by matej...@gmail.com on 8 Apr 2010 at 10:00

Attachments:

GoogleCodeExporter commented 8 years ago
Accepted the bug.

The patch looks ok, but I'll need to analyze it a bit more before I commit a fix
(which will most likely be a derivation of your patch).

Original comment by kristofer.karlsson@gmail.com on 9 Apr 2010 at 6:24

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r235.

Original comment by kristofer.karlsson@gmail.com on 9 Apr 2010 at 12:47

GoogleCodeExporter commented 8 years ago
Fixed, almost the same patch as you suggested.

Original comment by kristofer.karlsson@gmail.com on 9 Apr 2010 at 12:48