mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
Better %*
This commit is contained in:
parent
e496c86581
commit
b43fe82465
2 changed files with 10 additions and 2 deletions
|
@ -1034,8 +1034,13 @@ static int str_format(lua_State* L)
|
||||||
}
|
}
|
||||||
case '*':
|
case '*':
|
||||||
{
|
{
|
||||||
sprintf(buff, "%s", luaL_tolstring(L, arg, NULL));
|
size_t length;
|
||||||
break;
|
const char* string = luaL_tolstring(L, arg, &length);
|
||||||
|
|
||||||
|
luaL_reservebuffer(&b, length, -1);
|
||||||
|
luaL_addlstring(&b, string, length);
|
||||||
|
|
||||||
|
continue; /* skip the `addsize' at the end */
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{ /* also treat cases `pnLlh' */
|
{ /* also treat cases `pnLlh' */
|
||||||
|
|
|
@ -143,6 +143,9 @@ assert(pcall(function()
|
||||||
string.format("%* %* %*", return_two_nils())
|
string.format("%* %* %*", return_two_nils())
|
||||||
end) == false)
|
end) == false)
|
||||||
|
|
||||||
|
assert(string.format("%*", "a\0b\0c") == "a\0b\0c")
|
||||||
|
assert(string.format("%*", string.rep("doge", 3000)) == string.rep("doge", 3000))
|
||||||
|
|
||||||
assert(loadstring("return 1\n--comentário sem EOL no final")() == 1)
|
assert(loadstring("return 1\n--comentário sem EOL no final")() == 1)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue