mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-04 10:18:31 +00:00
Make improvements
- Add hierarchical auto-completion to redbean's repl - Fetch latest localtime() and strftime() from Eggert - Shave a few milliseconds off redbean start latency - Fix redbean repl with multi-line statements - Make the Lua unix module code more elegant - Harden Lua data structure serialization
This commit is contained in:
parent
d57b81aac7
commit
6a145a9262
44 changed files with 2987 additions and 1941 deletions
|
@ -4120,7 +4120,7 @@ static int LuaLog(lua_State *L) {
|
|||
}
|
||||
|
||||
static int LuaEncodeSmth(lua_State *L,
|
||||
int Encoder(lua_State *, char **, int, char *, int)) {
|
||||
int Encoder(lua_State *, char **, char *, int)) {
|
||||
int useoutput = false;
|
||||
int maxdepth = 64;
|
||||
char *numformat = "%.14g";
|
||||
|
@ -4129,15 +4129,14 @@ static int LuaEncodeSmth(lua_State *L,
|
|||
lua_settop(L, 2); // discard any extra arguments
|
||||
lua_getfield(L, 2, "useoutput");
|
||||
// ignore useoutput outside of request handling
|
||||
if (ishandlingrequest && lua_isboolean(L, -1))
|
||||
if (ishandlingrequest && lua_isboolean(L, -1)) {
|
||||
useoutput = lua_toboolean(L, -1);
|
||||
lua_getfield(L, 2, "maxdepth");
|
||||
maxdepth = luaL_optinteger(L, -1, maxdepth);
|
||||
}
|
||||
lua_getfield(L, 2, "numformat");
|
||||
numformat = luaL_optstring(L, -1, numformat);
|
||||
}
|
||||
lua_settop(L, 1); // keep the passed argument on top
|
||||
Encoder(L, useoutput ? &outbuf : &p, maxdepth, numformat, -1);
|
||||
Encoder(L, useoutput ? &outbuf : &p, numformat, -1);
|
||||
if (useoutput) {
|
||||
lua_pushnil(L);
|
||||
} else {
|
||||
|
@ -5185,7 +5184,7 @@ static void LuaPrint(lua_State *L) {
|
|||
if (n > 0) {
|
||||
for (i = 1; i <= n; i++) {
|
||||
if (i > 1) appendw(&b, '\t');
|
||||
LuaEncodeLuaData(L, &b, 64, "g", i);
|
||||
LuaEncodeLuaData(L, &b, "g", i);
|
||||
}
|
||||
appendw(&b, '\n');
|
||||
WRITE(1, b, appendz(b).i);
|
||||
|
@ -5222,7 +5221,6 @@ static void LuaInterpreter(lua_State *L) {
|
|||
}
|
||||
for (;;) {
|
||||
status = lua_loadline(L);
|
||||
write(1, "\n", 1);
|
||||
if (status == -1) break; // eof
|
||||
if (status == -2) {
|
||||
if (errno == EINTR) {
|
||||
|
@ -6502,7 +6500,6 @@ static int HandleReadline(void) {
|
|||
if (status == -1) {
|
||||
OnTerm(SIGHUP); // eof
|
||||
INFOF("got repl eof");
|
||||
write(1, "\n", 1);
|
||||
return -1;
|
||||
} else if (errno == EINTR) {
|
||||
errno = 0;
|
||||
|
@ -6516,7 +6513,6 @@ static int HandleReadline(void) {
|
|||
return -1;
|
||||
}
|
||||
}
|
||||
write(1, "\n", 1);
|
||||
linenoiseDisableRawMode();
|
||||
LUA_REPL_LOCK;
|
||||
if (status == LUA_OK) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue