| 61 | |
| 62 | |
| 63 | static int str_sub (lua_State *L) { |
| 64 | size_t l; |
| 65 | const char *s = luaL_checklstring(L, 1, &l); |
| 66 | size_t start = posrelat(luaL_checkinteger(L, 2), l); |
| 67 | size_t end = posrelat(luaL_optinteger(L, 3, -1), l); |
| 68 | if (start < 1) start = 1; |
| 69 | if (end > l) end = l; |
| 70 | if (start <= end) |
| 71 | lua_pushlstring(L, s + start - 1, end - start + 1); |
| 72 | else lua_pushliteral(L, ""); |
| 73 | return 1; |
| 74 | } |
| 75 | |
| 76 | |
| 77 | static int str_reverse (lua_State *L) { |
nothing calls this directly
no test coverage detected