lua-users home
lua-l archive

Lua 5.1.3 bug in string.byte

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


The range check logic in string.byte is broken:
$ lua -e 'for i=5,-10,-1 do print(i, string.byte("abc", i)) end'
5
4
3 99
2 98
1 97
0
-1 99
-2 98
-3 97
-4
-5 97 98 99 <--- Unexpected results for -#str-2 and lower
-6 97 98
-7 97
-8
-9 97 98 99
-10 97 98 99
--Mike

AltStyle によって変換されたページ (->オリジナル) /