1 | /* |
2 | ** String handling. |
3 | ** Copyright (C) 2005-2021 Mike Pall. See Copyright Notice in luajit.h |
4 | */ |
5 | |
6 | #ifndef _LJ_STR_H |
7 | #define _LJ_STR_H |
8 | |
9 | #include <stdarg.h> |
10 | |
11 | #include "lj_obj.h" |
12 | |
13 | /* String helpers. */ |
14 | LJ_FUNC int32_t LJ_FASTCALL lj_str_cmp(GCstr *a, GCstr *b); |
15 | LJ_FUNC const char *lj_str_find(const char *s, const char *f, |
16 | MSize slen, MSize flen); |
17 | LJ_FUNC int lj_str_haspattern(GCstr *s); |
18 | |
19 | /* String interning. */ |
20 | LJ_FUNC void lj_str_resize(lua_State *L, MSize newmask); |
21 | LJ_FUNCA GCstr *lj_str_new(lua_State *L, const char *str, size_t len); |
22 | LJ_FUNC void LJ_FASTCALL lj_str_free(global_State *g, GCstr *s); |
23 | LJ_FUNC void LJ_FASTCALL lj_str_init(lua_State *L); |
24 | #define lj_str_freetab(g) \ |
25 | (lj_mem_freevec(g, g->str.tab, g->str.mask+1, GCRef)) |
26 | |
27 | #define lj_str_newz(L, s) (lj_str_new(L, s, strlen(s))) |
28 | #define lj_str_newlit(L, s) (lj_str_new(L, "" s, sizeof(s)-1)) |
29 | #define lj_str_size(len) (sizeof(GCstr) + (((len)+4) & ~(MSize)3)) |
30 | |
31 | #endif |
32 | |