| 13718 | |
| 13719 | |
| 13720 | static int str_sub (lua_State *L) { |
| 13721 | size_t l; |
| 13722 | const char *s = luaL_checklstring(L, 1, &l); |
| 13723 | ptrdiff_t start = posrelat(luaL_checkinteger(L, 2), l); |
| 13724 | ptrdiff_t end = posrelat(luaL_optinteger(L, 3, -1), l); |
| 13725 | if (start < 1) start = 1; |
| 13726 | if (end > (ptrdiff_t)l) end = (ptrdiff_t)l; |
| 13727 | if (start <= end) |
| 13728 | lua_pushlstring(L, s+start-1, end-start+1); |
| 13729 | else lua_pushliteral(L, ""); |
| 13730 | return 1; |
| 13731 | } |
| 13732 | |
| 13733 | |
| 13734 | static int str_reverse (lua_State *L) { |
nothing calls this directly
no test coverage detected