23#define MAXUNICODE 0x10FFFF
25#define iscont(p) ((*(p) & 0xC0) == 0x80)
31 if (pos >= 0)
return pos;
32 else if (0u - (
size_t)pos > len)
return 0;
41 static const unsigned int limits[] = {0xFF, 0x7F, 0x7FF, 0xFFFF};
42 const unsigned char *
s = (
const unsigned char *)o;
43 unsigned int c =
s[0];
51 if ((cc & 0xC0) != 0x80)
53 res = (res << 6) | (cc & 0x3F);
56 res |= ((c & 0x7F) << (count * 5));
57 if (count > 3 || res >
MAXUNICODE || res <= limits[count])
62 return (
const char *)
s + 1;
78 "initial position out of string");
80 "final position out of string");
81 while (posi <= posj) {
109 if (posi > pose)
return 0;
110 if (pose - posi >= INT_MAX)
111 return luaL_error(L,
"string slice too long");
112 n = (int)(pose - posi) + 1;
116 for (
s += posi - 1;
s < se;) {
146 for (i = 1; i <= n; i++) {
167 "position out of range");
170 while (posi > 0 &&
iscont(
s + posi)) posi--;
174 return luaL_error(L,
"initial position is a continuation byte");
176 while (n < 0 && posi > 0) {
179 }
while (posi > 0 &&
iscont(
s + posi));
235#define UTF8PATT "[\0-\x7F\xC2-\xF4][\x80-\xBF]*"
245 {
"charpattern",
NULL},
CURL_EXTERN int void * arg
LUA_API void lua_pushnil(lua_State *L)
LUA_API const char * lua_pushfstring(lua_State *L, const char *fmt,...)
LUA_API void lua_setfield(lua_State *L, int idx, const char *k)
LUA_API void lua_pushvalue(lua_State *L, int idx)
LUA_API void lua_pushlstring(lua_State *L, const char *s, size_t len)
LUA_API void lua_pushinteger(lua_State *L, lua_Integer n)
LUA_API int lua_gettop(lua_State *L)
LUALIB_API void luaL_buffinit(lua_State *L, luaL_Buffer *B)
LUALIB_API void luaL_checkstack(lua_State *L, int space, const char *mes)
LUALIB_API void luaL_pushresult(luaL_Buffer *B)
LUALIB_API void luaL_addvalue(luaL_Buffer *B)
LUALIB_API int luaL_error(lua_State *L, const char *fmt,...)
LUALIB_API lua_Integer luaL_checkinteger(lua_State *L, int narg)
LUALIB_API lua_Integer luaL_optinteger(lua_State *L, int narg, lua_Integer def)
LUALIB_API const char * luaL_checklstring(lua_State *L, int narg, size_t *len)
#define luaL_checkstring(L, n)
#define luaL_argcheck(L, cond, numarg, extramsg)
#define lua_pushcfunction(L, f)
#define luaL_newlib(L, l)
#define lua_tointeger(L, i)
static int iter_aux(lua_State *L)
static void pushutfchar(lua_State *L, int arg)
static int utfchar(lua_State *L)
static int byteoffset(lua_State *L)
static int utflen(lua_State *L)
static const char * utf8_decode(const char *o, int *val)
static const luaL_Reg funcs[]
static int iter_codes(lua_State *L)
static lua_Integer u_posrelat(lua_Integer pos, size_t len)
LUAMOD_API int luaopen_utf8(lua_State *L)
static int codepoint(lua_State *L)
CURL_EXTERN CURLMcode curl_socket_t s