MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / codepoint

Function codepoint

third-party/lua-5.5.0/src/lutf8lib.c:117–143  ·  view source on GitHub ↗

** codepoint(s, [i, [j [, lax]]]) -> returns codepoints for all ** characters that start in the range [i,j] */

Source from the content-addressed store, hash-verified

115** characters that start in the range [i,j]
116*/
117static int codepoint (lua_State *L) {
118 size_t len;
119 const char *s = luaL_checklstring(L, 1, &len);
120 lua_Integer posi = u_posrelat(luaL_optinteger(L, 2, 1), len);
121 lua_Integer pose = u_posrelat(luaL_optinteger(L, 3, posi), len);
122 int lax = lua_toboolean(L, 4);
123 int n;
124 const char *se;
125 luaL_argcheck(L, posi >= 1, 2, "out of bounds");
126 luaL_argcheck(L, pose <= (lua_Integer)len, 3, "out of bounds");
127 if (posi > pose) return 0; /* empty interval; return no values */
128 if (pose - posi >= INT_MAX) /* (lua_Integer -> int) overflow? */
129 return luaL_error(L, "string slice too long");
130 n = (int)(pose - posi) + 1; /* upper bound for number of returns */
131 luaL_checkstack(L, n, "string slice too long");
132 n = 0; /* count the number of returns */
133 se = s + pose; /* string end */
134 for (s += posi - 1; s < se;) {
135 l_uint32 code;
136 s = utf8_decode(s, &code, !lax);
137 if (s == NULL)
138 return luaL_error(L, MSGInvalid);
139 lua_pushinteger(L, l_castU2S(code));
140 n++;
141 }
142 return n;
143}
144
145
146static void pushutfchar (lua_State *L, int arg) {

Callers

nothing calls this directly

Calls 8

luaL_checklstringFunction · 0.70
u_posrelatFunction · 0.70
luaL_optintegerFunction · 0.70
lua_tobooleanFunction · 0.70
luaL_errorFunction · 0.70
luaL_checkstackFunction · 0.70
utf8_decodeFunction · 0.70
lua_pushintegerFunction · 0.70

Tested by

no test coverage detected