| 41 | |
| 42 | |
| 43 | static int str_sub (lua_State *L) { |
| 44 | size_t l; |
| 45 | const char *s = luaL_checklstring(L, 1, &l); |
| 46 | ptrdiff_t start = posrelat(luaL_checkinteger(L, 2), l); |
| 47 | ptrdiff_t end = posrelat(luaL_optinteger(L, 3, -1), l); |
| 48 | if (start < 1) start = 1; |
| 49 | if (end > (ptrdiff_t)l) end = (ptrdiff_t)l; |
| 50 | if (start <= end) |
| 51 | lua_pushlstring(L, s+start-1, end-start+1); |
| 52 | else lua_pushliteral(L, ""); |
| 53 | return 1; |
| 54 | } |
| 55 | |
| 56 | |
| 57 | static int str_reverse (lua_State *L) { |
nothing calls this directly
no test coverage detected