mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-28 13:30:29 +00:00
Make improvements
- Add rusage to redbean Lua API - Add more redbean documentation - Add pledge() to redbean Lua API - Polyfill OpenBSD pledge() for Linux - Increase PATH_MAX limit to 1024 characters - Untrack sibling processes after fork() on Windows
This commit is contained in:
parent
9a6bd304a5
commit
47b3274665
212 changed files with 2251 additions and 834 deletions
6
third_party/linenoise/linenoise.c
vendored
6
third_party/linenoise/linenoise.c
vendored
|
@ -2457,15 +2457,17 @@ static int linenoiseFallback(const char *prompt, char **res) {
|
|||
* @return chomped allocated string of read line or null on eof/error
|
||||
*/
|
||||
char *linenoise(const char *prompt) {
|
||||
bool rm;
|
||||
char *res;
|
||||
bool rm, rs;
|
||||
if (linenoiseFallback(prompt, &res)) return res;
|
||||
fflush(stdout);
|
||||
fflush(stdout);
|
||||
rm = __replmode;
|
||||
rs = __replstderr;
|
||||
__replmode = true;
|
||||
if (isatty(2)) __replstderr = true;
|
||||
res = linenoiseRaw(prompt, fileno(stdin), fileno(stdout));
|
||||
__replmode = false;
|
||||
__replstderr = rs;
|
||||
__replmode = rm;
|
||||
return res;
|
||||
}
|
||||
|
|
18
third_party/lua/lrepl.c
vendored
18
third_party/lua/lrepl.c
vendored
|
@ -34,11 +34,11 @@
|
|||
#include "libc/intrin/nomultics.internal.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/gc.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/sa.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "third_party/linenoise/linenoise.h"
|
||||
#include "third_party/lua/cosmo.h"
|
||||
#include "third_party/lua/lauxlib.h"
|
||||
|
@ -101,10 +101,11 @@ static void lua_readline_addcompletion (linenoiseCompletions *c, char *s) {
|
|||
|
||||
void lua_readline_completions (const char *p, linenoiseCompletions *c) {
|
||||
int i;
|
||||
size_t n;
|
||||
bool found;
|
||||
lua_State *L;
|
||||
const char *name;
|
||||
char *a, *b, *component;
|
||||
char *a, *b, *s, *component;
|
||||
|
||||
// start searching globals
|
||||
L = globalL;
|
||||
|
@ -144,9 +145,11 @@ void lua_readline_completions (const char *p, linenoiseCompletions *c) {
|
|||
lua_pushnil(L);
|
||||
while (lua_next(L, -2)) {
|
||||
if (lua_type(L, -2) == LUA_TSTRING) {
|
||||
name = lua_tostring(L, -2);
|
||||
if (startswithi(name, a)) {
|
||||
lua_readline_addcompletion(c, xasprintf("%.*s%s", a - p, p, name));
|
||||
name = lua_tolstring(L, -2, &n);
|
||||
if (startswithi(name, a) && (s = malloc(a - p + n + 1))) {
|
||||
memcpy(s, p, a - p);
|
||||
memcpy(s + (a - p), name, n + 1);
|
||||
lua_readline_addcompletion(c, s);
|
||||
}
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
@ -157,7 +160,9 @@ void lua_readline_completions (const char *p, linenoiseCompletions *c) {
|
|||
|
||||
for (i = 0; i < ARRAYLEN(kKeywordHints); ++i) {
|
||||
if (startswithi(kKeywordHints[i], p)) {
|
||||
lua_readline_addcompletion(c, xstrdup(kKeywordHints[i]));
|
||||
if ((s = strdup(kKeywordHints[i]))) {
|
||||
lua_readline_addcompletion(c, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (lua_repl_completions_callback) {
|
||||
|
@ -333,6 +338,7 @@ void lua_initrepl(lua_State *L, const char *progname) {
|
|||
lua_repl_linenoise = linenoiseBegin(prompt, 0, 1);
|
||||
lua_pop(L, 1); /* remove prompt */
|
||||
__replmode = true;
|
||||
if (isatty(2)) __replstderr = true;
|
||||
}
|
||||
LUA_REPL_UNLOCK;
|
||||
}
|
||||
|
|
|
@ -787,7 +787,7 @@ build_time_vars = {'ABIFLAGS': 'm',
|
|||
'UNICODE_DEPS': '\\',
|
||||
'UNIVERSALSDK': '',
|
||||
'UPDATE_FILE': 'python3 ./Tools/scripts/update_file.py',
|
||||
'USE_COMPUTED_GOTOS': 0,
|
||||
'USE_COMPUTED_GOTOS': 1,
|
||||
'USE_INLINE': 1,
|
||||
'VERSION': '3.6',
|
||||
'WANT_SIGFPE_HANDLER': 0,
|
||||
|
|
10
third_party/python/pyconfig.h
vendored
10
third_party/python/pyconfig.h
vendored
|
@ -38,7 +38,7 @@
|
|||
#define HAVE_WORKING_TZSET 1
|
||||
#define HAVE_STRUCT_TM_TM_ZONE 1
|
||||
#define HAVE_TM_ZONE 1 /* deprecated */
|
||||
/* #undef HAVE_DECL_TZNAME */
|
||||
#define HAVE_DECL_TZNAME 1
|
||||
/* #undef HAVE_ALTZONE */
|
||||
/* #undef GETTIMEOFDAY_NO_TZ */
|
||||
|
||||
|
@ -141,6 +141,7 @@
|
|||
#define HAVE_FSTATAT 1
|
||||
#define HAVE_FSYNC 1
|
||||
#define HAVE_GETENTROPY 1
|
||||
#define HAVE_GETLOADAVG 1
|
||||
/* #undef HAVE_FEXECVE */
|
||||
/* #undef HAVE_FSTATVFS */
|
||||
/* #undef HAVE_FTIME */
|
||||
|
@ -148,7 +149,6 @@
|
|||
/* #define HAVE_SETGROUPS 1 */
|
||||
/* #define HAVE_INITGROUPS 1 */
|
||||
/* #define HAVE_GETGROUPLIST 1 */
|
||||
/* #undef HAVE_GETLOADAVG */
|
||||
|
||||
#define HAVE_FSEEKO 1
|
||||
#define HAVE_FTELLO 1
|
||||
|
@ -162,8 +162,8 @@
|
|||
/* #undef HAVE_GETHOSTBYNAME_R_5_ARG */
|
||||
/* #undef HAVE_GETHOSTBYNAME_R_6_ARG */
|
||||
|
||||
/* #undef HAVE_GETRESGID */
|
||||
/* #undef HAVE_GETRESUID */
|
||||
#define HAVE_GETRESGID 1
|
||||
#define HAVE_GETRESUID 1
|
||||
/* #undef HAVE_GETSPENT */
|
||||
/* #undef HAVE_GETSPNAM */
|
||||
|
||||
|
@ -477,7 +477,7 @@
|
|||
/* #undef TM_IN_SYS_TIME */
|
||||
|
||||
/* Define if you want to use computed gotos in ceval.c. */
|
||||
/* #define USE_COMPUTED_GOTOS 1 */
|
||||
#define USE_COMPUTED_GOTOS 1
|
||||
|
||||
/* Define to use the C99 inline keyword. */
|
||||
#define USE_INLINE 1
|
||||
|
|
20
third_party/zip/unix.c
vendored
20
third_party/zip/unix.c
vendored
|
@ -10,28 +10,16 @@
|
|||
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
|
||||
*/
|
||||
#include "libc/calls/struct/dirent.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/sysv/consts/s.h"
|
||||
#include "third_party/zip/zip.h"
|
||||
|
||||
#ifndef UTIL /* the companion #endif is a bit of ways down ... */
|
||||
|
||||
#include "libc/time/time.h"
|
||||
#include "libc/sysv/consts/_posix.h"
|
||||
#include "libc/calls/struct/stat.macros.h"
|
||||
|
||||
#if defined(MINIX) || defined(__mpexl)
|
||||
# ifdef S_IWRITE
|
||||
# undef S_IWRITE
|
||||
# endif /* S_IWRITE */
|
||||
# define S_IWRITE S_IWUSR
|
||||
#endif /* MINIX */
|
||||
|
||||
#if (!defined(S_IWRITE) && defined(S_IWUSR))
|
||||
# define S_IWRITE S_IWUSR
|
||||
#endif
|
||||
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/sysv/consts/dt.h"
|
||||
|
||||
#ifndef UTIL /* the companion #endif is a bit of ways down ... */
|
||||
|
||||
#define PAD 0
|
||||
#define PATH_END '/'
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue