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