mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-28 08:12:28 +00:00
Improve Lua and JSON serialization
This commit is contained in:
parent
3027d67037
commit
e3cd476a9b
20 changed files with 1041 additions and 476 deletions
|
@ -511,9 +511,13 @@ static dontinline int LuaCoderImpl(lua_State *L,
|
|||
void *p;
|
||||
size_t n;
|
||||
p = luaL_checklstring(L, 1, &n);
|
||||
p = C(p, n, &n);
|
||||
lua_pushlstring(L, p, n);
|
||||
free(p);
|
||||
if ((p = C(p, n, &n))) {
|
||||
lua_pushlstring(L, p, n);
|
||||
free(p);
|
||||
} else {
|
||||
luaL_error(L, "out of memory");
|
||||
unreachable;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -575,7 +579,17 @@ int LuaEscapeFragment(lua_State *L) {
|
|||
}
|
||||
|
||||
int LuaEscapeLiteral(lua_State *L) {
|
||||
return LuaCoder(L, EscapeJsStringLiteral);
|
||||
char *p, *q = 0;
|
||||
size_t n, y = 0;
|
||||
p = luaL_checklstring(L, 1, &n);
|
||||
if ((p = EscapeJsStringLiteral(&q, &y, p, n, &n))) {
|
||||
lua_pushlstring(L, p, n);
|
||||
free(q);
|
||||
return 1;
|
||||
} else {
|
||||
luaL_error(L, "out of memory");
|
||||
unreachable;
|
||||
}
|
||||
}
|
||||
|
||||
int LuaVisualizeControlCodes(lua_State *L) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue