RetroArch
Classes | Macros | Typedefs | Enumerations | Functions | Variables
lstrlib.c File Reference
#include "lprefix.h"
#include <ctype.h>
#include <float.h>
#include <limits.h>
#include <locale.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.c:

Classes

struct  MatchState
 
struct  GMatchState
 
struct  cD
 
union  Ftypes
 
struct  Header
 

Macros

#define lstrlib_c
 
#define LUA_LIB
 
#define LUA_MAXCAPTURES   32
 
#define uchar(c)   ((unsigned char)(c))
 
#define MAX_SIZET   ((size_t)(~(size_t)0))
 
#define MAXSIZE   (sizeof(size_t) < sizeof(int) ? MAX_SIZET : (size_t)(INT_MAX))
 
#define CAP_UNFINISHED   (-1)
 
#define CAP_POSITION   (-2)
 
#define MAXCCALLS   200
 
#define L_ESC   '%'
 
#define SPECIALS   "^$*+?.([%-"
 
#define MAX_ITEM   (120 + l_mathlim(MAX_10_EXP))
 
#define FLAGS   "-+ #0"
 
#define MAX_FORMAT   32
 
#define LUAL_PACKPADBYTE   0x00
 
#define MAXINTSIZE   16
 
#define NB   CHAR_BIT
 
#define MC   ((1 << NB) - 1)
 
#define SZINT   ((int)sizeof(lua_Integer))
 
#define MAXALIGN   (offsetof(struct cD, u))
 

Typedefs

typedef struct MatchState MatchState
 
typedef struct GMatchState GMatchState
 
typedef union Ftypes Ftypes
 
typedef struct Header Header
 
typedef enum KOption KOption
 

Enumerations

enum  KOption {
  Kint, Kuint, Kfloat, Kchar,
  Kstring, Kzstr, Kpadding, Kpaddalign,
  Knop
}
 

Functions

static int str_len (lua_State *L)
 
static lua_Integer posrelat (lua_Integer 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 void prepstate (MatchState *ms, lua_State *L, const char *s, size_t ls, const char *p, size_t lp)
 
static void reprepstate (MatchState *ms)
 
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 (luaL_Buffer *b, const char *s, size_t len)
 
static void checkdp (char *buff, int nb)
 
static void addliteral (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 int digit (int c)
 
static int getnum (const char **fmt, int df)
 
static int getnumlimit (Header *h, const char **fmt, int df)
 
static void initheader (lua_State *L, Header *h)
 
static KOption getoption (Header *h, const char **fmt, int *size)
 
static KOption getdetails (Header *h, size_t totalsize, const char **fmt, int *psize, int *ntoalign)
 
static void packint (luaL_Buffer *b, lua_Unsigned n, int islittle, int size, int neg)
 
static void copywithendian (volatile char *dest, volatile const char *src, int size, int islittle)
 
static int str_pack (lua_State *L)
 
static int str_packsize (lua_State *L)
 
static lua_Integer unpackint (lua_State *L, const char *str, int islittle, int size, int issigned)
 
static int str_unpack (lua_State *L)
 
static void createmetatable (lua_State *L)
 
LUAMOD_API int luaopen_string (lua_State *L)
 

Variables

union {
   int   dummy
 
   char   little
 
nativeendian = {1}
 
static const luaL_Reg strlib []
 

Macro Definition Documentation

◆ CAP_POSITION

#define CAP_POSITION   (-2)

◆ CAP_UNFINISHED

#define CAP_UNFINISHED   (-1)

◆ FLAGS

#define FLAGS   "-+ #0"

◆ L_ESC

#define L_ESC   '%'

◆ lstrlib_c

#define lstrlib_c

◆ LUA_LIB

#define LUA_LIB

◆ LUA_MAXCAPTURES

#define LUA_MAXCAPTURES   32

◆ LUAL_PACKPADBYTE

#define LUAL_PACKPADBYTE   0x00

◆ MAX_FORMAT

#define MAX_FORMAT   32

◆ MAX_ITEM

#define MAX_ITEM   (120 + l_mathlim(MAX_10_EXP))

◆ MAX_SIZET

#define MAX_SIZET   ((size_t)(~(size_t)0))

◆ MAXALIGN

#define MAXALIGN   (offsetof(struct cD, u))

◆ MAXCCALLS

#define MAXCCALLS   200

◆ MAXINTSIZE

#define MAXINTSIZE   16

◆ MAXSIZE

#define MAXSIZE   (sizeof(size_t) < sizeof(int) ? MAX_SIZET : (size_t)(INT_MAX))

◆ MC

#define MC   ((1 << NB) - 1)

◆ NB

#define NB   CHAR_BIT

◆ SPECIALS

#define SPECIALS   "^$*+?.([%-"

◆ SZINT

#define SZINT   ((int)sizeof(lua_Integer))

◆ uchar

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

Typedef Documentation

◆ Ftypes

typedef union Ftypes Ftypes

◆ GMatchState

typedef struct GMatchState GMatchState

◆ Header

typedef struct Header Header

◆ KOption

typedef enum KOption KOption

◆ MatchState

typedef struct MatchState MatchState

Enumeration Type Documentation

◆ KOption

enum KOption
Enumerator
Kint 
Kuint 
Kfloat 
Kchar 
Kstring 
Kzstr 
Kpadding 
Kpaddalign 
Knop 

Function Documentation

◆ add_s()

static void add_s ( MatchState ms,
luaL_Buffer b,
const char *  s,
const char *  e 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_value()

static void add_value ( MatchState ms,
luaL_Buffer b,
const char *  s,
const char *  e,
int  tr 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ addlenmod()

static void addlenmod ( char *  form,
const char *  lenmod 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ addliteral()

static void addliteral ( lua_State L,
luaL_Buffer b,
int  arg 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ addquoted()

static void addquoted ( luaL_Buffer b,
const char *  s,
size_t  len 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ capture_to_close()

static int capture_to_close ( MatchState ms)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_capture()

static int check_capture ( MatchState ms,
int  l 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkdp()

static void checkdp ( char *  buff,
int  nb 
)
static
Here is the caller graph for this function:

◆ classend()

static const char* classend ( MatchState ms,
const char *  p 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ copywithendian()

static void copywithendian ( volatile char *  dest,
volatile const char *  src,
int  size,
int  islittle 
)
static
Here is the caller graph for this function:

◆ createmetatable()

static void createmetatable ( lua_State L)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ digit()

static int digit ( int  c)
static
Here is the caller graph for this function:

◆ end_capture()

static const char* end_capture ( MatchState ms,
const char *  s,
const char *  p 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getdetails()

static KOption getdetails ( Header h,
size_t  totalsize,
const char **  fmt,
int *  psize,
int *  ntoalign 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getnum()

static int getnum ( const char **  fmt,
int  df 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getnumlimit()

static int getnumlimit ( Header h,
const char **  fmt,
int  df 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getoption()

static KOption getoption ( Header h,
const char **  fmt,
int *  size 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ gmatch()

static int gmatch ( lua_State L)
static
Here is the call graph for this function:

◆ gmatch_aux()

static int gmatch_aux ( lua_State L)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ initheader()

static void initheader ( lua_State L,
Header h 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ lmemfind()

static const char* lmemfind ( const char *  s1,
size_t  l1,
const char *  s2,
size_t  l2 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ luaopen_string()

LUAMOD_API int luaopen_string ( lua_State L)
Here is the call graph for this function:

◆ match()

static const char * match ( MatchState ms,
const char *  s,
const char *  p 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ match_capture()

static const char* match_capture ( MatchState ms,
const char *  s,
int  l 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ match_class()

static int match_class ( int  c,
int  cl 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ matchbalance()

static const char* matchbalance ( MatchState ms,
const char *  s,
const char *  p 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ matchbracketclass()

static int matchbracketclass ( int  c,
const char *  p,
const char *  ec 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ max_expand()

static const char* max_expand ( MatchState ms,
const char *  s,
const char *  p,
const char *  ep 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ min_expand()

static const char* min_expand ( MatchState ms,
const char *  s,
const char *  p,
const char *  ep 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ nospecials()

static int nospecials ( const char *  p,
size_t  l 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ packint()

static void packint ( luaL_Buffer b,
lua_Unsigned  n,
int  islittle,
int  size,
int  neg 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ posrelat()

static lua_Integer posrelat ( lua_Integer  pos,
size_t  len 
)
static
Here is the caller graph for this function:

◆ prepstate()

static void prepstate ( MatchState ms,
lua_State L,
const char *  s,
size_t  ls,
const char *  p,
size_t  lp 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ push_captures()

static int push_captures ( MatchState ms,
const char *  s,
const char *  e 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ push_onecapture()

static void push_onecapture ( MatchState ms,
int  i,
const char *  s,
const char *  e 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reprepstate()

static void reprepstate ( MatchState ms)
static
Here is the caller graph for this function:

◆ scanformat()

static const char* scanformat ( lua_State L,
const char *  strfrmt,
char *  form 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ singlematch()

static int singlematch ( MatchState ms,
const char *  s,
const char *  p,
const char *  ep 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ start_capture()

static const char* start_capture ( MatchState ms,
const char *  s,
const char *  p,
int  what 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ str_byte()

static int str_byte ( lua_State L)
static
Here is the call graph for this function:

◆ str_char()

static int str_char ( lua_State L)
static
Here is the call graph for this function:

◆ str_dump()

static int str_dump ( lua_State L)
static
Here is the call graph for this function:

◆ str_find()

static int str_find ( lua_State L)
static
Here is the call graph for this function:

◆ str_find_aux()

static int str_find_aux ( lua_State L,
int  find 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ str_format()

static int str_format ( lua_State L)
static
Here is the call graph for this function:

◆ str_gsub()

static int str_gsub ( lua_State L)
static
Here is the call graph for this function:

◆ str_len()

static int str_len ( lua_State L)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ str_lower()

static int str_lower ( lua_State L)
static
Here is the call graph for this function:

◆ str_match()

static int str_match ( lua_State L)
static
Here is the call graph for this function:

◆ str_pack()

static int str_pack ( lua_State L)
static
Here is the call graph for this function:

◆ str_packsize()

static int str_packsize ( lua_State L)
static
Here is the call graph for this function:

◆ str_rep()

static int str_rep ( lua_State L)
static
Here is the call graph for this function:

◆ str_reverse()

static int str_reverse ( lua_State L)
static
Here is the call graph for this function:

◆ str_sub()

static int str_sub ( lua_State L)
static
Here is the call graph for this function:

◆ str_unpack()

static int str_unpack ( lua_State L)
static
Here is the call graph for this function:

◆ str_upper()

static int str_upper ( lua_State L)
static
Here is the call graph for this function:

◆ unpackint()

static lua_Integer unpackint ( lua_State L,
const char *  str,
int  islittle,
int  size,
int  issigned 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ writer()

static int writer ( lua_State L,
const void b,
size_t  size,
void B 
)
static
Here is the call graph for this function:

Variable Documentation

◆ dummy

int dummy

◆ little

char little

◆ nativeendian

const { ... } nativeendian

◆ strlib

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},
{"pack", str_pack},
{"packsize", str_packsize},
{"unpack", str_unpack},
}
static int str_lower(lua_State *L)
Definition: lstrlib.c:96
static int str_gsub(lua_State *L)
Definition: lstrlib.c:762
static int str_unpack(lua_State *L)
Definition: lstrlib.c:1476
static int str_upper(lua_State *L)
Definition: lstrlib.c:109
static int str_pack(lua_State *L)
Definition: lstrlib.c:1330
static int gmatch(lua_State *L)
Definition: lstrlib.c:689
static int str_len(lua_State *L)
Definition: lstrlib.c:54
static int str_rep(lua_State *L)
Definition: lstrlib.c:122
#define NULL
Pointer to 0.
Definition: gctypes.h:65
static int str_byte(lua_State *L)
Definition: lstrlib.c:148
static int str_packsize(lua_State *L)
Definition: lstrlib.c:1417
static int str_reverse(lua_State *L)
Definition: lstrlib.c:84
static int str_format(lua_State *L)
Definition: lstrlib.c:1016
static int str_sub(lua_State *L)
Definition: lstrlib.c:70
static int str_find(lua_State *L)
Definition: lstrlib.c:654
static int str_match(lua_State *L)
Definition: lstrlib.c:659
static int str_char(lua_State *L)
Definition: lstrlib.c:167
static int str_dump(lua_State *L)
Definition: lstrlib.c:189