The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Macros | Typedefs | Functions | Variables
lstrlib.cpp File Reference
#include <ctype.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
Include dependency graph for lstrlib.cpp:

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 []
 

Macro Definition Documentation

#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().

#define uchar (   c)    ((unsigned char)(c))

Typedef Documentation

typedef struct MatchState MatchState

Function Documentation

static void add_s ( MatchState ms,
luaL_Buffer b,
const char *  s,
const char *  e 
)
static
static void add_value ( MatchState ms,
luaL_Buffer b,
const char *  s,
const char *  e,
int  tr 
)
static
static void addlenmod ( char *  form,
const char *  lenmod 
)
static

Definition at line 881 of file lstrlib.cpp.

Referenced by str_format().

static void addquoted ( lua_State L,
luaL_Buffer b,
int  arg 
)
static

Definition at line 832 of file lstrlib.cpp.

References luaL_addchar, luaL_addstring(), luaL_checklstring(), and uchar.

Referenced by str_format().

static int capture_to_close ( MatchState ms)
static
static int check_capture ( MatchState ms,
int  l 
)
static
static const char* classend ( MatchState ms,
const char *  p 
)
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().

static void createmetatable ( lua_State L)
static
static const char* end_capture ( MatchState ms,
const char *  s,
const char *  p 
)
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().

static int gmatch ( lua_State L)
static
static int gmatch_aux ( lua_State L)
static
static const char* lmemfind ( const char *  s1,
size_t  l1,
const char *  s2,
size_t  l2 
)
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 const char * match ( MatchState ms,
const char *  s,
const char *  p 
)
static
static const char* match_capture ( MatchState ms,
const char *  s,
int  l 
)
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().

static int match_class ( int  c,
int  cl 
)
static

Definition at line 265 of file lstrlib.cpp.

Referenced by matchbracketclass(), and singlematch().

static const char* matchbalance ( MatchState ms,
const char *  s,
const char *  p 
)
static

Definition at line 324 of file lstrlib.cpp.

References e, MatchState::L, LUA_QL, luaL_error(), and MatchState::p_end.

Referenced by match().

static int matchbracketclass ( int  c,
const char *  p,
const char *  ec 
)
static

Definition at line 285 of file lstrlib.cpp.

References L_ESC, match_class(), and uchar.

Referenced by match(), and singlematch().

static const char* max_expand ( MatchState ms,
const char *  s,
const char *  p,
const char *  ep 
)
static

Definition at line 345 of file lstrlib.cpp.

References i, match(), and singlematch().

Referenced by match().

static const char* min_expand ( MatchState ms,
const char *  s,
const char *  p,
const char *  ep 
)
static

Definition at line 360 of file lstrlib.cpp.

References match(), and singlematch().

Referenced by match().

static int nospecials ( const char *  p,
size_t  l 
)
static

Definition at line 565 of file lstrlib.cpp.

References SPECIALS.

Referenced by str_find_aux().

static size_t posrelat ( ptrdiff_t  pos,
size_t  len 
)
static

Definition at line 45 of file lstrlib.cpp.

References pos.

Referenced by str_byte(), str_find_aux(), and str_sub().

static int push_captures ( MatchState ms,
const char *  s,
const char *  e 
)
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 void push_onecapture ( MatchState ms,
int  i,
const char *  s,
const char *  e 
)
static
static const char* scanformat ( lua_State L,
const char *  strfrmt,
char *  form 
)
static

Definition at line 856 of file lstrlib.cpp.

References FLAGS, luaL_error(), and uchar.

Referenced by str_format().

static int singlematch ( MatchState ms,
const char *  s,
const char *  p,
const char *  ep 
)
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 const char* start_capture ( MatchState ms,
const char *  s,
const char *  p,
int  what 
)
static
static int str_byte ( lua_State L)
static
static int str_char ( lua_State L)
static
static int str_dump ( lua_State L)
static
static int str_find ( lua_State L)
static

Definition at line 628 of file lstrlib.cpp.

References str_find_aux().

static int str_find_aux ( lua_State L,
int  find 
)
static
static int str_format ( lua_State L)
static
static int str_gsub ( lua_State L)
static
static int str_len ( lua_State L)
static

Definition at line 36 of file lstrlib.cpp.

References lua_pushinteger(), and luaL_checklstring().

static int str_lower ( lua_State L)
static

Definition at line 78 of file lstrlib.cpp.

References i, luaL_buffinitsize(), luaL_checklstring(), luaL_pushresultsize(), and uchar.

static int str_match ( lua_State L)
static

Definition at line 633 of file lstrlib.cpp.

References str_find_aux().

static int str_rep ( lua_State L)
static
static int str_reverse ( lua_State L)
static

Definition at line 66 of file lstrlib.cpp.

References i, luaL_buffinitsize(), luaL_checklstring(), and luaL_pushresultsize().

static int str_sub ( lua_State L)
static
static int str_upper ( lua_State L)
static

Definition at line 91 of file lstrlib.cpp.

References i, luaL_buffinitsize(), luaL_checklstring(), luaL_pushresultsize(), and uchar.

static int writer ( lua_State L,
const void b,
size_t  size,
void B 
)
static

Variable Documentation

const luaL_Reg strlib[]
static
Initial value:
= {
{"byte", str_byte},
{"char", str_char},
{"dump", str_dump},
{"find", str_find},
{"format", str_format},
{"gmatch", gmatch},
{"gsub", str_gsub},
{"len", str_len},
{"lower", str_lower},
{"match", str_match},
{"rep", str_rep},
{"reverse", str_reverse},
{"sub", str_sub},
{"upper", str_upper},
{NULL, NULL}
}
static int str_dump(lua_State *L)
Definition: lstrlib.cpp:173
static int str_match(lua_State *L)
Definition: lstrlib.cpp:633
static int str_reverse(lua_State *L)
Definition: lstrlib.cpp:66
static int str_gsub(lua_State *L)
Definition: lstrlib.cpp:734
static int str_char(lua_State *L)
Definition: lstrlib.cpp:151
static int str_rep(lua_State *L)
Definition: lstrlib.cpp:107
static int str_byte(lua_State *L)
Definition: lstrlib.cpp:132
static int str_format(lua_State *L)
Definition: lstrlib.cpp:891
static int str_lower(lua_State *L)
Definition: lstrlib.cpp:78
static int str_find(lua_State *L)
Definition: lstrlib.cpp:628
static int str_len(lua_State *L)
Definition: lstrlib.cpp:36
static int gmatch(lua_State *L)
Definition: lstrlib.cpp:667
static int str_upper(lua_State *L)
Definition: lstrlib.cpp:91
static int str_sub(lua_State *L)
Definition: lstrlib.cpp:52

Definition at line 979 of file lstrlib.cpp.