The Battle for Wesnoth  1.15.0+dev
Macros | Functions | Variables
lutf8lib.cpp File Reference
#include "lprefix.h"
#include <assert.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
Include dependency graph for lutf8lib.cpp:

Go to the source code of this file.

Macros

#define lutf8lib_c
 
#define LUA_LIB
 
#define MAXUNICODE   0x10FFFF
 
#define iscont(p)   ((*(p) & 0xC0) == 0x80)
 
#define UTF8PATT   "[\0-\x7F\xC2-\xF4][\x80-\xBF]*"
 

Functions

static lua_Integer u_posrelat (lua_Integer pos, size_t len)
 
static const char * utf8_decode (const char *o, int *val)
 
static int utflen (lua_State *L)
 
static int codepoint (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 iter_aux (lua_State *L)
 
static int iter_codes (lua_State *L)
 
LUAMOD_API int luaopen_utf8 (lua_State *L)
 

Variables

static const luaL_Reg funcs []
 

Macro Definition Documentation

◆ iscont

#define iscont (   p)    ((*(p) & 0xC0) == 0x80)

Definition at line 25 of file lutf8lib.cpp.

Referenced by byteoffset(), and iter_aux().

◆ LUA_LIB

#define LUA_LIB

Definition at line 8 of file lutf8lib.cpp.

◆ lutf8lib_c

#define lutf8lib_c

Definition at line 7 of file lutf8lib.cpp.

◆ MAXUNICODE

#define MAXUNICODE   0x10FFFF

Definition at line 23 of file lutf8lib.cpp.

Referenced by pushutfchar(), and utf8_decode().

◆ UTF8PATT

#define UTF8PATT   "[\0-\x7F\xC2-\xF4][\x80-\xBF]*"

Definition at line 235 of file lutf8lib.cpp.

Referenced by luaopen_utf8().

Function Documentation

◆ byteoffset()

static int byteoffset ( lua_State L)
static

◆ codepoint()

static int codepoint ( lua_State L)
static

◆ iter_aux()

static int iter_aux ( lua_State L)
static

Definition at line 201 of file lutf8lib.cpp.

References iscont, lua_pushinteger(), lua_tointeger, luaL_checklstring(), luaL_error(), n, next, s, and utf8_decode().

Referenced by iter_codes().

◆ iter_codes()

static int iter_codes ( lua_State L)
static

◆ luaopen_utf8()

LUAMOD_API int luaopen_utf8 ( lua_State L)

Definition at line 250 of file lutf8lib.cpp.

References lua_pushlstring(), lua_setfield(), luaL_newlib, and UTF8PATT.

Referenced by lua_kernel_base::lua_kernel_base().

◆ pushutfchar()

static void pushutfchar ( lua_State L,
int  arg 
)
static

Definition at line 128 of file lutf8lib.cpp.

References lua_pushfstring(), luaL_argcheck, luaL_checkinteger(), and MAXUNICODE.

Referenced by utfchar().

◆ u_posrelat()

static lua_Integer u_posrelat ( lua_Integer  pos,
size_t  len 
)
static

Definition at line 30 of file lutf8lib.cpp.

Referenced by byteoffset(), codepoint(), and utflen().

◆ utf8_decode()

static const char* utf8_decode ( const char *  o,
int *  val 
)
static

Definition at line 40 of file lutf8lib.cpp.

References c, MAXUNICODE, and s.

Referenced by codepoint(), iter_aux(), and utflen().

◆ utfchar()

static int utfchar ( lua_State L)
static

Definition at line 138 of file lutf8lib.cpp.

References b, i, lua_gettop(), luaL_addvalue(), luaL_buffinit(), luaL_pushresult(), n, and pushutfchar().

◆ utflen()

static int utflen ( lua_State L)
static

Variable Documentation

◆ funcs

const luaL_Reg funcs[]
static
Initial value:
= {
{"offset", byteoffset},
{"codepoint", codepoint},
{"char", utfchar},
{"len", utflen},
{"codes", iter_codes},
{"charpattern", NULL},
{NULL, NULL}
}
static int byteoffset(lua_State *L)
Definition: lutf8lib.cpp:160
static int utfchar(lua_State *L)
Definition: lutf8lib.cpp:138
static int utflen(lua_State *L)
Definition: lutf8lib.cpp:71
static int codepoint(lua_State *L)
Definition: lutf8lib.cpp:100
static int iter_codes(lua_State *L)
Definition: lutf8lib.cpp:225

Definition at line 238 of file lutf8lib.cpp.