Make improvements

- Expand redbean UNIX module
- Expand redbean documentation
- Ensure Lua copyright is embedded in binary
- Increase the PATH_MAX limit especially on NT
- Use column major sorting for linenoise completions
- Fix some suboptimalities in redbean's new UNIX API
- Figured out right flags for Multics newline in raw mode
This commit is contained in:
Justine Tunney 2022-04-24 09:59:22 -07:00
parent cf3174dc74
commit 2046c0d2ae
305 changed files with 6602 additions and 4221 deletions

View file

@ -603,7 +603,7 @@ PyInit_termios(void)
if (IXANY) PyModule_AddIntConstant(m, "IXANY", IXANY);
if (IXOFF) PyModule_AddIntConstant(m, "IXOFF", IXOFF);
if (IMAXBEL) PyModule_AddIntConstant(m, "IMAXBEL", IMAXBEL);
if (OPOST) PyModule_AddIntConstant(m, "OPOST", OPOST);
PyModule_AddIntConstant(m, "OPOST", OPOST);
if (OLCUC) PyModule_AddIntConstant(m, "OLCUC", OLCUC);
if (ONLCR) PyModule_AddIntConstant(m, "ONLCR", ONLCR);
if (OCRNL) PyModule_AddIntConstant(m, "OCRNL", OCRNL);

View file

@ -35,6 +35,7 @@
#include "libc/sysv/consts/o.h"
#include "libc/time/time.h"
#include "libc/x/x.h"
#include "libc/zip.h"
#include "third_party/getopt/getopt.h"
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/bytesobject.h"
@ -658,16 +659,19 @@ Objectify(void)
if (ispkg) {
elfwriter_zip(elf, zipdir, zipdir, strlen(zipdir),
pydata, 0, 040755, timestamp, timestamp,
timestamp, nocompress, image_base);
timestamp, nocompress, image_base,
kZipCdirHdrLinkableSize);
}
if (!binonly) {
elfwriter_zip(elf, gc(xstrcat("py:", modname)), zipfile,
strlen(zipfile), pydata, pysize, st.st_mode, timestamp,
timestamp, timestamp, nocompress, image_base);
timestamp, timestamp, nocompress, image_base,
kZipCdirHdrLinkableSize);
}
elfwriter_zip(elf, gc(xstrcat("pyc:", modname)), gc(xstrcat(zipfile, 'c')),
strlen(zipfile) + 1, pycdata, pycsize, st.st_mode, timestamp,
timestamp, timestamp, nocompress, image_base);
timestamp, timestamp, nocompress, image_base,
kZipCdirHdrLinkableSize);
elfwriter_align(elf, 1, 0);
elfwriter_startsection(elf, ".yoink", SHT_PROGBITS,
SHF_ALLOC | SHF_EXECINSTR);

View file

@ -87,7 +87,7 @@ CompleteModule(const char *s, const char *p, linenoiseCompletions *c)
PyObject *m, *f, *g, *i, *v, *n;
plen = strlen(p);
for (it = PyImport_Inittab; it->name; ++it) {
if (startswith(it->name, p)) {
if (startswithi(it->name, p)) {
AddCompletion(c, xasprintf("%s%s", s, it->name + plen));
}
}
@ -98,7 +98,7 @@ CompleteModule(const char *s, const char *p, linenoiseCompletions *c)
while ((v = PyIter_Next(i))) {
if ((n = PyObject_GetAttrString(v, "name"))) {
if (((name = PyUnicode_AsUTF8AndSize(n, &namelen)) &&
namelen >= plen && !bcmp(name, p, plen))) {
namelen >= plen && !memcasecmp(name, p, plen))) {
AddCompletion(c, xasprintf("%s%s", s, name + plen));
}
Py_DECREF(n);
@ -125,7 +125,7 @@ CompleteDict(const char *b, const char *q, const char *p,
for (i = 0; PyDict_Next(o, &i, &k, &v);) {
if ((v != Py_None && PyUnicode_Check(k) &&
(s = PyUnicode_AsUTF8AndSize(k, &m)) &&
m >= q - p && !bcmp(s, p, q - p))) {
m >= q - p && !memcasecmp(s, p, q - p))) {
AddCompletion(c, xasprintf("%.*s%.*s", p - b, b, m, s));
}
}
@ -142,7 +142,10 @@ CompleteDir(const char *b, const char *q, const char *p,
if ((i = PyObject_GetIter(d))) {
while ((k = PyIter_Next(i))) {
if (((s = PyUnicode_AsUTF8AndSize(k, &m)) &&
m >= q - p && !bcmp(s, p, q - p))) {
m >= q - p && !memcasecmp(s, p, q - p) &&
!(q - p == 0 && m > 4 &&
(s[0+0] == '_' && s[0+1] == '_' &&
s[m-1] == '_' && s[m-2] == '_')))) {
AddCompletion(c, xasprintf("%.*s%.*s", p - b, b, m, s));
}
Py_DECREF(k);