MCPcopy Create free account
hub / github.com/F-Stack/f-stack / str_byte

Function str_byte

app/redis-6.2.6/deps/lua/src/lstrlib.c:106–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104
105
106static int str_byte (lua_State *L) {
107 size_t l;
108 const char *s = luaL_checklstring(L, 1, &l);
109 ptrdiff_t posi = posrelat(luaL_optinteger(L, 2, 1), l);
110 ptrdiff_t pose = posrelat(luaL_optinteger(L, 3, posi), l);
111 int n, i;
112 if (posi <= 0) posi = 1;
113 if ((size_t)pose > l) pose = l;
114 if (posi > pose) return 0; /* empty interval; return no values */
115 n = (int)(pose - posi + 1);
116 if (posi + n <= pose) /* overflow? */
117 luaL_error(L, "string slice too long");
118 luaL_checkstack(L, n, "string slice too long");
119 for (i=0; i<n; i++)
120 lua_pushinteger(L, uchar(s[posi+i-1]));
121 return n;
122}
123
124
125static int str_char (lua_State *L) {

Callers

nothing calls this directly

Calls 6

luaL_checklstringFunction · 0.70
posrelatFunction · 0.70
luaL_optintegerFunction · 0.70
luaL_errorFunction · 0.70
luaL_checkstackFunction · 0.70
lua_pushintegerFunction · 0.70

Tested by

no test coverage detected