| 789 | |
| 790 | |
| 791 | static int luaB_range (lua_State *L) { |
| 792 | lua_Integer start, end, step; |
| 793 | if (!lua_isnoneornil(L, 2)) { |
| 794 | start = luaL_checkinteger(L, 1); |
| 795 | end = luaL_checkinteger(L, 2); |
| 796 | step = luaL_optinteger(L, 3, 1); |
| 797 | } |
| 798 | else { |
| 799 | start = 1; |
| 800 | end = luaL_checkinteger(L, 1); |
| 801 | step = 1; |
| 802 | } |
| 803 | |
| 804 | lua_createtable(L, cast(int, end - start), 0); |
| 805 | lua_Integer idx = 1; |
| 806 | for (lua_Integer i = start; i <= end; i += step, ++idx) { |
| 807 | lua_pushinteger(L, i); |
| 808 | lua_rawseti(L, -2, idx); |
| 809 | L->checkEtl(); |
| 810 | } |
| 811 | return 1; |
| 812 | } |
| 813 | |
| 814 | |
| 815 | static int luaB_sdiv (lua_State *L) { |
nothing calls this directly
no outgoing calls
no test coverage detected