mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 05:42:29 +00:00
Pay off more technical debt
This makes breaking changes to add underscores to many non-standard function names provided by the c library. MODE=tiny is now tinier and we now use smaller locks that are better for tiny apps in this mode. Some headers have been renamed to be in the same folder as the build package, so it'll be easier to know which build dependency is needed. Certain old misguided interfaces have been removed. Intel intrinsics headers are now listed in libc/isystem (but not in the amalgamation) to help further improve open source compatibility. Header complexity has also been reduced. Lastly, more shell scripts are now available.
This commit is contained in:
parent
b69f3d2488
commit
6f7d0cb1c3
960 changed files with 4072 additions and 4873 deletions
|
@ -28,7 +28,7 @@
|
|||
│ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/mem/gc.internal.h"
|
||||
#include "third_party/python/Modules/_decimal/libmpdec/bits.h"
|
||||
#include "third_party/python/Modules/_decimal/libmpdec/constants.h"
|
||||
#include "third_party/python/Modules/_decimal/libmpdec/mpdecimal.h"
|
||||
|
|
2
third_party/python/Modules/getpath.c
vendored
2
third_party/python/Modules/getpath.c
vendored
|
@ -11,7 +11,7 @@
|
|||
#include "libc/log/log.h"
|
||||
#include "libc/mem/alloca.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/mem/gc.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/auxv.h"
|
||||
|
|
4
third_party/python/Modules/posixmodule.c
vendored
4
third_party/python/Modules/posixmodule.c
vendored
|
@ -11,6 +11,7 @@
|
|||
#include "libc/calls/makedev.h"
|
||||
#include "libc/calls/struct/dirent.h"
|
||||
#include "libc/calls/struct/iovec.h"
|
||||
#include "libc/calls/struct/rusage.h"
|
||||
#include "libc/calls/struct/sched_param.h"
|
||||
#include "libc/calls/struct/stat.macros.h"
|
||||
#include "libc/calls/struct/statvfs.h"
|
||||
|
@ -25,9 +26,9 @@
|
|||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/intrin/weaken.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/mem/alg.h"
|
||||
#include "libc/mem/gc.internal.h"
|
||||
#include "libc/nt/createfile.h"
|
||||
#include "libc/nt/dll.h"
|
||||
#include "libc/nt/enum/creationdisposition.h"
|
||||
|
@ -36,7 +37,6 @@
|
|||
#include "libc/nt/files.h"
|
||||
#include "libc/nt/runtime.h"
|
||||
#include "libc/runtime/dlfcn.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/runtime/pathconf.h"
|
||||
#include "libc/runtime/sysconf.h"
|
||||
#include "libc/sock/sendfile.internal.h"
|
||||
|
|
2
third_party/python/Modules/selectmodule.c
vendored
2
third_party/python/Modules/selectmodule.c
vendored
|
@ -9,7 +9,7 @@
|
|||
#include "libc/errno.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/nt/efi.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/mem/gc.internal.h"
|
||||
#include "libc/sock/epoll.h"
|
||||
#include "libc/sock/select.h"
|
||||
#include "libc/sock/sock.h"
|
||||
|
|
2
third_party/python/Modules/tlsmodule.c
vendored
2
third_party/python/Modules/tlsmodule.c
vendored
|
@ -20,7 +20,7 @@
|
|||
#include "libc/calls/calls.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/mem/gc.internal.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "net/https/https.h"
|
||||
#include "third_party/mbedtls/ctr_drbg.h"
|
||||
|
|
10
third_party/python/Modules/unicodedata.c
vendored
10
third_party/python/Modules/unicodedata.c
vendored
|
@ -5,8 +5,8 @@
|
|||
│ https://docs.python.org/3/license.html │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#define PY_SSIZE_T_CLEAN
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/nexgen32e/kompressor.h"
|
||||
#include "third_party/python/Include/floatobject.h"
|
||||
#include "third_party/python/Include/import.h"
|
||||
|
@ -405,7 +405,7 @@ unicodedata_UCD_decomposition_impl(PyObject *self, int chr)
|
|||
|
||||
/* high byte is number of hex bytes (usually one or two), low byte
|
||||
is prefix code (from*/
|
||||
count = bextra(_PyUnicode_Decomp, index, _PyUnicode_DecompBits) >> 8;
|
||||
count = _bextra(_PyUnicode_Decomp, index, _PyUnicode_DecompBits) >> 8;
|
||||
|
||||
/* XXX: could allocate the PyString up front instead
|
||||
(strlen(prefix) + 5 * count + 1 bytes) */
|
||||
|
@ -413,7 +413,7 @@ unicodedata_UCD_decomposition_impl(PyObject *self, int chr)
|
|||
/* Based on how index is calculated above and _PyUnicode_Decomp is
|
||||
generated from Tools/unicode/makeunicodedata.py, it should not be
|
||||
possible to overflow _PyUnicode_DecompPrefix. */
|
||||
prefix_index = bextra(_PyUnicode_Decomp, index, _PyUnicode_DecompBits) & 255;
|
||||
prefix_index = _bextra(_PyUnicode_Decomp, index, _PyUnicode_DecompBits) & 255;
|
||||
assert(prefix_index < Py_ARRAY_LENGTH(_PyUnicode_DecompPrefix));
|
||||
|
||||
/* copy prefix */
|
||||
|
@ -425,8 +425,8 @@ unicodedata_UCD_decomposition_impl(PyObject *self, int chr)
|
|||
decomp[i++] = ' ';
|
||||
assert(i < sizeof(decomp));
|
||||
PyOS_snprintf(decomp + i, sizeof(decomp) - i, "%04X",
|
||||
bextra(_PyUnicode_Decomp, ++index,
|
||||
_PyUnicode_DecompBits));
|
||||
_bextra(_PyUnicode_Decomp, ++index,
|
||||
_PyUnicode_DecompBits));
|
||||
i += strlen(decomp + i);
|
||||
}
|
||||
return PyUnicode_FromStringAndSize(decomp, i);
|
||||
|
|
18
third_party/python/Modules/unicodedata_getcode.c
vendored
18
third_party/python/Modules/unicodedata_getcode.c
vendored
|
@ -4,8 +4,8 @@
|
|||
│ Python 3 │
|
||||
│ https://docs.python.org/3/license.html │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "third_party/python/Include/pyctype.h"
|
||||
#include "third_party/python/Include/pyerrors.h"
|
||||
#include "third_party/python/Include/pymacro.h"
|
||||
|
@ -174,7 +174,7 @@ _PyUnicode_GetCode(PyObject *self, const char *name, int namelen, Py_UCS4 *code,
|
|||
details */
|
||||
h = (unsigned int)_gethash(name, namelen, _PyUnicode_CodeMagic);
|
||||
i = ~h & mask;
|
||||
v = bextra(_PyUnicode_CodeHash, i, _PyUnicode_CodeHashBits);
|
||||
v = _bextra(_PyUnicode_CodeHash, i, _PyUnicode_CodeHashBits);
|
||||
if (!v)
|
||||
return 0;
|
||||
if (_cmpname(self, v, name, namelen))
|
||||
|
@ -184,7 +184,7 @@ _PyUnicode_GetCode(PyObject *self, const char *name, int namelen, Py_UCS4 *code,
|
|||
incr = mask;
|
||||
for (;;) {
|
||||
i = (i + incr) & mask;
|
||||
v = bextra(_PyUnicode_CodeHash, i, _PyUnicode_CodeHashBits);
|
||||
v = _bextra(_PyUnicode_CodeHash, i, _PyUnicode_CodeHashBits);
|
||||
if (!v)
|
||||
return 0;
|
||||
if (_cmpname(self, v, name, namelen))
|
||||
|
@ -247,10 +247,10 @@ _PyUnicode_GetUcName(PyObject *self, Py_UCS4 code, char *buffer, int buflen,
|
|||
}
|
||||
/* get offset into phrasebook */
|
||||
offset = _PyUnicode_PhrasebookOffset1[(code>>_PyUnicode_PhrasebookShift)];
|
||||
offset = bextra(_PyUnicode_PhrasebookOffset2,
|
||||
(offset << _PyUnicode_PhrasebookShift) +
|
||||
(code & ((1 << _PyUnicode_PhrasebookShift) - 1)),
|
||||
_PyUnicode_PhrasebookOffset2Bits);
|
||||
offset = _bextra(_PyUnicode_PhrasebookOffset2,
|
||||
(offset << _PyUnicode_PhrasebookShift) +
|
||||
(code & ((1 << _PyUnicode_PhrasebookShift) - 1)),
|
||||
_PyUnicode_PhrasebookOffset2Bits);
|
||||
if (!offset)
|
||||
return 0;
|
||||
i = 0;
|
||||
|
@ -271,8 +271,8 @@ _PyUnicode_GetUcName(PyObject *self, Py_UCS4 code, char *buffer, int buflen,
|
|||
word has bit 7 set. the last word in a string ends with
|
||||
0x80 */
|
||||
w = (_PyUnicode_Lexicon +
|
||||
bextra(_PyUnicode_LexiconOffset, word,
|
||||
_PyUnicode_LexiconOffsetBits));
|
||||
_bextra(_PyUnicode_LexiconOffset, word,
|
||||
_PyUnicode_LexiconOffsetBits));
|
||||
while (*w < 128) {
|
||||
if (i >= buflen)
|
||||
return 0; /* buffer overflow */
|
||||
|
|
|
@ -31,7 +31,7 @@ _PyUnicode_GetDecompRecord(PyObject *self,
|
|||
}
|
||||
/* high byte is number of hex bytes (usually one or two), low byte
|
||||
is prefix code (from*/
|
||||
decomp = bextra(_PyUnicode_Decomp, *index, _PyUnicode_DecompBits);
|
||||
decomp = _bextra(_PyUnicode_Decomp, *index, _PyUnicode_DecompBits);
|
||||
*count = decomp >> 8;
|
||||
*prefix = decomp & 255;
|
||||
(*index)++;
|
||||
|
|
|
@ -115,10 +115,10 @@ _PyUnicode_NfcNfkc(PyObject *self, PyObject *input, int k)
|
|||
}
|
||||
index = f * UNIDATA_TOTAL_LAST + l;
|
||||
index1 = _PyUnicode_CompIndex[index >> _PyUnicode_CompShift];
|
||||
code = bextra(_PyUnicode_CompData,
|
||||
(index1 << _PyUnicode_CompShift)+
|
||||
(index & ((1 << _PyUnicode_CompShift) - 1)),
|
||||
_PyUnicode_CompDataBits);
|
||||
code = _bextra(_PyUnicode_CompData,
|
||||
(index1 << _PyUnicode_CompShift)+
|
||||
(index & ((1 << _PyUnicode_CompShift) - 1)),
|
||||
_PyUnicode_CompDataBits);
|
||||
if (code == 0)
|
||||
goto not_combinable;
|
||||
/* Replace the original character. */
|
||||
|
|
|
@ -97,9 +97,9 @@ _PyUnicode_NfdNfkd(PyObject *self, PyObject *input, int k)
|
|||
/* Copy decomposition onto the stack, in reverse
|
||||
order. */
|
||||
while(count) {
|
||||
code = bextra(_PyUnicode_Decomp,
|
||||
index + (--count),
|
||||
_PyUnicode_DecompBits);
|
||||
code = _bextra(_PyUnicode_Decomp,
|
||||
index + (--count),
|
||||
_PyUnicode_DecompBits);
|
||||
stack[stackptr++] = code;
|
||||
}
|
||||
}
|
||||
|
|
2
third_party/python/Objects/listobject.c
vendored
2
third_party/python/Objects/listobject.c
vendored
|
@ -6,7 +6,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/mem/gc.internal.h"
|
||||
#include "third_party/python/Include/abstract.h"
|
||||
#include "third_party/python/Include/accu.h"
|
||||
#include "third_party/python/Include/boolobject.h"
|
||||
|
|
8
third_party/python/Objects/unicodeobject.c
vendored
8
third_party/python/Objects/unicodeobject.c
vendored
|
@ -6,10 +6,10 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#define PY_SSIZE_T_CLEAN
|
||||
#include "libc/assert.h"
|
||||
#include "libc/intrin/likely.h"
|
||||
#include "libc/intrin/weaken.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/intrin/likely.h"
|
||||
#include "libc/intrin/weaken.h"
|
||||
#include "libc/log/countbranch.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "third_party/python/Include/abstract.h"
|
||||
|
@ -6029,7 +6029,7 @@ _PyUnicode_DecodeUnicodeEscape(const char *s,
|
|||
|
||||
/* \N{name} */
|
||||
case 'N':
|
||||
if (!weaken(_PyUnicode_GetCode)) {
|
||||
if (!_weaken(_PyUnicode_GetCode)) {
|
||||
PyErr_SetString(
|
||||
PyExc_UnicodeError,
|
||||
"\\N escapes not supported "
|
||||
|
@ -6049,7 +6049,7 @@ _PyUnicode_DecodeUnicodeEscape(const char *s,
|
|||
s++;
|
||||
ch = 0xffffffff; /* in case 'getcode' messes up */
|
||||
if (namelen <= INT_MAX &&
|
||||
weaken(_PyUnicode_GetCode)(NULL, start, (int)namelen, &ch, 0)) {
|
||||
_weaken(_PyUnicode_GetCode)(NULL, start, (int)namelen, &ch, 0)) {
|
||||
assert(ch <= MAX_UNICODE);
|
||||
WRITE_CHAR(ch);
|
||||
continue;
|
||||
|
|
4
third_party/python/Parser/node.c
vendored
4
third_party/python/Parser/node.c
vendored
|
@ -5,7 +5,7 @@
|
|||
│ https://docs.python.org/3/license.html │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/nexgen32e/bsr.h"
|
||||
#include "libc/intrin/bsr.h"
|
||||
#include "third_party/python/Include/errcode.h"
|
||||
#include "third_party/python/Include/node.h"
|
||||
#include "third_party/python/Include/objimpl.h"
|
||||
|
@ -32,7 +32,7 @@ fancy_roundup(int x)
|
|||
/* Round up to the closest power of 2 >= n. */
|
||||
int r;
|
||||
assert(x > 128);
|
||||
r = 1u << (bsr(x - 1) + 1); /* hacker's delight */
|
||||
r = 1u << (_bsr(x - 1) + 1); /* hacker's delight */
|
||||
return r > 0 ? r : -1;
|
||||
}
|
||||
|
||||
|
|
4
third_party/python/Python/codecs.c
vendored
4
third_party/python/Python/codecs.c
vendored
|
@ -1009,14 +1009,14 @@ PyObject *PyCodec_NameReplaceErrors(PyObject *exc)
|
|||
return NULL;
|
||||
for (i = start, ressize = 0; i < end; ++i) {
|
||||
/* object is guaranteed to be "ready" */
|
||||
if (!weaken(_PyUnicode_GetUcName)) {
|
||||
if (!_weaken(_PyUnicode_GetUcName)) {
|
||||
PyErr_SetString(
|
||||
PyExc_UnicodeError,
|
||||
"_PyUnicode_GetUcName() not available");
|
||||
return NULL;
|
||||
}
|
||||
c = PyUnicode_READ_CHAR(object, i);
|
||||
if (weaken(_PyUnicode_GetUcName)(NULL, c, buffer, sizeof(buffer), 1)) {
|
||||
if (_weaken(_PyUnicode_GetUcName)(NULL, c, buffer, sizeof(buffer), 1)) {
|
||||
replsize = 1+1+1+(int)strlen(buffer)+1;
|
||||
}
|
||||
else if (c >= 0x10000) {
|
||||
|
|
3
third_party/python/Python/fatality.c
vendored
3
third_party/python/Python/fatality.c
vendored
|
@ -6,6 +6,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/weaken.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "third_party/python/Include/abstract.h"
|
||||
#include "third_party/python/Include/pyerrors.h"
|
||||
|
@ -159,6 +160,6 @@ exit:
|
|||
#if defined(MS_WINDOWS) && defined(_DEBUG)
|
||||
DebugBreak();
|
||||
#endif
|
||||
if (weaken(__die)) weaken(__die)();
|
||||
if (_weaken(__die)) _weaken(__die)();
|
||||
abort();
|
||||
}
|
||||
|
|
6
third_party/python/Python/getcopyright.c
vendored
6
third_party/python/Python/getcopyright.c
vendored
|
@ -4,9 +4,9 @@
|
|||
│ Python 3 │
|
||||
│ https://docs.python.org/3/license.html │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/weaken.h"
|
||||
#include "libc/intrin/cmpxchg.h"
|
||||
#include "libc/stdio/append.internal.h"
|
||||
#include "libc/intrin/weaken.h"
|
||||
#include "libc/stdio/append.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "third_party/python/Include/pylifecycle.h"
|
||||
/* clang-format off */
|
||||
|
@ -32,7 +32,7 @@ Py_GetCopyright(void)
|
|||
static char *res;
|
||||
if (_cmpxchg(&once, 0, 1)) {
|
||||
appends(&res, "");
|
||||
for (p = *weaken(kLegalNotices); *p; p += strlen(p) + 1) {
|
||||
for (p = *_weaken(kLegalNotices); *p; p += strlen(p) + 1) {
|
||||
appends(&res, p);
|
||||
}
|
||||
}
|
||||
|
|
12
third_party/python/Python/import.c
vendored
12
third_party/python/Python/import.c
vendored
|
@ -4,15 +4,15 @@
|
|||
│ Python 3 │
|
||||
│ https://docs.python.org/3/license.html │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/mem/alg.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/calls/struct/stat.macros.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/mem/alg.h"
|
||||
#include "libc/mem/gc.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/gc.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/sysv/consts/s.h"
|
||||
#include "libc/x/x.h"
|
||||
|
@ -887,7 +887,7 @@ PyImport_ExecCodeModuleWithPathnames(const char *name, PyObject *co,
|
|||
// cpathobj != NULL means cpathname != NULL
|
||||
size_t cpathlen = strlen(cpathname);
|
||||
char *pathname2 = _gc(strdup(cpathname));
|
||||
if (endswith(pathname2, ".pyc"))
|
||||
if (_endswith(pathname2, ".pyc"))
|
||||
{
|
||||
pathname2[cpathlen-2] = '\0'; // so now ends with .py
|
||||
if(!stat(pathname2, &stinfo) && (stinfo.st_mode & S_IFMT) == S_IFREG)
|
||||
|
@ -2370,7 +2370,7 @@ static PyObject *_imp_source_from_cache(PyObject *module, PyObject *arg) {
|
|||
Py_ssize_t pathlen = 0;
|
||||
if (!PyArg_Parse(PyOS_FSPath(arg), "z#:source_from_cache", &path, &pathlen))
|
||||
return NULL;
|
||||
if (!path || !endswith(path, ".pyc")) {
|
||||
if (!path || !_endswith(path, ".pyc")) {
|
||||
PyErr_Format(PyExc_ValueError, "%s does not end in .pyc", path);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -2666,7 +2666,7 @@ static PyObject *SFLObject_is_package(SourcelessFileLoader *self,
|
|||
self->name, name);
|
||||
return NULL;
|
||||
}
|
||||
if (startswith(basename(self->path), "__init__")) {
|
||||
if (_startswith(basename(self->path), "__init__")) {
|
||||
Py_RETURN_TRUE;
|
||||
}
|
||||
Py_RETURN_FALSE;
|
||||
|
|
2
third_party/python/Python/marshal.c
vendored
2
third_party/python/Python/marshal.c
vendored
|
@ -9,7 +9,7 @@
|
|||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/mem/gc.internal.h"
|
||||
#include "third_party/python/Include/abstract.h"
|
||||
#include "third_party/python/Include/boolobject.h"
|
||||
#include "third_party/python/Include/code.h"
|
||||
|
|
2
third_party/python/Python/sysmodule.c
vendored
2
third_party/python/Python/sysmodule.c
vendored
|
@ -9,7 +9,7 @@
|
|||
#include "libc/mem/mem.h"
|
||||
#include "libc/nt/dll.h"
|
||||
#include "libc/nt/version.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/mem/gc.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/locale.h"
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "libc/log/check.h"
|
||||
#include "libc/nexgen32e/crc32.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/append.internal.h"
|
||||
#include "libc/stdio/append.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "third_party/zlib/zlib.h"
|
||||
|
|
9
third_party/python/pycomp.c
vendored
9
third_party/python/pycomp.c
vendored
|
@ -24,10 +24,11 @@
|
|||
#include "libc/intrin/bits.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/mem/gc.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "libc/x/xasprintf.h"
|
||||
#include "third_party/getopt/getopt.h"
|
||||
#include "third_party/python/Include/bytesobject.h"
|
||||
#include "third_party/python/Include/compile.h"
|
||||
|
@ -119,15 +120,15 @@ main(int argc, char *argv[])
|
|||
GetOpts(argc, argv);
|
||||
marshalled = 0;
|
||||
if (stat(inpath, &st) == -1) perror(inpath), exit(1);
|
||||
CHECK_NOTNULL((p = gc(xslurp(inpath, &n))));
|
||||
CHECK_NOTNULL((p = _gc(xslurp(inpath, &n))));
|
||||
Py_NoUserSiteDirectory++;
|
||||
Py_NoSiteFlag++;
|
||||
Py_IgnoreEnvironmentFlag++;
|
||||
Py_FrozenFlag++;
|
||||
/* Py_VerboseFlag++; */
|
||||
Py_SetProgramName(gc(utf8to32(argv[0], -1, 0)));
|
||||
Py_SetProgramName(_gc(utf8to32(argv[0], -1, 0)));
|
||||
_Py_InitializeEx_Private(1, 0);
|
||||
name = gc(xjoinpaths("/zip/.python", StripComponents(inpath, 3)));
|
||||
name = _gc(xjoinpaths("/zip/.python", StripComponents(inpath, 3)));
|
||||
code = Py_CompileStringExFlags(p, name, Py_file_input, NULL, optimize);
|
||||
if (!code) goto error;
|
||||
marshalled = PyMarshal_WriteObjectToString(code, Py_MARSHAL_VERSION);
|
||||
|
|
10
third_party/python/pyobj.c
vendored
10
third_party/python/pyobj.c
vendored
|
@ -17,19 +17,19 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/iovec.h"
|
||||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/elf/def.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/mem/gc.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/append.internal.h"
|
||||
#include "libc/stdio/append.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/sysv/consts/clock.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
|
@ -354,7 +354,7 @@ GetModName(bool *ispkg)
|
|||
{
|
||||
char *mod;
|
||||
mod = Dotify(xstripexts(StripComponents(pyfile, strip_components)));
|
||||
if ((*ispkg = endswith(mod, ".__init__"))) {
|
||||
if ((*ispkg = _endswith(mod, ".__init__"))) {
|
||||
mod[strlen(mod) - strlen(".__init__")] = 0;
|
||||
}
|
||||
return mod;
|
||||
|
@ -385,7 +385,7 @@ GetParent2(void)
|
|||
{
|
||||
char *p, *mod;
|
||||
mod = Dotify(xstripexts(StripComponents(pyfile, strip_components)));
|
||||
if (endswith(mod, ".__init__")) mod[strlen(mod) - strlen(".__init__")] = 0;
|
||||
if (_endswith(mod, ".__init__")) mod[strlen(mod) - strlen(".__init__")] = 0;
|
||||
if ((p = strrchr(mod, '.'))) *p = 0;
|
||||
return mod;
|
||||
}
|
||||
|
|
9
third_party/python/runpythonmodule.c
vendored
9
third_party/python/runpythonmodule.c
vendored
|
@ -18,8 +18,8 @@
|
|||
#include "libc/log/check.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/mem/gc.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/runtime/symbols.internal.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
|
@ -30,6 +30,7 @@
|
|||
#include "libc/sysv/consts/sig.h"
|
||||
#include "libc/time/time.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "libc/x/xasprintf.h"
|
||||
#include "third_party/linenoise/linenoise.h"
|
||||
#include "third_party/python/Include/abstract.h"
|
||||
#include "third_party/python/Include/ceval.h"
|
||||
|
@ -95,7 +96,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 (startswithi(it->name, p)) {
|
||||
if (_startswithi(it->name, p)) {
|
||||
AddCompletion(c, xasprintf("%s%s", s, it->name + plen));
|
||||
}
|
||||
}
|
||||
|
@ -169,7 +170,7 @@ Complete(const char *p, linenoiseCompletions *c)
|
|||
{
|
||||
PyObject *o, *t, *i;
|
||||
const char *q, *s, *b;
|
||||
if (startswith(p, "import ")) {
|
||||
if (_startswith(p, "import ")) {
|
||||
for (q = p + 7; *q; ++q) {
|
||||
if (!isalnum(*q) && *q != '_') {
|
||||
return;
|
||||
|
@ -279,7 +280,7 @@ RunPythonModule(int argc, char **argv)
|
|||
int i, res;
|
||||
char *oldloc;
|
||||
|
||||
if (argc == 1 && weaken(kLaunchPythonModuleName)) {
|
||||
if (argc == 1 && _weaken(kLaunchPythonModuleName)) {
|
||||
launchargs[0] = argv[0];
|
||||
launchargs[1] = strdup("-m");
|
||||
launchargs[2] = strdup(kLaunchPythonModuleName);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue