| 51 | |
| 52 | |
| 53 | static int str_sub (lua_State *L) { |
| 54 | size_t l; |
| 55 | const char *s = luaL_checklstring(L, 1, &l); |
| 56 | size_t start = posrelat(luaL_checkinteger(L, 2), l); |
| 57 | size_t end = posrelat(luaL_optinteger(L, 3, -1), l); |
| 58 | if (start < 1) start = 1; |
| 59 | if (end > l) end = l; |
| 60 | if (start <= end) |
| 61 | lua_pushlstring(L, s + start - 1, end - start + 1); |
| 62 | else lua_pushliteral(L, ""); |
| 63 | return 1; |
| 64 | } |
| 65 | |
| 66 | |
| 67 | static int str_reverse (lua_State *L) { |
nothing calls this directly
no test coverage detected