MCPcopy Create free account
hub / github.com/KikoPlayProject/KikoPlay / split

Method split

Extension/Modules/lua_stringutil.cpp:81–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79}
80
81int StringUtil::split(lua_State *L)
82{
83 const char *s = luaL_checkstring(L, 1);
84 size_t len = 0;
85 const char *sep = luaL_checklstring(L, 2, &len);
86 const char *e = NULL;
87 bool skipEmpty = false;
88 if (lua_gettop(L) == 3)
89 {
90 skipEmpty = lua_toboolean(L, 3);
91 }
92 int i = 1;
93
94 lua_newtable(L); /* result */
95
96 /* repeat for each separator */
97 while ((e = strstr(s, sep)) != NULL)
98 {
99 if (!skipEmpty || e-s > 0)
100 {
101 lua_pushlstring(L, s, e-s); /* push substring */
102 lua_rawseti(L, -2, i++);
103 }
104 s = e + len; /* skip separator */
105 }
106
107 /* push last substring */
108 lua_pushstring(L, s);
109 lua_rawseti(L, -2, i);
110
111 return 1; /* return the table */
112}
113
114int StringUtil::indexof(lua_State *L)
115{

Callers 15

setContentMethod · 0.80
checkMethod · 0.80
fetchInfoMethod · 0.80
Aria2JsonRPCMethod · 0.80
loadLocalMethod · 0.80
insertNodeMethod · 0.80
insertNodeIndexMethod · 0.80
removeNodeIndexMethod · 0.80
setStaffsMethod · 0.80
fromMapMethod · 0.80
setTimelineMethod · 0.80
createImageMethod · 0.80

Calls 6

luaL_checklstringFunction · 0.85
lua_gettopFunction · 0.85
lua_tobooleanFunction · 0.85
lua_pushlstringFunction · 0.85
lua_rawsetiFunction · 0.85
lua_pushstringFunction · 0.85

Tested by

no test coverage detected