#include <ctype.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
Go to the source code of this file.
Classes | |
struct | MatchState |
Macros | |
#define | lstrlib_c |
#define | LUA_LIB |
#define | LUA_MAXCAPTURES 32 |
#define | uchar(c) ((unsigned char)(c)) |
#define | MAXSIZE ((~(size_t)0) >> 1) |
#define | CAP_UNFINISHED (-1) |
#define | CAP_POSITION (-2) |
#define | MAXCCALLS 200 |
#define | L_ESC '%' |
#define | SPECIALS "^$*+?.([%-" |
#define | LUA_INTFRMLEN "l" |
#define | LUA_INTFRM_T long |
#define | LUA_FLTFRMLEN "" |
#define | LUA_FLTFRM_T double |
#define | MAX_ITEM 512 |
#define | FLAGS "-+ #0" |
#define | MAX_FORMAT (sizeof(FLAGS) + sizeof(LUA_INTFRMLEN) + 10) |
Typedefs | |
typedef struct MatchState | MatchState |
Functions | |
static int | str_len (lua_State *L) |
static size_t | posrelat (ptrdiff_t pos, size_t len) |
static int | str_sub (lua_State *L) |
static int | str_reverse (lua_State *L) |
static int | str_lower (lua_State *L) |
static int | str_upper (lua_State *L) |
static int | str_rep (lua_State *L) |
static int | str_byte (lua_State *L) |
static int | str_char (lua_State *L) |
static int | writer (lua_State *L, const void *b, size_t size, void *B) |
static int | str_dump (lua_State *L) |
static const char * | match (MatchState *ms, const char *s, const char *p) |
static int | check_capture (MatchState *ms, int l) |
static int | capture_to_close (MatchState *ms) |
static const char * | classend (MatchState *ms, const char *p) |
static int | match_class (int c, int cl) |
static int | matchbracketclass (int c, const char *p, const char *ec) |
static int | singlematch (MatchState *ms, const char *s, const char *p, const char *ep) |
static const char * | matchbalance (MatchState *ms, const char *s, const char *p) |
static const char * | max_expand (MatchState *ms, const char *s, const char *p, const char *ep) |
static const char * | min_expand (MatchState *ms, const char *s, const char *p, const char *ep) |
static const char * | start_capture (MatchState *ms, const char *s, const char *p, int what) |
static const char * | end_capture (MatchState *ms, const char *s, const char *p) |
static const char * | match_capture (MatchState *ms, const char *s, int l) |
static const char * | lmemfind (const char *s1, size_t l1, const char *s2, size_t l2) |
static void | push_onecapture (MatchState *ms, int i, const char *s, const char *e) |
static int | push_captures (MatchState *ms, const char *s, const char *e) |
static int | nospecials (const char *p, size_t l) |
static int | str_find_aux (lua_State *L, int find) |
static int | str_find (lua_State *L) |
static int | str_match (lua_State *L) |
static int | gmatch_aux (lua_State *L) |
static int | gmatch (lua_State *L) |
static void | add_s (MatchState *ms, luaL_Buffer *b, const char *s, const char *e) |
static void | add_value (MatchState *ms, luaL_Buffer *b, const char *s, const char *e, int tr) |
static int | str_gsub (lua_State *L) |
static void | addquoted (lua_State *L, luaL_Buffer *b, int arg) |
static const char * | scanformat (lua_State *L, const char *strfrmt, char *form) |
static void | addlenmod (char *form, const char *lenmod) |
static int | str_format (lua_State *L) |
static void | createmetatable (lua_State *L) |
LUAMOD_API int | luaopen_string (lua_State *L) |
Variables | |
static const luaL_Reg | strlib [] |
#define CAP_POSITION (-2) |
Definition at line 194 of file lstrlib.cpp.
Referenced by match(), and push_onecapture().
#define CAP_UNFINISHED (-1) |
Definition at line 193 of file lstrlib.cpp.
Referenced by capture_to_close(), check_capture(), end_capture(), match(), and push_onecapture().
#define FLAGS "-+ #0" |
Definition at line 824 of file lstrlib.cpp.
Referenced by scanformat().
#define L_ESC '%' |
Definition at line 221 of file lstrlib.cpp.
Referenced by add_s(), classend(), match(), matchbracketclass(), singlematch(), and str_format().
#define lstrlib_c |
Definition at line 13 of file lstrlib.cpp.
#define LUA_FLTFRM_T double |
Definition at line 816 of file lstrlib.cpp.
Referenced by str_format().
#define LUA_FLTFRMLEN "" |
Definition at line 815 of file lstrlib.cpp.
Referenced by str_format().
#define LUA_INTFRM_T long |
Definition at line 802 of file lstrlib.cpp.
Referenced by str_format().
#define LUA_INTFRMLEN "l" |
Definition at line 801 of file lstrlib.cpp.
Referenced by str_format().
#define LUA_LIB |
Definition at line 14 of file lstrlib.cpp.
#define LUA_MAXCAPTURES 32 |
Definition at line 27 of file lstrlib.cpp.
Referenced by start_capture().
#define MAX_FORMAT (sizeof(FLAGS) + sizeof(LUA_INTFRMLEN) + 10) |
Definition at line 829 of file lstrlib.cpp.
Referenced by str_format().
#define MAX_ITEM 512 |
Definition at line 822 of file lstrlib.cpp.
Referenced by str_format().
#define MAXCCALLS 200 |
Definition at line 217 of file lstrlib.cpp.
Referenced by gmatch_aux(), str_find_aux(), and str_gsub().
#define MAXSIZE ((~(size_t)0) >> 1) |
Definition at line 105 of file lstrlib.cpp.
Referenced by str_rep().
#define SPECIALS "^$*+?.([%-" |
Definition at line 222 of file lstrlib.cpp.
Referenced by nospecials().
Definition at line 32 of file lstrlib.cpp.
Referenced by add_s(), addquoted(), utf8::lowercase(), match(), matchbracketclass(), scanformat(), singlematch(), str_byte(), str_char(), str_lower(), and str_upper().
typedef struct MatchState MatchState |
|
static |
Definition at line 677 of file lstrlib.cpp.
References i, MatchState::L, L_ESC, LUA_QL, lua_tolstring(), luaL_addchar, luaL_addlstring(), luaL_addvalue(), luaL_error(), push_onecapture(), and uchar.
Referenced by add_value().
|
static |
Definition at line 703 of file lstrlib.cpp.
References add_s(), MatchState::L, lua_call, lua_gettable(), lua_isstring(), lua_pop, lua_pushlstring(), lua_pushvalue(), LUA_TFUNCTION, lua_toboolean(), LUA_TTABLE, luaL_addvalue(), luaL_error(), luaL_typename, push_captures(), and push_onecapture().
Referenced by str_gsub().
|
static |
Definition at line 881 of file lstrlib.cpp.
Referenced by str_format().
|
static |
Definition at line 832 of file lstrlib.cpp.
References luaL_addchar, luaL_addstring(), luaL_checklstring(), and uchar.
Referenced by str_format().
|
static |
Definition at line 233 of file lstrlib.cpp.
References CAP_UNFINISHED, MatchState::capture, MatchState::L, MatchState::len, MatchState::level, and luaL_error().
Referenced by end_capture().
|
static |
Definition at line 225 of file lstrlib.cpp.
References CAP_UNFINISHED, MatchState::capture, MatchState::L, MatchState::len, MatchState::level, and luaL_error().
Referenced by match_capture().
|
static |
Definition at line 241 of file lstrlib.cpp.
References MatchState::L, L_ESC, LUA_QL, luaL_error(), and MatchState::p_end.
Referenced by match().
Definition at line 998 of file lstrlib.cpp.
References lua_createtable(), lua_pop, lua_pushliteral, lua_pushvalue(), lua_setfield(), and lua_setmetatable().
Referenced by luaopen_string().
|
static |
Definition at line 387 of file lstrlib.cpp.
References CAP_UNFINISHED, MatchState::capture, capture_to_close(), MatchState::init, MatchState::len, and match().
Referenced by match().
Definition at line 667 of file lstrlib.cpp.
References gmatch_aux(), lua_pushcclosure(), lua_pushinteger(), lua_settop(), and luaL_checkstring.
Definition at line 638 of file lstrlib.cpp.
References e, MatchState::L, MatchState::level, lua_assert, lua_pushinteger(), lua_replace(), lua_tointeger, lua_tolstring(), lua_upvalueindex, match(), MatchState::matchdepth, MAXCCALLS, MatchState::p_end, push_captures(), MatchState::src_end, and MatchState::src_init.
Referenced by gmatch().
|
static |
Definition at line 513 of file lstrlib.cpp.
References ai::registry::init().
Referenced by str_find_aux().
LUAMOD_API int luaopen_string | ( | lua_State * | L | ) |
Definition at line 1013 of file lstrlib.cpp.
References createmetatable(), and luaL_newlib.
Referenced by lua_kernel_base::lua_kernel_base().
|
static |
Definition at line 409 of file lstrlib.cpp.
References CAP_POSITION, CAP_UNFINISHED, classend(), end_capture(), ai::registry::init(), MatchState::L, L_ESC, LUA_QL, luaL_error(), match_capture(), matchbalance(), matchbracketclass(), MatchState::matchdepth, max_expand(), min_expand(), MatchState::p_end, singlematch(), MatchState::src_end, MatchState::src_init, start_capture(), and uchar.
Referenced by terrain_builder::build_terrains(), end_capture(), gmatch_aux(), basic_unit_filter_impl::internal_matches_filter(), test_throw::lexical_cast(), max_expand(), min_expand(), start_capture(), str_find_aux(), str_gsub(), and utils::wildcard_string_match().
|
static |
Definition at line 398 of file lstrlib.cpp.
References MatchState::capture, check_capture(), MatchState::init, MatchState::len, and MatchState::src_end.
Referenced by match().
Definition at line 265 of file lstrlib.cpp.
Referenced by matchbracketclass(), and singlematch().
|
static |
Definition at line 324 of file lstrlib.cpp.
References e, MatchState::L, LUA_QL, luaL_error(), and MatchState::p_end.
Referenced by match().
Definition at line 285 of file lstrlib.cpp.
References L_ESC, match_class(), and uchar.
Referenced by match(), and singlematch().
|
static |
Definition at line 345 of file lstrlib.cpp.
References i, match(), and singlematch().
Referenced by match().
|
static |
Definition at line 360 of file lstrlib.cpp.
References match(), and singlematch().
Referenced by match().
|
static |
|
static |
Definition at line 45 of file lstrlib.cpp.
References pos.
Referenced by str_byte(), str_find_aux(), and str_sub().
|
static |
Definition at line 554 of file lstrlib.cpp.
References i, MatchState::L, MatchState::level, luaL_checkstack(), and push_onecapture().
Referenced by add_value(), gmatch_aux(), and str_find_aux().
|
static |
Definition at line 535 of file lstrlib.cpp.
References CAP_POSITION, CAP_UNFINISHED, MatchState::capture, i, MatchState::init, MatchState::L, MatchState::len, MatchState::level, lua_pushinteger(), lua_pushlstring(), luaL_error(), and MatchState::src_init.
Referenced by add_s(), add_value(), and push_captures().
|
static |
Definition at line 856 of file lstrlib.cpp.
References FLAGS, luaL_error(), and uchar.
Referenced by str_format().
|
static |
Definition at line 308 of file lstrlib.cpp.
References L_ESC, match_class(), matchbracketclass(), MatchState::src_end, and uchar.
Referenced by match(), max_expand(), and min_expand().
|
static |
Definition at line 373 of file lstrlib.cpp.
References MatchState::capture, MatchState::init, MatchState::L, MatchState::len, MatchState::level, LUA_MAXCAPTURES, luaL_error(), match(), and what().
Referenced by match().
Definition at line 132 of file lstrlib.cpp.
References i, int(), lua_pushinteger(), luaL_checklstring(), luaL_checkstack(), luaL_error(), luaL_optinteger(), posrelat(), and uchar.
Definition at line 151 of file lstrlib.cpp.
References i, lua_gettop(), luaL_argcheck, luaL_buffinitsize(), luaL_checkint, luaL_pushresultsize(), and uchar.
Definition at line 173 of file lstrlib.cpp.
References lua_dump(), lua_settop(), LUA_TFUNCTION, luaL_buffinit(), luaL_checktype(), luaL_error(), luaL_pushresult(), and writer().
Definition at line 628 of file lstrlib.cpp.
References str_find_aux().
Definition at line 576 of file lstrlib.cpp.
References ai::registry::init(), MatchState::L, MatchState::level, lmemfind(), lua_assert, lua_pushinteger(), lua_pushnil(), lua_toboolean(), luaL_checklstring(), luaL_optinteger(), match(), MatchState::matchdepth, MAXCCALLS, nospecials(), MatchState::p_end, posrelat(), push_captures(), MatchState::src_end, and MatchState::src_init.
Referenced by str_find(), and str_match().
Definition at line 891 of file lstrlib.cpp.
References addlenmod(), addquoted(), L_ESC, LUA_FLTFRM_T, LUA_FLTFRMLEN, lua_gettop(), LUA_INTFRM_T, LUA_INTFRMLEN, lua_pop, LUA_QL, luaL_addchar, luaL_addsize, luaL_addvalue(), luaL_argcheck, luaL_argerror(), luaL_buffinit(), luaL_checkint, luaL_checklstring(), luaL_checknumber(), luaL_error(), luaL_prepbuffsize(), luaL_pushresult(), luaL_tolstring(), MAX_FORMAT, MAX_ITEM, and scanformat().
Definition at line 734 of file lstrlib.cpp.
References add_value(), e, MatchState::L, MatchState::level, lua_assert, lua_pushinteger(), LUA_TFUNCTION, LUA_TNUMBER, LUA_TSTRING, LUA_TTABLE, lua_type(), luaL_addchar, luaL_addlstring(), luaL_argcheck, luaL_buffinit(), luaL_checklstring(), luaL_optinteger(), luaL_pushresult(), match(), MatchState::matchdepth, MAXCCALLS, MatchState::p_end, MatchState::src_end, and MatchState::src_init.
Definition at line 36 of file lstrlib.cpp.
References lua_pushinteger(), and luaL_checklstring().
Definition at line 78 of file lstrlib.cpp.
References i, luaL_buffinitsize(), luaL_checklstring(), luaL_pushresultsize(), and uchar.
Definition at line 633 of file lstrlib.cpp.
References str_find_aux().
Definition at line 107 of file lstrlib.cpp.
References lua_pushliteral, luaL_buffinitsize(), luaL_checkint, luaL_checklstring(), luaL_error(), luaL_optlstring(), luaL_pushresultsize(), and MAXSIZE.
Definition at line 66 of file lstrlib.cpp.
References i, luaL_buffinitsize(), luaL_checklstring(), and luaL_pushresultsize().
Definition at line 52 of file lstrlib.cpp.
References lua_pushliteral, lua_pushlstring(), luaL_checkinteger(), luaL_checklstring(), luaL_optinteger(), and posrelat().
Definition at line 91 of file lstrlib.cpp.
References i, luaL_buffinitsize(), luaL_checklstring(), luaL_pushresultsize(), and uchar.
Definition at line 166 of file lstrlib.cpp.
References luaL_addlstring().
Referenced by handle_preprocess_command(), campaignd::server::handle_upload(), persist_file_context::save_context(), str_dump(), wesnothd::ban_manager::write(), game_config::config_cache::write_file(), and wesnothd::room_manager::write_rooms().
|
static |
Definition at line 979 of file lstrlib.cpp.