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