mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-24 22:32:28 +00:00
Add pretty printing to redbean serializers
This commit is contained in:
parent
6bb8b26d70
commit
516b68606f
11 changed files with 327 additions and 91 deletions
8
third_party/lua/luaformatstack.c
vendored
8
third_party/lua/luaformatstack.c
vendored
|
@ -24,11 +24,17 @@ dontdiscard char *LuaFormatStack(lua_State *L) {
|
|||
size_t l;
|
||||
int i, top;
|
||||
char *p, *b = 0;
|
||||
struct EncoderConfig conf = {
|
||||
.maxdepth = 64,
|
||||
.sorted = true,
|
||||
.pretty = false,
|
||||
.indent = " ",
|
||||
};
|
||||
top = lua_gettop(L);
|
||||
for (i = 1; i <= top; i++) {
|
||||
if (i > 1) appendw(&b, '\n');
|
||||
appendf(&b, "\t%d\t%s\t", i, luaL_typename(L, i));
|
||||
LuaEncodeLuaData(L, &b, i, true);
|
||||
LuaEncodeLuaData(L, &b, i, conf);
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue