mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
Revert lstrlib to upstream/master
This commit is contained in:
parent
cce6b98821
commit
7a437aad17
1 changed files with 20 additions and 1 deletions
|
@ -1046,15 +1046,34 @@ static int str_format(lua_State* L)
|
||||||
const char* string = luaL_tolstring(L, arg, &length);
|
const char* string = luaL_tolstring(L, arg, &length);
|
||||||
|
|
||||||
luaL_addlstring(&b, string, length);
|
luaL_addlstring(&b, string, length);
|
||||||
continue; /* skip the `addsize' at the end */
|
continue; // skip the `addsize' at the end
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{ // also treat cases `pnLlh'
|
{ // also treat cases `pnLlh'
|
||||||
luaL_error(L, "invalid option '%%%c' to 'format'", *(strfrmt - 1));
|
luaL_error(L, "invalid option '%%%c' to 'format'", *(strfrmt - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
luaL_addlstring(&b, buff, strlen(buff));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
luaL_pushresult(&b);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int str_split(lua_State* L)
|
||||||
|
{
|
||||||
|
size_t haystackLen;
|
||||||
|
const char* haystack = luaL_checklstring(L, 1, &haystackLen);
|
||||||
|
size_t needleLen;
|
||||||
|
const char* needle = luaL_optlstring(L, 2, ",", &needleLen);
|
||||||
|
|
||||||
|
const char* begin = haystack;
|
||||||
|
const char* end = haystack + haystackLen;
|
||||||
const char* spanStart = begin;
|
const char* spanStart = begin;
|
||||||
int numMatches = 0;
|
int numMatches = 0;
|
||||||
|
|
||||||
|
lua_createtable(L, 0, 0);
|
||||||
|
|
||||||
if (needleLen == 0)
|
if (needleLen == 0)
|
||||||
begin++;
|
begin++;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue