Go to the documentation of this file.
24 #define MAXUNICODE 0x10FFFFu
26 #define MAXUTF 0x7FFFFFFFu
31 #if (UINT_MAX >> 30) >= 1
32 typedef unsigned int utfint;
38 #define iscont(p) ((*(p) & 0xC0) == 0x80)
44 if (pos >= 0)
return pos;
45 else if (0u - (
size_t)pos > len)
return 0;
58 static const utfint limits[] =
59 {~(
utfint)0, 0x80, 0x800, 0x10000u, 0x200000u, 0x4000000u};
60 unsigned int c = (
unsigned char)
s[0];
66 for (; c & 0x40; c <<= 1) {
67 unsigned int cc = (
unsigned char)
s[++
count];
68 if ((cc & 0xC0) != 0x80)
70 res = (res << 6) | (cc & 0x3F);
79 if (res >
MAXUNICODE || (0xD800u <= res && res <= 0xDFFFu))
100 "initial position out of bounds");
102 "final position out of bounds");
103 while (posi <= posj) {
132 if (posi > pose)
return 0;
133 if (pose - posi >= INT_MAX)
134 return luaL_error(L,
"string slice too long");
135 n = (
int)(pose - posi) + 1;
139 for (
s += posi - 1;
s < se;) {
169 for (i = 1; i <= n; i++) {
190 "position out of bounds");
193 while (posi > 0 &&
iscont(
s + posi)) posi--;
197 return luaL_error(L,
"initial position is a continuation byte");
199 while (n < 0 && posi > 0) {
202 }
while (posi > 0 &&
iscont(
s + posi));
268 #define UTF8PATT "[\0-\x7F\xC2-\xFD][\x80-\xBF]*"
278 {
"charpattern", NULL},
LUA_UNSIGNED lua_Unsigned
static void pushutfchar(lua_State *L, int arg)
#define luaL_checkstring(L, n)
LUALIB_API void luaL_buffinit(lua_State *L, luaL_Buffer *B)
LUA_API void lua_pushinteger(lua_State *L, lua_Integer n)
const LUA_API char * lua_pushfstring(lua_State *L, const char *fmt,...)
auto arg(const Char *name, const T &arg) -> detail::named_arg< Char, T >
static int iter_codes(lua_State *L)
const LUALIB_API char * luaL_checklstring(lua_State *L, int arg, size_t *len)
LUALIB_API void luaL_pushresult(luaL_Buffer *B)
static int codepoint(lua_State *L)
constexpr auto count() -> size_t
static int iter_aux(lua_State *L, int strict)
static lua_Integer u_posrelat(lua_Integer pos, size_t len)
#define lua_tointeger(L, i)
LUA_API void lua_setfield(lua_State *L, int idx, const char *k)
static int iter_auxstrict(lua_State *L)
#define luaL_argcheck(L, cond, arg, extramsg)
LUA_API int lua_gettop(lua_State *L)
LUA_API void lua_pushvalue(lua_State *L, int idx)
#define lua_pushcfunction(L, f)
const LUA_API char * lua_pushlstring(lua_State *L, const char *s, size_t len)
LUAMOD_API int luaopen_utf8(lua_State *L)
LUALIB_API lua_Integer luaL_optinteger(lua_State *L, int arg, lua_Integer def)
static const char * utf8_decode(const char *s, utfint *val, int strict)
LUALIB_API void luaL_checkstack(lua_State *L, int space, const char *msg)
#define luaL_newlib(L, l)
LUALIB_API int luaL_error(lua_State *L, const char *fmt,...)
static int utflen(lua_State *L)
LUALIB_API lua_Integer luaL_checkinteger(lua_State *L, int arg)
LUA_API int lua_toboolean(lua_State *L, int idx)
static int byteoffset(lua_State *L)
LUALIB_API void luaL_addvalue(luaL_Buffer *B)
static int utfchar(lua_State *L)
static const luaL_Reg funcs[]
static int iter_auxlax(lua_State *L)
plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:45