mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-28 13:30:29 +00:00
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:
parent
cf3174dc74
commit
2046c0d2ae
305 changed files with 6602 additions and 4221 deletions
4
third_party/argon2/blake2b.c
vendored
4
third_party/argon2/blake2b.c
vendored
|
@ -42,7 +42,7 @@ static const uint64_t blake2b_IV[8] = {
|
|||
UINT64_C(0x1f83d9abfb41bd6b), UINT64_C(0x5be0cd19137e2179),
|
||||
};
|
||||
|
||||
static const unsigned int blake2b_sigma[12][16] = {
|
||||
static const unsigned char blake2b_sigma[12][16] = {
|
||||
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
|
||||
{14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3},
|
||||
{11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4},
|
||||
|
@ -69,7 +69,7 @@ static inline void blake2b_set_lastblock(blake2b_state *S) {
|
|||
}
|
||||
|
||||
static inline void blake2b_increment_counter(blake2b_state *S,
|
||||
uint64_t inc) {
|
||||
uint64_t inc) {
|
||||
S->t[0] += inc;
|
||||
S->t[1] += (S->t[0] < inc);
|
||||
}
|
||||
|
|
163
third_party/linenoise/linenoise.c
vendored
163
third_party/linenoise/linenoise.c
vendored
|
@ -125,6 +125,7 @@
|
|||
│ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/alg/alg.h"
|
||||
#include "libc/assert.h"
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/calls/calls.h"
|
||||
|
@ -136,6 +137,7 @@
|
|||
#include "libc/calls/termios.h"
|
||||
#include "libc/calls/ttydefaults.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
|
@ -147,6 +149,7 @@
|
|||
#include "libc/mem/mem.h"
|
||||
#include "libc/nexgen32e/bsr.h"
|
||||
#include "libc/nexgen32e/rdtsc.h"
|
||||
#include "libc/nt/version.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/stdio/append.internal.h"
|
||||
|
@ -190,15 +193,21 @@ Copyright 2010-2013 Pieter Noordhuis <pcnoordhuis@gmail.com>\"");
|
|||
#define DEBUG(L, ...) (void)0
|
||||
#endif
|
||||
|
||||
#define DUFF_ROUTINE_READ(STATE) \
|
||||
case STATE: \
|
||||
linenoiseRefreshLineForce(l); \
|
||||
rc = linenoiseRead(l->ifd, seq, sizeof(seq), l, block); \
|
||||
if (rc == -1 && errno == EAGAIN) { \
|
||||
l->state = STATE; \
|
||||
return -1; \
|
||||
} \
|
||||
l->state = 0
|
||||
#define DUFF_ROUTINE_LOOP 0
|
||||
#define DUFF_ROUTINE_START 5
|
||||
|
||||
#define DUFF_ROUTINE_LABEL(STATE) \
|
||||
case STATE: \
|
||||
linenoiseRefreshLineForce(l); \
|
||||
l->state = DUFF_ROUTINE_LOOP
|
||||
|
||||
#define DUFF_ROUTINE_READ(STATE) \
|
||||
DUFF_ROUTINE_LABEL(STATE); \
|
||||
rc = linenoiseRead(l->ifd, seq, sizeof(seq), l, block); \
|
||||
if (rc == -1 && errno == EAGAIN) { \
|
||||
l->state = STATE; \
|
||||
return -1; \
|
||||
}
|
||||
|
||||
#define BLOCKING_READ() rc = linenoiseRead(l->ifd, seq, sizeof(seq), l, false)
|
||||
|
||||
|
@ -399,7 +408,9 @@ static int linenoiseIsUnsupportedTerm(void) {
|
|||
char *term;
|
||||
static char once, res;
|
||||
if (!once) {
|
||||
if ((term = getenv("TERM"))) {
|
||||
if (IsWindows() && !IsAtLeastWindows10()) {
|
||||
res = 1;
|
||||
} else if ((term = getenv("TERM"))) {
|
||||
for (i = 0; i < sizeof(kUnsupported) / sizeof(*kUnsupported); i++) {
|
||||
if (!strcasecmp(term, kUnsupported[i])) {
|
||||
res = 1;
|
||||
|
@ -656,7 +667,7 @@ int linenoiseEnableRawMode(int fd) {
|
|||
raw = orig_termios;
|
||||
raw.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
|
||||
raw.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG);
|
||||
raw.c_oflag &= ~OPOST;
|
||||
raw.c_oflag |= OPOST | ONLCR;
|
||||
raw.c_iflag |= IUTF8;
|
||||
raw.c_cflag |= CS8;
|
||||
raw.c_cc[VMIN] = 1;
|
||||
|
@ -810,10 +821,10 @@ struct winsize linenoiseGetTerminalSize(struct winsize ws, int ifd, int ofd) {
|
|||
}
|
||||
if (((!ws.ws_col || !ws.ws_row) && linenoiseRead(ifd, 0, 0, 0, 1) != -1 &&
|
||||
linenoiseWriteStr(
|
||||
ofd, "\0337" /* save position */
|
||||
"\033[9979;9979H" /* move cursor to bottom right corner */
|
||||
"\033[6n" /* report position */
|
||||
"\0338") != -1 && /* restore position */
|
||||
ofd, "\e7" /* save position */
|
||||
"\e[9979;9979H" /* move cursor to bottom right corner */
|
||||
"\e[6n" /* report position */
|
||||
"\e8") != -1 && /* restore position */
|
||||
(n = linenoiseRead(ifd, b, sizeof(b), 0, 1)) != -1 &&
|
||||
n && b[0] == 033 && b[1] == '[' && b[n - 1] == 'R')) {
|
||||
p = b + 2;
|
||||
|
@ -827,8 +838,8 @@ struct winsize linenoiseGetTerminalSize(struct winsize ws, int ifd, int ofd) {
|
|||
|
||||
/* Clear the screen. Used to handle ctrl+l */
|
||||
void linenoiseClearScreen(int fd) {
|
||||
linenoiseWriteStr(fd, "\033[H" /* move cursor to top left corner */
|
||||
"\033[2J"); /* erase display */
|
||||
linenoiseWriteStr(fd, "\e[H" /* move cursor to top left corner */
|
||||
"\e[2J"); /* erase display */
|
||||
}
|
||||
|
||||
static void linenoiseBeep(void) {
|
||||
|
@ -962,7 +973,7 @@ static char *linenoiseMakeSearchPrompt(int fail, const char *s, int n) {
|
|||
if (fail) abAppends(&ab, "failed ");
|
||||
abAppends(&ab, "reverse-i-search `\e[4m");
|
||||
abAppend(&ab, s, n);
|
||||
abAppends(&ab, "\033[24m");
|
||||
abAppends(&ab, "\e[24m");
|
||||
abAppends(&ab, s + n);
|
||||
abAppendw(&ab, READ32LE("') "));
|
||||
return ab.b;
|
||||
|
@ -1007,8 +1018,8 @@ static char *linenoiseRefreshHints(struct linenoiseState *l) {
|
|||
if (!hintsCallback) return 0;
|
||||
if (!(hint = hintsCallback(l->buf, &ansi1, &ansi2))) return 0;
|
||||
abInit(&ab);
|
||||
ansi1 = "\033[90m";
|
||||
ansi2 = "\033[39m";
|
||||
ansi1 = "\e[90m";
|
||||
ansi2 = "\e[39m";
|
||||
if (ansi1) abAppends(&ab, ansi1);
|
||||
abAppends(&ab, hint);
|
||||
if (ansi2) abAppends(&ab, ansi2);
|
||||
|
@ -1174,7 +1185,7 @@ StartOver:
|
|||
abInit(&ab);
|
||||
abAppendw(&ab, '\r'); /* start of line */
|
||||
if (l->rows - l->oldpos - 1 > 0) {
|
||||
abAppends(&ab, "\033[");
|
||||
abAppends(&ab, "\e[");
|
||||
abAppendu(&ab, l->rows - l->oldpos - 1);
|
||||
abAppendw(&ab, 'A'); /* cursor up clamped */
|
||||
}
|
||||
|
@ -1185,7 +1196,7 @@ StartOver:
|
|||
if (x && x + rune.n > xn) {
|
||||
if (cy >= 0) ++cy;
|
||||
if (x < xn) {
|
||||
abAppends(&ab, "\033[K"); /* clear line forward */
|
||||
abAppends(&ab, "\e[K"); /* clear line forward */
|
||||
}
|
||||
abAppends(&ab, "\r" /* start of line */
|
||||
"\n"); /* cursor down unclamped */
|
||||
|
@ -1200,9 +1211,9 @@ StartOver:
|
|||
abAppendw(&ab, '*');
|
||||
} else {
|
||||
flipit = hasflip && (i == flip[0] || i == flip[1]);
|
||||
if (flipit) abAppendw(&ab, READ32LE("\033[1m"));
|
||||
if (flipit) abAppendw(&ab, READ32LE("\e[1m"));
|
||||
abAppendw(&ab, tpenc(rune.c));
|
||||
if (flipit) abAppendw(&ab, READ64LE("\033[22m\0\0"));
|
||||
if (flipit) abAppendw(&ab, READ64LE("\e[22m\0\0"));
|
||||
}
|
||||
t = wcwidth(rune.c);
|
||||
t = MAX(0, t);
|
||||
|
@ -1217,7 +1228,7 @@ StartOver:
|
|||
}
|
||||
free(hint);
|
||||
}
|
||||
abAppendw(&ab, READ32LE("\033[J")); /* erase display forwards */
|
||||
abAppendw(&ab, READ32LE("\e[J")); /* erase display forwards */
|
||||
|
||||
/*
|
||||
* if we are at the very end of the screen with our prompt, we need to
|
||||
|
@ -1232,12 +1243,12 @@ StartOver:
|
|||
* move cursor to right position
|
||||
*/
|
||||
if (cy > 0) {
|
||||
abAppendw(&ab, READ32LE("\033[\0"));
|
||||
abAppendw(&ab, READ32LE("\e[\0"));
|
||||
abAppendu(&ab, cy);
|
||||
abAppendw(&ab, 'A'); /* cursor up */
|
||||
}
|
||||
if (cx > 0) {
|
||||
abAppendw(&ab, READ32LE("\r\033["));
|
||||
abAppendw(&ab, READ32LE("\r\e["));
|
||||
abAppendu(&ab, cx);
|
||||
abAppendw(&ab, 'C'); /* cursor right */
|
||||
} else if (!cx) {
|
||||
|
@ -1509,7 +1520,7 @@ static void linenoiseEditYank(struct linenoiseState *l) {
|
|||
|
||||
static void linenoiseEditRotate(struct linenoiseState *l) {
|
||||
if ((l->seq[1][0] == CTRL('Y') ||
|
||||
(l->seq[1][0] == 033 && l->seq[1][1] == 'y'))) {
|
||||
(l->seq[1][0] == '\e' && l->seq[1][1] == 'y'))) {
|
||||
if (l->yi < l->len && l->yj <= l->len) {
|
||||
memmove(l->buf + l->yi, l->buf + l->yj, l->len - l->yj + 1);
|
||||
l->len -= l->yj - l->yi;
|
||||
|
@ -1780,12 +1791,12 @@ struct linenoiseState *linenoiseBegin(const char *prompt, int ifd, int ofd) {
|
|||
free(l);
|
||||
return 0;
|
||||
}
|
||||
l->state = DUFF_ROUTINE_START;
|
||||
l->buf[0] = 0;
|
||||
l->ifd = ifd;
|
||||
l->ofd = ofd;
|
||||
l->prompt = strdup(prompt ? prompt : "");
|
||||
l->ws = linenoiseGetTerminalSize(l->ws, l->ifd, l->ofd);
|
||||
linenoiseHistoryAdd("");
|
||||
linenoiseWriteStr(l->ofd, l->prompt);
|
||||
abInit(&l->ab);
|
||||
return l;
|
||||
|
@ -1814,6 +1825,10 @@ void linenoiseEnd(struct linenoiseState *l) {
|
|||
}
|
||||
}
|
||||
|
||||
static int CompareStrings(const void *a, const void *b) {
|
||||
return strcasecmp(*(const char **)a, *(const char **)b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs linenoise engine.
|
||||
*
|
||||
|
@ -1844,7 +1859,7 @@ ssize_t linenoiseEdit(struct linenoiseState *l, const char *prompt, char **obuf,
|
|||
|
||||
switch (l->state) {
|
||||
for (;;) {
|
||||
DUFF_ROUTINE_READ(0);
|
||||
DUFF_ROUTINE_READ(DUFF_ROUTINE_LOOP);
|
||||
HandleRead:
|
||||
if (!rc && l->len) {
|
||||
rc = 1;
|
||||
|
@ -1933,7 +1948,7 @@ ssize_t linenoiseEdit(struct linenoiseState *l, const char *prompt, char **obuf,
|
|||
|
||||
// handle tab and tab-tab completion
|
||||
if (seq[0] == '\t' && completionCallback) {
|
||||
size_t i, j, k, n, m, perline, itemlen;
|
||||
size_t i, j, k, n, m, itemlen;
|
||||
// we know that the user pressed tab once
|
||||
rc = 0;
|
||||
linenoiseFreeCompletions(&l->lc);
|
||||
|
@ -1956,6 +1971,7 @@ ssize_t linenoiseEdit(struct linenoiseState *l, const char *prompt, char **obuf,
|
|||
continue;
|
||||
}
|
||||
if (l->lc.len > 1) {
|
||||
qsort(l->lc.cvec, l->lc.len, sizeof(*l->lc.cvec), CompareStrings);
|
||||
// if there's a multiline completions, then do nothing and wait and
|
||||
// see if the user presses tab again. if the user does this we then
|
||||
// print ALL the completions, to above the editing line
|
||||
|
@ -1965,29 +1981,42 @@ ssize_t linenoiseEdit(struct linenoiseState *l, const char *prompt, char **obuf,
|
|||
free(s);
|
||||
}
|
||||
for (;;) {
|
||||
DUFF_ROUTINE_READ(3);
|
||||
DUFF_ROUTINE_READ(2);
|
||||
if (rc == 1 && seq[0] == '\t') {
|
||||
const char **p;
|
||||
struct abuf ab;
|
||||
int i, x, y, xn, yn, xy;
|
||||
itemlen = linenoiseMaxCompletionWidth(&l->lc) + 4;
|
||||
perline = MAX(1, (l->ws.ws_col - 1) / itemlen);
|
||||
abInit(&ab);
|
||||
abAppends(&ab, "\r\n\033[K");
|
||||
for (size_t i = 0; i < l->lc.len;) {
|
||||
for (size_t j = 0; i < l->lc.len && j < perline; ++j, ++i) {
|
||||
n = GetMonospaceWidth(l->lc.cvec[i], strlen(l->lc.cvec[i]),
|
||||
0);
|
||||
abAppends(&ab, l->lc.cvec[i]);
|
||||
xn = MAX(1, (l->ws.ws_col - 1) / itemlen);
|
||||
yn = (l->lc.len + (xn - 1)) / xn;
|
||||
if (!__builtin_mul_overflow(xn, yn, &xy) &&
|
||||
(p = calloc(xy, sizeof(char *)))) {
|
||||
// arrange in column major order
|
||||
for (i = x = 0; x < xn; ++x) {
|
||||
for (y = 0; y < yn; ++y) {
|
||||
p[y * xn + x] = i < l->lc.len ? l->lc.cvec[i++] : "";
|
||||
}
|
||||
}
|
||||
abInit(&ab);
|
||||
abAppends(&ab, "\r\n\e[K");
|
||||
for (x = i = 0; i < xy; ++i) {
|
||||
n = GetMonospaceWidth(p[i], strlen(p[i]), 0);
|
||||
abAppends(&ab, p[i]);
|
||||
for (k = n; k < itemlen; ++k) {
|
||||
abAppendw(&ab, ' ');
|
||||
}
|
||||
if (++x == xn) {
|
||||
abAppendw(&ab, READ16LE("\r\n"));
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
abAppendw(&ab, READ16LE("\r\n"));
|
||||
ab.len -= 2;
|
||||
abAppends(&ab, "\n");
|
||||
linenoiseWriteStr(l->ofd, ab.b);
|
||||
linenoiseRefreshLine(l);
|
||||
abFree(&ab);
|
||||
free(p);
|
||||
}
|
||||
ab.len -= 2;
|
||||
abAppends(&ab, "\n");
|
||||
linenoiseWriteStr(l->ofd, ab.b);
|
||||
linenoiseRefreshLine(l);
|
||||
abFree(&ab);
|
||||
} else {
|
||||
goto HandleRead;
|
||||
}
|
||||
|
@ -1998,7 +2027,7 @@ ssize_t linenoiseEdit(struct linenoiseState *l, const char *prompt, char **obuf,
|
|||
// handle (1) emacs keyboard combos
|
||||
// (2) otherwise sigint exit
|
||||
if (seq[0] == CTRL('C')) {
|
||||
DUFF_ROUTINE_READ(4);
|
||||
DUFF_ROUTINE_READ(3);
|
||||
if (rc == 1) {
|
||||
switch (seq[0]) {
|
||||
CASE(CTRL('C'), linenoiseEditInterrupt(l));
|
||||
|
@ -2019,7 +2048,7 @@ ssize_t linenoiseEdit(struct linenoiseState *l, const char *prompt, char **obuf,
|
|||
if (ispaused) {
|
||||
linenoiseUnpause(l->ofd);
|
||||
} else {
|
||||
DUFF_ROUTINE_READ(5);
|
||||
DUFF_ROUTINE_READ(4);
|
||||
if (rc > 0) {
|
||||
char esc[sizeof(seq) * 4];
|
||||
size_t m = linenoiseEscape(esc, seq, rc);
|
||||
|
@ -2031,6 +2060,28 @@ ssize_t linenoiseEdit(struct linenoiseState *l, const char *prompt, char **obuf,
|
|||
continue;
|
||||
}
|
||||
|
||||
// handle enter key
|
||||
if (seq[0] == '\r') {
|
||||
char *p;
|
||||
l->final = 1;
|
||||
free(history[--historylen]);
|
||||
history[historylen] = 0;
|
||||
linenoiseEditEnd(l);
|
||||
linenoiseRefreshLineForce(l);
|
||||
p = strdup(l->buf);
|
||||
linenoiseReset(l);
|
||||
if (p) {
|
||||
*obuf = p;
|
||||
l->state = DUFF_ROUTINE_START;
|
||||
return l->len;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
DUFF_ROUTINE_LABEL(DUFF_ROUTINE_START);
|
||||
linenoiseHistoryAdd("");
|
||||
continue;
|
||||
}
|
||||
|
||||
// handle keystrokes that don't need read()
|
||||
switch (seq[0]) {
|
||||
CASE(CTRL('P'), linenoiseEditUp(l));
|
||||
|
@ -2070,22 +2121,6 @@ ssize_t linenoiseEdit(struct linenoiseState *l, const char *prompt, char **obuf,
|
|||
}
|
||||
break;
|
||||
|
||||
case '\r': {
|
||||
l->final = 1;
|
||||
free(history[--historylen]);
|
||||
history[historylen] = 0;
|
||||
linenoiseEditEnd(l);
|
||||
linenoiseRefreshLineForce(l);
|
||||
char *p = strdup(l->buf);
|
||||
linenoiseReset(l);
|
||||
if (p) {
|
||||
*obuf = p;
|
||||
return l->len;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
case '\e':
|
||||
// handle ansi escape
|
||||
if (rc < 2) break;
|
||||
|
|
2
third_party/lua/README.cosmo
vendored
2
third_party/lua/README.cosmo
vendored
|
@ -30,3 +30,5 @@ LOCAL MODIFICATIONS
|
|||
bold text, which can be encoded elegantly as `\e[1mHELLO\e[0m`.
|
||||
|
||||
Added luaL_traceback2() for function parameters in traceback.
|
||||
|
||||
Added Python-like printf modulus operator for strings.
|
||||
|
|
9
third_party/lua/cosmo.h
vendored
9
third_party/lua/cosmo.h
vendored
|
@ -12,11 +12,12 @@ int LuaEncodeJsonData(lua_State *, char **, int, char *);
|
|||
int LuaEncodeLuaData(lua_State *, char **, int, char *);
|
||||
int LuaEncodeUrl(lua_State *);
|
||||
int LuaParseUrl(lua_State *);
|
||||
void EscapeLuaString(char *, size_t, char **);
|
||||
void LuaPushUrlParams(lua_State *, struct UrlParams *);
|
||||
int LuaPushHeaders(lua_State *, struct HttpMessage *, const char *);
|
||||
void LuaPushLatin1(lua_State *, const char *, size_t);
|
||||
int LuaPushHeader(lua_State *, struct HttpMessage *, char *, int);
|
||||
int LuaPushHeaders(lua_State *, struct HttpMessage *, const char *);
|
||||
void EscapeLuaString(char *, size_t, char **);
|
||||
void LuaPushLatin1(lua_State *, const char *, size_t);
|
||||
void LuaPushUrlParams(lua_State *, struct UrlParams *);
|
||||
void LuaPrintStack(lua_State *);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
|
|
41
third_party/lua/lapi.c
vendored
41
third_party/lua/lapi.c
vendored
|
@ -1,12 +1,32 @@
|
|||
/*
|
||||
** $Id: lapi.c $
|
||||
** Lua API
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╚──────────────────────────────────────────────────────────────────────────────╝
|
||||
│ │
|
||||
│ Lua │
|
||||
│ Copyright © 2004-2021 Lua.org, PUC-Rio. │
|
||||
│ │
|
||||
│ Permission is hereby granted, free of charge, to any person obtaining │
|
||||
│ a copy of this software and associated documentation files (the │
|
||||
│ "Software"), to deal in the Software without restriction, including │
|
||||
│ without limitation the rights to use, copy, modify, merge, publish, │
|
||||
│ distribute, sublicense, and/or sell copies of the Software, and to │
|
||||
│ permit persons to whom the Software is furnished to do so, subject to │
|
||||
│ the following conditions: │
|
||||
│ │
|
||||
│ The above copyright notice and this permission notice shall be │
|
||||
│ included in all copies or substantial portions of the Software. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │
|
||||
│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │
|
||||
│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │
|
||||
│ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY │
|
||||
│ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, │
|
||||
│ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │
|
||||
│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#define lapi_c
|
||||
#define LUA_CORE
|
||||
|
||||
#include "third_party/lua/lapi.h"
|
||||
#include "third_party/lua/ldebug.h"
|
||||
#include "third_party/lua/ldo.h"
|
||||
|
@ -22,8 +42,13 @@
|
|||
#include "third_party/lua/lua.h"
|
||||
#include "third_party/lua/lundump.h"
|
||||
#include "third_party/lua/lvm.h"
|
||||
// clang-format off
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Lua 5.4.3 (MIT License)\\n\
|
||||
Copyright 1994–2021 Lua.org, PUC-Rio.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
|
||||
/* clang-format off */
|
||||
|
||||
const char lua_ident[] =
|
||||
"$LuaVersion: " LUA_COPYRIGHT " $"
|
||||
|
|
6
third_party/lua/lapi.h
vendored
6
third_party/lua/lapi.h
vendored
|
@ -1,9 +1,3 @@
|
|||
/*
|
||||
** $Id: lapi.h $
|
||||
** Auxiliary functions from Lua API
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
#ifndef lapi_h
|
||||
#define lapi_h
|
||||
|
||||
|
|
40
third_party/lua/lauxlib.c
vendored
40
third_party/lua/lauxlib.c
vendored
|
@ -1,19 +1,43 @@
|
|||
/*
|
||||
** $Id: lauxlib.c $
|
||||
** Auxiliary functions for building Lua libraries
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╚──────────────────────────────────────────────────────────────────────────────╝
|
||||
│ │
|
||||
│ Lua │
|
||||
│ Copyright © 2004-2021 Lua.org, PUC-Rio. │
|
||||
│ │
|
||||
│ Permission is hereby granted, free of charge, to any person obtaining │
|
||||
│ a copy of this software and associated documentation files (the │
|
||||
│ "Software"), to deal in the Software without restriction, including │
|
||||
│ without limitation the rights to use, copy, modify, merge, publish, │
|
||||
│ distribute, sublicense, and/or sell copies of the Software, and to │
|
||||
│ permit persons to whom the Software is furnished to do so, subject to │
|
||||
│ the following conditions: │
|
||||
│ │
|
||||
│ The above copyright notice and this permission notice shall be │
|
||||
│ included in all copies or substantial portions of the Software. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │
|
||||
│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │
|
||||
│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │
|
||||
│ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY │
|
||||
│ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, │
|
||||
│ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │
|
||||
│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#define lauxlib_c
|
||||
#define LUA_LIB
|
||||
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/errno.h"
|
||||
#include "third_party/lua/lauxlib.h"
|
||||
#include "third_party/lua/lprefix.h"
|
||||
#include "third_party/lua/lua.h"
|
||||
// clang-format off
|
||||
|
||||
/* clang-format off */
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Lua 5.4.3 (MIT License)\\n\
|
||||
Copyright 1994–2021 Lua.org, PUC-Rio.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
|
||||
|
||||
/**
|
||||
|
|
40
third_party/lua/lbaselib.c
vendored
40
third_party/lua/lbaselib.c
vendored
|
@ -1,19 +1,43 @@
|
|||
/*
|
||||
** $Id: lbaselib.c $
|
||||
** Basic library
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╚──────────────────────────────────────────────────────────────────────────────╝
|
||||
│ │
|
||||
│ Lua │
|
||||
│ Copyright © 2004-2021 Lua.org, PUC-Rio. │
|
||||
│ │
|
||||
│ Permission is hereby granted, free of charge, to any person obtaining │
|
||||
│ a copy of this software and associated documentation files (the │
|
||||
│ "Software"), to deal in the Software without restriction, including │
|
||||
│ without limitation the rights to use, copy, modify, merge, publish, │
|
||||
│ distribute, sublicense, and/or sell copies of the Software, and to │
|
||||
│ permit persons to whom the Software is furnished to do so, subject to │
|
||||
│ the following conditions: │
|
||||
│ │
|
||||
│ The above copyright notice and this permission notice shall be │
|
||||
│ included in all copies or substantial portions of the Software. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │
|
||||
│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │
|
||||
│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │
|
||||
│ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY │
|
||||
│ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, │
|
||||
│ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │
|
||||
│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#define lbaselib_c
|
||||
#define LUA_LIB
|
||||
|
||||
#include "third_party/lua/lauxlib.h"
|
||||
#include "third_party/lua/lprefix.h"
|
||||
#include "third_party/lua/lua.h"
|
||||
#include "third_party/lua/lualib.h"
|
||||
|
||||
/* clang-format off */
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Lua 5.4.3 (MIT License)\\n\
|
||||
Copyright 1994–2021 Lua.org, PUC-Rio.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
|
||||
|
||||
static int luaB_print (lua_State *L) {
|
||||
int n = lua_gettop(L); /* number of arguments */
|
||||
|
|
41
third_party/lua/lcode.c
vendored
41
third_party/lua/lcode.c
vendored
|
@ -1,12 +1,32 @@
|
|||
/*
|
||||
** $Id: lcode.c $
|
||||
** Code generator for Lua
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╚──────────────────────────────────────────────────────────────────────────────╝
|
||||
│ │
|
||||
│ Lua │
|
||||
│ Copyright © 2004-2021 Lua.org, PUC-Rio. │
|
||||
│ │
|
||||
│ Permission is hereby granted, free of charge, to any person obtaining │
|
||||
│ a copy of this software and associated documentation files (the │
|
||||
│ "Software"), to deal in the Software without restriction, including │
|
||||
│ without limitation the rights to use, copy, modify, merge, publish, │
|
||||
│ distribute, sublicense, and/or sell copies of the Software, and to │
|
||||
│ permit persons to whom the Software is furnished to do so, subject to │
|
||||
│ the following conditions: │
|
||||
│ │
|
||||
│ The above copyright notice and this permission notice shall be │
|
||||
│ included in all copies or substantial portions of the Software. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │
|
||||
│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │
|
||||
│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │
|
||||
│ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY │
|
||||
│ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, │
|
||||
│ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │
|
||||
│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#define lcode_c
|
||||
#define LUA_CORE
|
||||
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "third_party/lua/lcode.h"
|
||||
#include "third_party/lua/ldebug.h"
|
||||
|
@ -22,8 +42,13 @@
|
|||
#include "third_party/lua/ltable.h"
|
||||
#include "third_party/lua/lua.h"
|
||||
#include "third_party/lua/lvm.h"
|
||||
// clang-format off
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Lua 5.4.3 (MIT License)\\n\
|
||||
Copyright 1994–2021 Lua.org, PUC-Rio.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
|
||||
/* clang-format off */
|
||||
|
||||
/* Maximum number of registers in a Lua function (must fit in 8 bits) */
|
||||
#define MAXREGS 255
|
||||
|
|
6
third_party/lua/lcode.h
vendored
6
third_party/lua/lcode.h
vendored
|
@ -1,9 +1,3 @@
|
|||
/*
|
||||
** $Id: lcode.h $
|
||||
** Code generator for Lua
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
#ifndef lcode_h
|
||||
#define lcode_h
|
||||
|
||||
|
|
41
third_party/lua/lcorolib.c
vendored
41
third_party/lua/lcorolib.c
vendored
|
@ -1,18 +1,43 @@
|
|||
/*
|
||||
** $Id: lcorolib.c $
|
||||
** Coroutine Library
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╚──────────────────────────────────────────────────────────────────────────────╝
|
||||
│ │
|
||||
│ Lua │
|
||||
│ Copyright © 2004-2021 Lua.org, PUC-Rio. │
|
||||
│ │
|
||||
│ Permission is hereby granted, free of charge, to any person obtaining │
|
||||
│ a copy of this software and associated documentation files (the │
|
||||
│ "Software"), to deal in the Software without restriction, including │
|
||||
│ without limitation the rights to use, copy, modify, merge, publish, │
|
||||
│ distribute, sublicense, and/or sell copies of the Software, and to │
|
||||
│ permit persons to whom the Software is furnished to do so, subject to │
|
||||
│ the following conditions: │
|
||||
│ │
|
||||
│ The above copyright notice and this permission notice shall be │
|
||||
│ included in all copies or substantial portions of the Software. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │
|
||||
│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │
|
||||
│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │
|
||||
│ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY │
|
||||
│ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, │
|
||||
│ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │
|
||||
│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#define lcorolib_c
|
||||
#define LUA_LIB
|
||||
|
||||
#include "third_party/lua/lauxlib.h"
|
||||
#include "third_party/lua/lprefix.h"
|
||||
#include "third_party/lua/lua.h"
|
||||
#include "third_party/lua/lualib.h"
|
||||
// clang-format off
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Lua 5.4.3 (MIT License)\\n\
|
||||
Copyright 1994–2021 Lua.org, PUC-Rio.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
|
||||
/* clang-format off */
|
||||
|
||||
static lua_State *getco (lua_State *L) {
|
||||
lua_State *co = lua_tothread(L, 1);
|
||||
|
|
63
third_party/lua/lctype.c
vendored
63
third_party/lua/lctype.c
vendored
|
@ -1,63 +0,0 @@
|
|||
/*
|
||||
** $Id: lctype.c $
|
||||
** 'ctype' functions for Lua
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
#define lctype_c
|
||||
#define LUA_CORE
|
||||
|
||||
#include "third_party/lua/lctype.h"
|
||||
#include "third_party/lua/lprefix.h"
|
||||
|
||||
/* clang-format off */
|
||||
|
||||
#if !LUA_USE_CTYPE /* { */
|
||||
|
||||
|
||||
|
||||
#if defined (LUA_UCID) /* accept UniCode IDentifiers? */
|
||||
/* consider all non-ascii codepoints to be alphabetic */
|
||||
#define NONA 0x01
|
||||
#else
|
||||
#define NONA 0x00 /* default */
|
||||
#endif
|
||||
|
||||
|
||||
LUAI_DDEF const lu_byte luai_ctype_[UCHAR_MAX + 2] = {
|
||||
0x00, /* EOZ */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0. */
|
||||
0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1. */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x0c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, /* 2. */
|
||||
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
|
||||
0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, /* 3. */
|
||||
0x16, 0x16, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
|
||||
0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 4. */
|
||||
0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
|
||||
0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 5. */
|
||||
0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x05,
|
||||
0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 6. */
|
||||
0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
|
||||
0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 7. */
|
||||
0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x00,
|
||||
NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, /* 8. */
|
||||
NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA,
|
||||
NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, /* 9. */
|
||||
NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA,
|
||||
NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, /* a. */
|
||||
NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA,
|
||||
NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, /* b. */
|
||||
NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA,
|
||||
0x00, 0x00, NONA, NONA, NONA, NONA, NONA, NONA, /* c. */
|
||||
NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA,
|
||||
NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, /* d. */
|
||||
NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA,
|
||||
NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, /* e. */
|
||||
NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA,
|
||||
NONA, NONA, NONA, NONA, NONA, 0x00, 0x00, 0x00, /* f. */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
#endif /* } */
|
116
third_party/lua/lctype.h
vendored
116
third_party/lua/lctype.h
vendored
|
@ -1,100 +1,54 @@
|
|||
/*
|
||||
** $Id: lctype.h $
|
||||
** 'ctype' functions for Lua
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
#ifndef lctype_h
|
||||
#define lctype_h
|
||||
|
||||
#include "third_party/lua/lua.h"
|
||||
|
||||
/* clang-format off */
|
||||
|
||||
/*
|
||||
** WARNING: the functions defined here do not necessarily correspond
|
||||
** to the similar functions in the standard C ctype.h. They are
|
||||
** optimized for the specific needs of Lua.
|
||||
*/
|
||||
|
||||
#if !defined(LUA_USE_CTYPE)
|
||||
|
||||
#if 'A' == 65 && '0' == 48
|
||||
/* ASCII case: can use its own tables; faster and fixed */
|
||||
#define LUA_USE_CTYPE 0
|
||||
#else
|
||||
/* must use standard C ctype */
|
||||
#define LUA_USE_CTYPE 1
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if !LUA_USE_CTYPE /* { */
|
||||
|
||||
|
||||
#include "third_party/lua/llimits.h"
|
||||
|
||||
|
||||
#define ALPHABIT 0
|
||||
#define DIGITBIT 1
|
||||
#define PRINTBIT 2
|
||||
#define SPACEBIT 3
|
||||
#define XDIGITBIT 4
|
||||
|
||||
|
||||
#define MASK(B) (1 << (B))
|
||||
|
||||
|
||||
/*
|
||||
** add 1 to char to allow index -1 (EOZ)
|
||||
*/
|
||||
#define testprop(c,p) (luai_ctype_[(c)+1] & (p))
|
||||
|
||||
/*
|
||||
** 'lalpha' (Lua alphabetic) and 'lalnum' (Lua alphanumeric) both include '_'
|
||||
*/
|
||||
#define lislalpha(c) testprop(c, MASK(ALPHABIT))
|
||||
#define lislalnum(c) testprop(c, (MASK(ALPHABIT) | MASK(DIGITBIT)))
|
||||
#define lisdigit(c) testprop(c, MASK(DIGITBIT))
|
||||
#define lisspace(c) testprop(c, MASK(SPACEBIT))
|
||||
#define lisprint(c) testprop(c, MASK(PRINTBIT))
|
||||
#define lisxdigit(c) testprop(c, MASK(XDIGITBIT))
|
||||
|
||||
|
||||
/*
|
||||
** In ASCII, this 'ltolower' is correct for alphabetic characters and
|
||||
** for '.'. That is enough for Lua needs. ('check_exp' ensures that
|
||||
** the character either is an upper-case letter or is unchanged by
|
||||
** the transformation, which holds for lower-case letters and '.'.)
|
||||
*/
|
||||
#define ltolower(c) \
|
||||
check_exp(('A' <= (c) && (c) <= 'Z') || (c) == ((c) | ('A' ^ 'a')), \
|
||||
#define ltolower(c) \
|
||||
check_exp(('A' <= (c) && (c) <= 'Z') || (c) == ((c) | ('A' ^ 'a')), \
|
||||
(c) | ('A' ^ 'a'))
|
||||
|
||||
#define lisdigit(C) \
|
||||
({ \
|
||||
unsigned char c_ = (C); \
|
||||
'0' <= c_&& c_ <= '9'; \
|
||||
})
|
||||
|
||||
/* one entry for each character and for -1 (EOZ) */
|
||||
LUAI_DDEC(const lu_byte luai_ctype_[UCHAR_MAX + 2];)
|
||||
#define lislalpha(C) \
|
||||
({ \
|
||||
unsigned char c_ = (C); \
|
||||
('A' <= c_ && c_ <= 'Z') || ('a' <= c_ && c_ <= 'z') || c_ == '_'; \
|
||||
})
|
||||
|
||||
#define lislalnum(C) \
|
||||
({ \
|
||||
unsigned char c_ = (C); \
|
||||
(('0' <= c_ && c_ <= '9') || ('A' <= c_ && c_ <= 'Z') || \
|
||||
('a' <= c_ && c_ <= 'z') || c_ == '_'); \
|
||||
})
|
||||
|
||||
#else /* }{ */
|
||||
#define lisspace(C) \
|
||||
({ \
|
||||
unsigned char c_ = (C); \
|
||||
(c_ == ' ' || c_ == '\t' || c_ == '\r' || c_ == '\n' || c_ == '\f' || \
|
||||
c_ == '\v'); \
|
||||
})
|
||||
|
||||
/*
|
||||
** use standard C ctypes
|
||||
*/
|
||||
#define lisxdigit(C) \
|
||||
({ \
|
||||
unsigned char c_ = (C); \
|
||||
(('0' <= c_ && c_ <= '9') || ('A' <= c_ && c_ <= 'F') || \
|
||||
('a' <= c_ && c_ <= 'f')); \
|
||||
})
|
||||
|
||||
|
||||
|
||||
#define lislalpha(c) (isalpha(c) || (c) == '_')
|
||||
#define lislalnum(c) (isalnum(c) || (c) == '_')
|
||||
#define lisdigit(c) (isdigit(c))
|
||||
#define lisspace(c) (isspace(c))
|
||||
#define lisprint(c) (isprint(c))
|
||||
#define lisxdigit(c) (isxdigit(c))
|
||||
|
||||
#define ltolower(c) (tolower(c))
|
||||
|
||||
#endif /* } */
|
||||
#define lisprint(C) \
|
||||
({ \
|
||||
unsigned char c_ = (C); \
|
||||
32 <= c_&& c_ <= 126; \
|
||||
})
|
||||
|
||||
#endif
|
||||
|
||||
|
|
49
third_party/lua/ldblib.c
vendored
49
third_party/lua/ldblib.c
vendored
|
@ -1,20 +1,42 @@
|
|||
/*
|
||||
** $Id: ldblib.c $
|
||||
** Interface from Lua to its debug API
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╚──────────────────────────────────────────────────────────────────────────────╝
|
||||
│ │
|
||||
│ Lua │
|
||||
│ Copyright © 2004-2021 Lua.org, PUC-Rio. │
|
||||
│ │
|
||||
│ Permission is hereby granted, free of charge, to any person obtaining │
|
||||
│ a copy of this software and associated documentation files (the │
|
||||
│ "Software"), to deal in the Software without restriction, including │
|
||||
│ without limitation the rights to use, copy, modify, merge, publish, │
|
||||
│ distribute, sublicense, and/or sell copies of the Software, and to │
|
||||
│ permit persons to whom the Software is furnished to do so, subject to │
|
||||
│ the following conditions: │
|
||||
│ │
|
||||
│ The above copyright notice and this permission notice shall be │
|
||||
│ included in all copies or substantial portions of the Software. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │
|
||||
│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │
|
||||
│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │
|
||||
│ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY │
|
||||
│ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, │
|
||||
│ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │
|
||||
│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#define ldblib_c
|
||||
#define LUA_LIB
|
||||
|
||||
#include "third_party/lua/lprefix.h"
|
||||
|
||||
|
||||
|
||||
#include "third_party/lua/lua.h"
|
||||
|
||||
#include "third_party/lua/lauxlib.h"
|
||||
#include "third_party/lua/lprefix.h"
|
||||
#include "third_party/lua/lua.h"
|
||||
#include "third_party/lua/lualib.h"
|
||||
// clang-format off
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Lua 5.4.3 (MIT License)\\n\
|
||||
Copyright 1994–2021 Lua.org, PUC-Rio.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
|
||||
|
||||
/*
|
||||
|
@ -477,4 +499,3 @@ LUAMOD_API int luaopen_debug (lua_State *L) {
|
|||
luaL_newlib(L, dblib);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
47
third_party/lua/ldebug.c
vendored
47
third_party/lua/ldebug.c
vendored
|
@ -1,18 +1,32 @@
|
|||
/*
|
||||
** $Id: ldebug.c $
|
||||
** Debug Interface
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╚──────────────────────────────────────────────────────────────────────────────╝
|
||||
│ │
|
||||
│ Lua │
|
||||
│ Copyright © 2004-2021 Lua.org, PUC-Rio. │
|
||||
│ │
|
||||
│ Permission is hereby granted, free of charge, to any person obtaining │
|
||||
│ a copy of this software and associated documentation files (the │
|
||||
│ "Software"), to deal in the Software without restriction, including │
|
||||
│ without limitation the rights to use, copy, modify, merge, publish, │
|
||||
│ distribute, sublicense, and/or sell copies of the Software, and to │
|
||||
│ permit persons to whom the Software is furnished to do so, subject to │
|
||||
│ the following conditions: │
|
||||
│ │
|
||||
│ The above copyright notice and this permission notice shall be │
|
||||
│ included in all copies or substantial portions of the Software. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │
|
||||
│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │
|
||||
│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │
|
||||
│ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY │
|
||||
│ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, │
|
||||
│ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │
|
||||
│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#define ldebug_c
|
||||
#define LUA_CORE
|
||||
|
||||
#include "third_party/lua/lprefix.h"
|
||||
|
||||
|
||||
|
||||
#include "third_party/lua/lua.h"
|
||||
|
||||
#include "third_party/lua/lapi.h"
|
||||
#include "third_party/lua/lcode.h"
|
||||
#include "third_party/lua/ldebug.h"
|
||||
|
@ -20,12 +34,19 @@
|
|||
#include "third_party/lua/lfunc.h"
|
||||
#include "third_party/lua/lobject.h"
|
||||
#include "third_party/lua/lopcodes.h"
|
||||
#include "third_party/lua/lprefix.h"
|
||||
#include "third_party/lua/lstate.h"
|
||||
#include "third_party/lua/lstring.h"
|
||||
#include "third_party/lua/ltable.h"
|
||||
#include "third_party/lua/ltm.h"
|
||||
#include "third_party/lua/lua.h"
|
||||
#include "third_party/lua/lvm.h"
|
||||
// clang-format off
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Lua 5.4.3 (MIT License)\\n\
|
||||
Copyright 1994–2021 Lua.org, PUC-Rio.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
|
||||
|
||||
#define noLuaClosure(f) ((f) == NULL || (f)->c.tt == LUA_VCCL)
|
||||
|
|
6
third_party/lua/ldebug.h
vendored
6
third_party/lua/ldebug.h
vendored
|
@ -1,9 +1,3 @@
|
|||
/*
|
||||
** $Id: ldebug.h $
|
||||
** Auxiliary functions from Debug Interface module
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
#ifndef ldebug_h
|
||||
#define ldebug_h
|
||||
|
||||
|
|
40
third_party/lua/ldo.c
vendored
40
third_party/lua/ldo.c
vendored
|
@ -1,12 +1,32 @@
|
|||
/*
|
||||
** $Id: ldo.c $
|
||||
** Stack and Call structure of Lua
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╚──────────────────────────────────────────────────────────────────────────────╝
|
||||
│ │
|
||||
│ Lua │
|
||||
│ Copyright © 2004-2021 Lua.org, PUC-Rio. │
|
||||
│ │
|
||||
│ Permission is hereby granted, free of charge, to any person obtaining │
|
||||
│ a copy of this software and associated documentation files (the │
|
||||
│ "Software"), to deal in the Software without restriction, including │
|
||||
│ without limitation the rights to use, copy, modify, merge, publish, │
|
||||
│ distribute, sublicense, and/or sell copies of the Software, and to │
|
||||
│ permit persons to whom the Software is furnished to do so, subject to │
|
||||
│ the following conditions: │
|
||||
│ │
|
||||
│ The above copyright notice and this permission notice shall be │
|
||||
│ included in all copies or substantial portions of the Software. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │
|
||||
│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │
|
||||
│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │
|
||||
│ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY │
|
||||
│ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, │
|
||||
│ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │
|
||||
│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#define ldo_c
|
||||
#define LUA_CORE
|
||||
|
||||
#include "libc/runtime/gc.h"
|
||||
#include "third_party/lua/lapi.h"
|
||||
#include "third_party/lua/ldebug.h"
|
||||
|
@ -26,8 +46,12 @@
|
|||
#include "third_party/lua/lundump.h"
|
||||
#include "third_party/lua/lvm.h"
|
||||
#include "third_party/lua/lzio.h"
|
||||
// clang-format off
|
||||
|
||||
/* clang-format off */
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Lua 5.4.3 (MIT License)\\n\
|
||||
Copyright 1994–2021 Lua.org, PUC-Rio.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
|
||||
|
||||
#define errorstatus(s) ((s) > LUA_YIELD)
|
||||
|
|
6
third_party/lua/ldo.h
vendored
6
third_party/lua/ldo.h
vendored
|
@ -1,9 +1,3 @@
|
|||
/*
|
||||
** $Id: ldo.h $
|
||||
** Stack and Call structure of Lua
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
#ifndef ldo_h
|
||||
#define ldo_h
|
||||
|
||||
|
|
41
third_party/lua/ldump.c
vendored
41
third_party/lua/ldump.c
vendored
|
@ -1,19 +1,44 @@
|
|||
/*
|
||||
** $Id: ldump.c $
|
||||
** save precompiled Lua chunks
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╚──────────────────────────────────────────────────────────────────────────────╝
|
||||
│ │
|
||||
│ Lua │
|
||||
│ Copyright © 2004-2021 Lua.org, PUC-Rio. │
|
||||
│ │
|
||||
│ Permission is hereby granted, free of charge, to any person obtaining │
|
||||
│ a copy of this software and associated documentation files (the │
|
||||
│ "Software"), to deal in the Software without restriction, including │
|
||||
│ without limitation the rights to use, copy, modify, merge, publish, │
|
||||
│ distribute, sublicense, and/or sell copies of the Software, and to │
|
||||
│ permit persons to whom the Software is furnished to do so, subject to │
|
||||
│ the following conditions: │
|
||||
│ │
|
||||
│ The above copyright notice and this permission notice shall be │
|
||||
│ included in all copies or substantial portions of the Software. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │
|
||||
│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │
|
||||
│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │
|
||||
│ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY │
|
||||
│ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, │
|
||||
│ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │
|
||||
│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#define ldump_c
|
||||
#define LUA_CORE
|
||||
|
||||
#include "third_party/lua/lobject.h"
|
||||
#include "third_party/lua/lprefix.h"
|
||||
#include "third_party/lua/lstate.h"
|
||||
#include "third_party/lua/lua.h"
|
||||
#include "third_party/lua/lundump.h"
|
||||
// clang-format off
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Lua 5.4.3 (MIT License)\\n\
|
||||
Copyright 1994–2021 Lua.org, PUC-Rio.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
|
||||
/* clang-format off */
|
||||
|
||||
typedef struct {
|
||||
lua_State *L;
|
||||
|
|
41
third_party/lua/lfunc.c
vendored
41
third_party/lua/lfunc.c
vendored
|
@ -1,12 +1,32 @@
|
|||
/*
|
||||
** $Id: lfunc.c $
|
||||
** Auxiliary functions to manipulate prototypes and closures
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╚──────────────────────────────────────────────────────────────────────────────╝
|
||||
│ │
|
||||
│ Lua │
|
||||
│ Copyright © 2004-2021 Lua.org, PUC-Rio. │
|
||||
│ │
|
||||
│ Permission is hereby granted, free of charge, to any person obtaining │
|
||||
│ a copy of this software and associated documentation files (the │
|
||||
│ "Software"), to deal in the Software without restriction, including │
|
||||
│ without limitation the rights to use, copy, modify, merge, publish, │
|
||||
│ distribute, sublicense, and/or sell copies of the Software, and to │
|
||||
│ permit persons to whom the Software is furnished to do so, subject to │
|
||||
│ the following conditions: │
|
||||
│ │
|
||||
│ The above copyright notice and this permission notice shall be │
|
||||
│ included in all copies or substantial portions of the Software. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │
|
||||
│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │
|
||||
│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │
|
||||
│ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY │
|
||||
│ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, │
|
||||
│ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │
|
||||
│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#define lfunc_c
|
||||
#define LUA_CORE
|
||||
|
||||
#include "third_party/lua/ldebug.h"
|
||||
#include "third_party/lua/ldo.h"
|
||||
#include "third_party/lua/lfunc.h"
|
||||
|
@ -17,8 +37,13 @@
|
|||
#include "third_party/lua/lstate.h"
|
||||
#include "third_party/lua/ltm.h"
|
||||
#include "third_party/lua/lua.h"
|
||||
// clang-format off
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Lua 5.4.3 (MIT License)\\n\
|
||||
Copyright 1994–2021 Lua.org, PUC-Rio.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
|
||||
/* clang-format off */
|
||||
|
||||
CClosure *luaF_newCclosure (lua_State *L, int nupvals) {
|
||||
GCObject *o = luaC_newobj(L, LUA_VCCL, sizeCclosure(nupvals));
|
||||
|
|
6
third_party/lua/lfunc.h
vendored
6
third_party/lua/lfunc.h
vendored
|
@ -1,9 +1,3 @@
|
|||
/*
|
||||
** $Id: lfunc.h $
|
||||
** Auxiliary functions to manipulate prototypes and closures
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
#ifndef lfunc_h
|
||||
#define lfunc_h
|
||||
|
||||
|
|
41
third_party/lua/lgc.c
vendored
41
third_party/lua/lgc.c
vendored
|
@ -1,12 +1,32 @@
|
|||
/*
|
||||
** $Id: lgc.c $
|
||||
** Garbage Collector
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╚──────────────────────────────────────────────────────────────────────────────╝
|
||||
│ │
|
||||
│ Lua │
|
||||
│ Copyright © 2004-2021 Lua.org, PUC-Rio. │
|
||||
│ │
|
||||
│ Permission is hereby granted, free of charge, to any person obtaining │
|
||||
│ a copy of this software and associated documentation files (the │
|
||||
│ "Software"), to deal in the Software without restriction, including │
|
||||
│ without limitation the rights to use, copy, modify, merge, publish, │
|
||||
│ distribute, sublicense, and/or sell copies of the Software, and to │
|
||||
│ permit persons to whom the Software is furnished to do so, subject to │
|
||||
│ the following conditions: │
|
||||
│ │
|
||||
│ The above copyright notice and this permission notice shall be │
|
||||
│ included in all copies or substantial portions of the Software. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │
|
||||
│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │
|
||||
│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │
|
||||
│ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY │
|
||||
│ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, │
|
||||
│ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │
|
||||
│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#define lgc_c
|
||||
#define LUA_CORE
|
||||
|
||||
#include "third_party/lua/ldebug.h"
|
||||
#include "third_party/lua/ldo.h"
|
||||
#include "third_party/lua/lfunc.h"
|
||||
|
@ -19,8 +39,13 @@
|
|||
#include "third_party/lua/ltable.h"
|
||||
#include "third_party/lua/ltm.h"
|
||||
#include "third_party/lua/lua.h"
|
||||
// clang-format off
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Lua 5.4.3 (MIT License)\\n\
|
||||
Copyright 1994–2021 Lua.org, PUC-Rio.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
|
||||
/* clang-format off */
|
||||
|
||||
/*
|
||||
** Maximum number of elements to sweep in each single step.
|
||||
|
|
6
third_party/lua/lgc.h
vendored
6
third_party/lua/lgc.h
vendored
|
@ -1,9 +1,3 @@
|
|||
/*
|
||||
** $Id: lgc.h $
|
||||
** Garbage Collector
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
#ifndef lgc_h
|
||||
#define lgc_h
|
||||
|
||||
|
|
42
third_party/lua/linit.c
vendored
42
third_party/lua/linit.c
vendored
|
@ -1,12 +1,32 @@
|
|||
/*
|
||||
** $Id: linit.c $
|
||||
** Initialization of libraries for lua.c and other clients
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╚──────────────────────────────────────────────────────────────────────────────╝
|
||||
│ │
|
||||
│ Lua │
|
||||
│ Copyright © 2004-2021 Lua.org, PUC-Rio. │
|
||||
│ │
|
||||
│ Permission is hereby granted, free of charge, to any person obtaining │
|
||||
│ a copy of this software and associated documentation files (the │
|
||||
│ "Software"), to deal in the Software without restriction, including │
|
||||
│ without limitation the rights to use, copy, modify, merge, publish, │
|
||||
│ distribute, sublicense, and/or sell copies of the Software, and to │
|
||||
│ permit persons to whom the Software is furnished to do so, subject to │
|
||||
│ the following conditions: │
|
||||
│ │
|
||||
│ The above copyright notice and this permission notice shall be │
|
||||
│ included in all copies or substantial portions of the Software. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │
|
||||
│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │
|
||||
│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │
|
||||
│ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY │
|
||||
│ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, │
|
||||
│ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │
|
||||
│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#define linit_c
|
||||
#define LUA_LIB
|
||||
|
||||
/*
|
||||
** If you embed Lua in your program and need to open the standard
|
||||
** libraries, call luaL_openlibs in your program. If you need a
|
||||
|
@ -22,13 +42,17 @@
|
|||
** lua_setfield(L, -2, modname);
|
||||
** lua_pop(L, 1); // remove PRELOAD table
|
||||
*/
|
||||
|
||||
#include "third_party/lua/lauxlib.h"
|
||||
#include "third_party/lua/lprefix.h"
|
||||
#include "third_party/lua/lua.h"
|
||||
#include "third_party/lua/lualib.h"
|
||||
// clang-format off
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Lua 5.4.3 (MIT License)\\n\
|
||||
Copyright 1994–2021 Lua.org, PUC-Rio.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
|
||||
/* clang-format off */
|
||||
|
||||
/*
|
||||
** these libs are loaded by lua.c and are readily available to any Lua
|
||||
|
|
41
third_party/lua/liolib.c
vendored
41
third_party/lua/liolib.c
vendored
|
@ -1,12 +1,32 @@
|
|||
/*
|
||||
** $Id: liolib.c $
|
||||
** Standard I/O (and system) library
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╚──────────────────────────────────────────────────────────────────────────────╝
|
||||
│ │
|
||||
│ Lua │
|
||||
│ Copyright © 2004-2021 Lua.org, PUC-Rio. │
|
||||
│ │
|
||||
│ Permission is hereby granted, free of charge, to any person obtaining │
|
||||
│ a copy of this software and associated documentation files (the │
|
||||
│ "Software"), to deal in the Software without restriction, including │
|
||||
│ without limitation the rights to use, copy, modify, merge, publish, │
|
||||
│ distribute, sublicense, and/or sell copies of the Software, and to │
|
||||
│ permit persons to whom the Software is furnished to do so, subject to │
|
||||
│ the following conditions: │
|
||||
│ │
|
||||
│ The above copyright notice and this permission notice shall be │
|
||||
│ included in all copies or substantial portions of the Software. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │
|
||||
│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │
|
||||
│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │
|
||||
│ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY │
|
||||
│ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, │
|
||||
│ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │
|
||||
│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#define liolib_c
|
||||
#define LUA_LIB
|
||||
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/errno.h"
|
||||
|
@ -16,8 +36,13 @@
|
|||
#include "third_party/lua/lprefix.h"
|
||||
#include "third_party/lua/lua.h"
|
||||
#include "third_party/lua/lualib.h"
|
||||
// clang-format off
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Lua 5.4.3 (MIT License)\\n\
|
||||
Copyright 1994–2021 Lua.org, PUC-Rio.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
|
||||
/* clang-format off */
|
||||
|
||||
/*
|
||||
** Change this macro to accept other modes for 'fopen' besides
|
||||
|
|
40
third_party/lua/llex.c
vendored
40
third_party/lua/llex.c
vendored
|
@ -1,12 +1,32 @@
|
|||
/*
|
||||
** $Id: llex.c $
|
||||
** Lexical Analyzer
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╚──────────────────────────────────────────────────────────────────────────────╝
|
||||
│ │
|
||||
│ Lua │
|
||||
│ Copyright © 2004-2021 Lua.org, PUC-Rio. │
|
||||
│ │
|
||||
│ Permission is hereby granted, free of charge, to any person obtaining │
|
||||
│ a copy of this software and associated documentation files (the │
|
||||
│ "Software"), to deal in the Software without restriction, including │
|
||||
│ without limitation the rights to use, copy, modify, merge, publish, │
|
||||
│ distribute, sublicense, and/or sell copies of the Software, and to │
|
||||
│ permit persons to whom the Software is furnished to do so, subject to │
|
||||
│ the following conditions: │
|
||||
│ │
|
||||
│ The above copyright notice and this permission notice shall be │
|
||||
│ included in all copies or substantial portions of the Software. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │
|
||||
│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │
|
||||
│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │
|
||||
│ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY │
|
||||
│ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, │
|
||||
│ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │
|
||||
│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#define llex_c
|
||||
#define LUA_CORE
|
||||
|
||||
#include "third_party/lua/lctype.h"
|
||||
#include "third_party/lua/ldebug.h"
|
||||
#include "third_party/lua/ldo.h"
|
||||
|
@ -20,8 +40,12 @@
|
|||
#include "third_party/lua/ltable.h"
|
||||
#include "third_party/lua/lua.h"
|
||||
#include "third_party/lua/lzio.h"
|
||||
// clang-format off
|
||||
|
||||
/* clang-format off */
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Lua 5.4.3 (MIT License)\\n\
|
||||
Copyright 1994–2021 Lua.org, PUC-Rio.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
|
||||
|
||||
#define next(ls) (ls->current = zgetc(ls->z))
|
||||
|
|
6
third_party/lua/llimits.h
vendored
6
third_party/lua/llimits.h
vendored
|
@ -1,9 +1,3 @@
|
|||
/*
|
||||
** $Id: llimits.h $
|
||||
** Limits, basic types, and some other 'installation-dependent' definitions
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
#ifndef llimits_h
|
||||
#define llimits_h
|
||||
|
||||
|
|
41
third_party/lua/lmathlib.c
vendored
41
third_party/lua/lmathlib.c
vendored
|
@ -1,12 +1,32 @@
|
|||
/*
|
||||
** $Id: lmathlib.c $
|
||||
** Standard mathematical library
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╚──────────────────────────────────────────────────────────────────────────────╝
|
||||
│ │
|
||||
│ Lua │
|
||||
│ Copyright © 2004-2021 Lua.org, PUC-Rio. │
|
||||
│ │
|
||||
│ Permission is hereby granted, free of charge, to any person obtaining │
|
||||
│ a copy of this software and associated documentation files (the │
|
||||
│ "Software"), to deal in the Software without restriction, including │
|
||||
│ without limitation the rights to use, copy, modify, merge, publish, │
|
||||
│ distribute, sublicense, and/or sell copies of the Software, and to │
|
||||
│ permit persons to whom the Software is furnished to do so, subject to │
|
||||
│ the following conditions: │
|
||||
│ │
|
||||
│ The above copyright notice and this permission notice shall be │
|
||||
│ included in all copies or substantial portions of the Software. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │
|
||||
│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │
|
||||
│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │
|
||||
│ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY │
|
||||
│ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, │
|
||||
│ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │
|
||||
│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#define lmathlib_c
|
||||
#define LUA_LIB
|
||||
|
||||
#include "libc/math.h"
|
||||
#include "libc/nt/struct/msg.h"
|
||||
#include "libc/time/time.h"
|
||||
|
@ -14,8 +34,13 @@
|
|||
#include "third_party/lua/lprefix.h"
|
||||
#include "third_party/lua/lua.h"
|
||||
#include "third_party/lua/lualib.h"
|
||||
// clang-format off
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Lua 5.4.3 (MIT License)\\n\
|
||||
Copyright 1994–2021 Lua.org, PUC-Rio.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
|
||||
/* clang-format off */
|
||||
|
||||
#undef PI
|
||||
#define PI (l_mathop(3.141592653589793238462643383279502884))
|
||||
|
|
41
third_party/lua/lmem.c
vendored
41
third_party/lua/lmem.c
vendored
|
@ -1,12 +1,32 @@
|
|||
/*
|
||||
** $Id: lmem.c $
|
||||
** Interface to Memory Manager
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╚──────────────────────────────────────────────────────────────────────────────╝
|
||||
│ │
|
||||
│ Lua │
|
||||
│ Copyright © 2004-2021 Lua.org, PUC-Rio. │
|
||||
│ │
|
||||
│ Permission is hereby granted, free of charge, to any person obtaining │
|
||||
│ a copy of this software and associated documentation files (the │
|
||||
│ "Software"), to deal in the Software without restriction, including │
|
||||
│ without limitation the rights to use, copy, modify, merge, publish, │
|
||||
│ distribute, sublicense, and/or sell copies of the Software, and to │
|
||||
│ permit persons to whom the Software is furnished to do so, subject to │
|
||||
│ the following conditions: │
|
||||
│ │
|
||||
│ The above copyright notice and this permission notice shall be │
|
||||
│ included in all copies or substantial portions of the Software. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │
|
||||
│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │
|
||||
│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │
|
||||
│ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY │
|
||||
│ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, │
|
||||
│ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │
|
||||
│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#define lmem_c
|
||||
#define LUA_CORE
|
||||
|
||||
#include "third_party/lua/ldebug.h"
|
||||
#include "third_party/lua/ldo.h"
|
||||
#include "third_party/lua/lgc.h"
|
||||
|
@ -15,8 +35,13 @@
|
|||
#include "third_party/lua/lprefix.h"
|
||||
#include "third_party/lua/lstate.h"
|
||||
#include "third_party/lua/lua.h"
|
||||
// clang-format off
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Lua 5.4.3 (MIT License)\\n\
|
||||
Copyright 1994–2021 Lua.org, PUC-Rio.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
|
||||
/* clang-format off */
|
||||
|
||||
#if defined(EMERGENCYGCTESTS)
|
||||
/*
|
||||
|
|
6
third_party/lua/lmem.h
vendored
6
third_party/lua/lmem.h
vendored
|
@ -1,9 +1,3 @@
|
|||
/*
|
||||
** $Id: lmem.h $
|
||||
** Interface to Memory Manager
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
#ifndef lmem_h
|
||||
#define lmem_h
|
||||
|
||||
|
|
52
third_party/lua/loadlib.c
vendored
52
third_party/lua/loadlib.c
vendored
|
@ -1,24 +1,52 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╚──────────────────────────────────────────────────────────────────────────────╝
|
||||
│ │
|
||||
│ Lua │
|
||||
│ Copyright © 2004-2021 Lua.org, PUC-Rio. │
|
||||
│ │
|
||||
│ Permission is hereby granted, free of charge, to any person obtaining │
|
||||
│ a copy of this software and associated documentation files (the │
|
||||
│ "Software"), to deal in the Software without restriction, including │
|
||||
│ without limitation the rights to use, copy, modify, merge, publish, │
|
||||
│ distribute, sublicense, and/or sell copies of the Software, and to │
|
||||
│ permit persons to whom the Software is furnished to do so, subject to │
|
||||
│ the following conditions: │
|
||||
│ │
|
||||
│ The above copyright notice and this permission notice shall be │
|
||||
│ included in all copies or substantial portions of the Software. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │
|
||||
│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │
|
||||
│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │
|
||||
│ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY │
|
||||
│ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, │
|
||||
│ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │
|
||||
│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#define loadlib_c
|
||||
#define LUA_LIB
|
||||
#include "third_party/lua/lauxlib.h"
|
||||
#include "third_party/lua/lprefix.h"
|
||||
#include "third_party/lua/lua.h"
|
||||
#include "third_party/lua/lualib.h"
|
||||
// clang-format off
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Lua 5.4.3 (MIT License)\\n\
|
||||
Copyright 1994–2021 Lua.org, PUC-Rio.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
|
||||
/*
|
||||
** $Id: loadlib.c $
|
||||
** Dynamic library loader for Lua
|
||||
** See Copyright Notice in lua.h
|
||||
**
|
||||
** This module contains an implementation of loadlib for Unix systems
|
||||
** that have dlfcn, an implementation for Windows, and a stub for other
|
||||
** systems.
|
||||
*/
|
||||
|
||||
#define loadlib_c
|
||||
#define LUA_LIB
|
||||
|
||||
#include "third_party/lua/lauxlib.h"
|
||||
#include "third_party/lua/lprefix.h"
|
||||
#include "third_party/lua/lua.h"
|
||||
#include "third_party/lua/lualib.h"
|
||||
|
||||
const char *g_lua_path_default = LUA_PATH_DEFAULT;
|
||||
|
||||
/* clang-format off */
|
||||
|
||||
/*
|
||||
** LUA_IGMARK is a mark to ignore all before it when building the
|
||||
|
|
40
third_party/lua/lobject.c
vendored
40
third_party/lua/lobject.c
vendored
|
@ -1,12 +1,32 @@
|
|||
/*
|
||||
** $Id: lobject.c $
|
||||
** Some generic functions over Lua objects
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╚──────────────────────────────────────────────────────────────────────────────╝
|
||||
│ │
|
||||
│ Lua │
|
||||
│ Copyright © 2004-2021 Lua.org, PUC-Rio. │
|
||||
│ │
|
||||
│ Permission is hereby granted, free of charge, to any person obtaining │
|
||||
│ a copy of this software and associated documentation files (the │
|
||||
│ "Software"), to deal in the Software without restriction, including │
|
||||
│ without limitation the rights to use, copy, modify, merge, publish, │
|
||||
│ distribute, sublicense, and/or sell copies of the Software, and to │
|
||||
│ permit persons to whom the Software is furnished to do so, subject to │
|
||||
│ the following conditions: │
|
||||
│ │
|
||||
│ The above copyright notice and this permission notice shall be │
|
||||
│ included in all copies or substantial portions of the Software. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │
|
||||
│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │
|
||||
│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │
|
||||
│ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY │
|
||||
│ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, │
|
||||
│ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │
|
||||
│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#define lobject_c
|
||||
#define LUA_CORE
|
||||
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "third_party/lua/lctype.h"
|
||||
#include "third_party/lua/ldebug.h"
|
||||
|
@ -18,8 +38,12 @@
|
|||
#include "third_party/lua/lstring.h"
|
||||
#include "third_party/lua/lua.h"
|
||||
#include "third_party/lua/lvm.h"
|
||||
// clang-format off
|
||||
|
||||
/* clang-format off */
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Lua 5.4.3 (MIT License)\\n\
|
||||
Copyright 1994–2021 Lua.org, PUC-Rio.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
|
||||
|
||||
static lua_Integer intarith (lua_State *L, int op, lua_Integer v1,
|
||||
|
|
6
third_party/lua/lobject.h
vendored
6
third_party/lua/lobject.h
vendored
|
@ -1,9 +1,3 @@
|
|||
/*
|
||||
** $Id: lobject.h $
|
||||
** Type definitions for Lua objects
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
#ifndef lobject_h
|
||||
#define lobject_h
|
||||
|
||||
|
|
41
third_party/lua/lopcodes.c
vendored
41
third_party/lua/lopcodes.c
vendored
|
@ -1,16 +1,41 @@
|
|||
/*
|
||||
** $Id: lopcodes.c $
|
||||
** Opcodes for Lua virtual machine
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╚──────────────────────────────────────────────────────────────────────────────╝
|
||||
│ │
|
||||
│ Lua │
|
||||
│ Copyright © 2004-2021 Lua.org, PUC-Rio. │
|
||||
│ │
|
||||
│ Permission is hereby granted, free of charge, to any person obtaining │
|
||||
│ a copy of this software and associated documentation files (the │
|
||||
│ "Software"), to deal in the Software without restriction, including │
|
||||
│ without limitation the rights to use, copy, modify, merge, publish, │
|
||||
│ distribute, sublicense, and/or sell copies of the Software, and to │
|
||||
│ permit persons to whom the Software is furnished to do so, subject to │
|
||||
│ the following conditions: │
|
||||
│ │
|
||||
│ The above copyright notice and this permission notice shall be │
|
||||
│ included in all copies or substantial portions of the Software. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │
|
||||
│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │
|
||||
│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │
|
||||
│ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY │
|
||||
│ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, │
|
||||
│ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │
|
||||
│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#define lopcodes_c
|
||||
#define LUA_CORE
|
||||
|
||||
#include "third_party/lua/lopcodes.h"
|
||||
#include "third_party/lua/lprefix.h"
|
||||
// clang-format off
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Lua 5.4.3 (MIT License)\\n\
|
||||
Copyright 1994–2021 Lua.org, PUC-Rio.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
|
||||
/* clang-format off */
|
||||
|
||||
/* ORDER OP */
|
||||
|
||||
|
|
6
third_party/lua/lopcodes.h
vendored
6
third_party/lua/lopcodes.h
vendored
|
@ -1,9 +1,3 @@
|
|||
/*
|
||||
** $Id: lopcodes.h $
|
||||
** Opcodes for Lua virtual machine
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
#ifndef lopcodes_h
|
||||
#define lopcodes_h
|
||||
|
||||
|
|
41
third_party/lua/loslib.c
vendored
41
third_party/lua/loslib.c
vendored
|
@ -1,12 +1,32 @@
|
|||
/*
|
||||
** $Id: loslib.c $
|
||||
** Standard Operating System library
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╚──────────────────────────────────────────────────────────────────────────────╝
|
||||
│ │
|
||||
│ Lua │
|
||||
│ Copyright © 2004-2021 Lua.org, PUC-Rio. │
|
||||
│ │
|
||||
│ Permission is hereby granted, free of charge, to any person obtaining │
|
||||
│ a copy of this software and associated documentation files (the │
|
||||
│ "Software"), to deal in the Software without restriction, including │
|
||||
│ without limitation the rights to use, copy, modify, merge, publish, │
|
||||
│ distribute, sublicense, and/or sell copies of the Software, and to │
|
||||
│ permit persons to whom the Software is furnished to do so, subject to │
|
||||
│ the following conditions: │
|
||||
│ │
|
||||
│ The above copyright notice and this permission notice shall be │
|
||||
│ included in all copies or substantial portions of the Software. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │
|
||||
│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │
|
||||
│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │
|
||||
│ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY │
|
||||
│ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, │
|
||||
│ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │
|
||||
│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#define loslib_c
|
||||
#define LUA_LIB
|
||||
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/errno.h"
|
||||
|
@ -20,8 +40,13 @@
|
|||
#include "third_party/lua/lprefix.h"
|
||||
#include "third_party/lua/lua.h"
|
||||
#include "third_party/lua/lualib.h"
|
||||
// clang-format off
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Lua 5.4.3 (MIT License)\\n\
|
||||
Copyright 1994–2021 Lua.org, PUC-Rio.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
|
||||
/* clang-format off */
|
||||
|
||||
/*
|
||||
** {==================================================================
|
||||
|
|
40
third_party/lua/lparser.c
vendored
40
third_party/lua/lparser.c
vendored
|
@ -1,12 +1,32 @@
|
|||
/*
|
||||
** $Id: lparser.c $
|
||||
** Lua Parser
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╚──────────────────────────────────────────────────────────────────────────────╝
|
||||
│ │
|
||||
│ Lua │
|
||||
│ Copyright © 2004-2021 Lua.org, PUC-Rio. │
|
||||
│ │
|
||||
│ Permission is hereby granted, free of charge, to any person obtaining │
|
||||
│ a copy of this software and associated documentation files (the │
|
||||
│ "Software"), to deal in the Software without restriction, including │
|
||||
│ without limitation the rights to use, copy, modify, merge, publish, │
|
||||
│ distribute, sublicense, and/or sell copies of the Software, and to │
|
||||
│ permit persons to whom the Software is furnished to do so, subject to │
|
||||
│ the following conditions: │
|
||||
│ │
|
||||
│ The above copyright notice and this permission notice shall be │
|
||||
│ included in all copies or substantial portions of the Software. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │
|
||||
│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │
|
||||
│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │
|
||||
│ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY │
|
||||
│ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, │
|
||||
│ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │
|
||||
│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#define lparser_c
|
||||
#define LUA_CORE
|
||||
|
||||
#include "third_party/lua/lcode.h"
|
||||
#include "third_party/lua/ldebug.h"
|
||||
#include "third_party/lua/ldo.h"
|
||||
|
@ -21,8 +41,12 @@
|
|||
#include "third_party/lua/lstring.h"
|
||||
#include "third_party/lua/ltable.h"
|
||||
#include "third_party/lua/lua.h"
|
||||
// clang-format off
|
||||
|
||||
/* clang-format off */
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Lua 5.4.3 (MIT License)\\n\
|
||||
Copyright 1994–2021 Lua.org, PUC-Rio.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
|
||||
|
||||
/* maximum number of local variables per function (must be smaller
|
||||
|
|
6
third_party/lua/lparser.h
vendored
6
third_party/lua/lparser.h
vendored
|
@ -1,9 +1,3 @@
|
|||
/*
|
||||
** $Id: lparser.h $
|
||||
** Lua Parser
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
#ifndef lparser_h
|
||||
#define lparser_h
|
||||
|
||||
|
|
27
third_party/lua/lprefix.h
vendored
27
third_party/lua/lprefix.h
vendored
|
@ -1,45 +1,36 @@
|
|||
/*
|
||||
** $Id: lprefix.h $
|
||||
** Definitions for Lua code that must come before any other header file
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
#ifndef lprefix_h
|
||||
#define lprefix_h
|
||||
|
||||
|
||||
/*
|
||||
** Allows POSIX/XSI stuff
|
||||
*/
|
||||
#if !defined(LUA_USE_C89) /* { */
|
||||
#if !defined(LUA_USE_C89) /* { */
|
||||
|
||||
#if !defined(_XOPEN_SOURCE)
|
||||
#define _XOPEN_SOURCE 600
|
||||
#define _XOPEN_SOURCE 600
|
||||
#elif _XOPEN_SOURCE == 0
|
||||
#undef _XOPEN_SOURCE /* use -D_XOPEN_SOURCE=0 to undefine it */
|
||||
#undef _XOPEN_SOURCE /* use -D_XOPEN_SOURCE=0 to undefine it */
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Allows manipulation of large files in gcc and some other compilers
|
||||
*/
|
||||
#if !defined(LUA_32BITS) && !defined(_FILE_OFFSET_BITS)
|
||||
#define _LARGEFILE_SOURCE 1
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
#define _LARGEFILE_SOURCE 1
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
#endif
|
||||
|
||||
#endif /* } */
|
||||
|
||||
#endif /* } */
|
||||
|
||||
/*
|
||||
** Windows stuff
|
||||
*/
|
||||
#if defined(_WIN32) /* { */
|
||||
#if defined(_WIN32) /* { */
|
||||
|
||||
#if !defined(_CRT_SECURE_NO_WARNINGS)
|
||||
#define _CRT_SECURE_NO_WARNINGS /* avoid warnings about ISO C functions */
|
||||
#define _CRT_SECURE_NO_WARNINGS /* avoid warnings about ISO C functions */
|
||||
#endif
|
||||
|
||||
#endif /* } */
|
||||
#endif /* } */
|
||||
|
||||
#endif
|
||||
|
||||
|
|
64
third_party/lua/lrepl.c
vendored
64
third_party/lua/lrepl.c
vendored
|
@ -1,9 +1,36 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╚──────────────────────────────────────────────────────────────────────────────╝
|
||||
│ │
|
||||
│ Lua │
|
||||
│ Copyright © 2004-2021 Lua.org, PUC-Rio. │
|
||||
│ │
|
||||
│ Permission is hereby granted, free of charge, to any person obtaining │
|
||||
│ a copy of this software and associated documentation files (the │
|
||||
│ "Software"), to deal in the Software without restriction, including │
|
||||
│ without limitation the rights to use, copy, modify, merge, publish, │
|
||||
│ distribute, sublicense, and/or sell copies of the Software, and to │
|
||||
│ permit persons to whom the Software is furnished to do so, subject to │
|
||||
│ the following conditions: │
|
||||
│ │
|
||||
│ The above copyright notice and this permission notice shall be │
|
||||
│ included in all copies or substantial portions of the Software. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │
|
||||
│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │
|
||||
│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │
|
||||
│ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY │
|
||||
│ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, │
|
||||
│ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │
|
||||
│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#define lua_c
|
||||
#include "libc/alg/alg.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/sigbits.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/intrin/nomultics.internal.h"
|
||||
#include "libc/intrin/spinlock.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/runtime/gc.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
@ -12,13 +39,21 @@
|
|||
#include "third_party/linenoise/linenoise.h"
|
||||
#include "third_party/lua/lauxlib.h"
|
||||
#include "third_party/lua/lprefix.h"
|
||||
#include "third_party/lua/lrepl.h"
|
||||
#include "third_party/lua/lua.h"
|
||||
#include "third_party/lua/lualib.h"
|
||||
// clang-format off
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Lua 5.4.3 (MIT License)\\n\
|
||||
Copyright 1994–2021 Lua.org, PUC-Rio.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
|
||||
|
||||
bool lua_repl_blocking;
|
||||
bool lua_repl_isterminal;
|
||||
_Alignas(64) char lualock;
|
||||
linenoiseCompletionCallback *lua_repl_completions_callback;
|
||||
_Alignas(64) char lua_repl_lock;
|
||||
struct linenoiseState *lua_repl_linenoise;
|
||||
static lua_State *globalL;
|
||||
static const char *g_progname;
|
||||
|
@ -63,6 +98,7 @@ void lua_readline_completions(const char *p, linenoiseCompletions *c) {
|
|||
lua_pop(L, 1);
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
lua_repl_completions_callback(p, c);
|
||||
}
|
||||
|
||||
char *lua_readline_hint(const char *p, const char **ansi1, const char **ansi2) {
|
||||
|
@ -128,7 +164,7 @@ static ssize_t pushline (lua_State *L, int firstline) {
|
|||
if (lua_repl_isterminal) {
|
||||
prmt = strdup(get_prompt(L, firstline));
|
||||
lua_pop(L, 1); /* remove prompt */
|
||||
_spunlock(&lualock);
|
||||
LUA_REPL_UNLOCK;
|
||||
rc = linenoiseEdit(lua_repl_linenoise, prmt, &b, !firstline || lua_repl_blocking);
|
||||
free(prmt);
|
||||
if (rc != -1) {
|
||||
|
@ -138,11 +174,11 @@ static ssize_t pushline (lua_State *L, int firstline) {
|
|||
linenoiseHistorySave(g_historypath);
|
||||
}
|
||||
}
|
||||
_spinlock(&lualock);
|
||||
LUA_REPL_LOCK;
|
||||
} else {
|
||||
_spunlock(&lualock);
|
||||
LUA_REPL_UNLOCK;
|
||||
b = linenoiseGetLine(stdin);
|
||||
_spinlock(&lualock);
|
||||
LUA_REPL_LOCK;
|
||||
rc = b ? 1 : -1;
|
||||
}
|
||||
if (rc == -1 || (!rc && !b)) {
|
||||
|
@ -208,7 +244,7 @@ static int multiline (lua_State *L) {
|
|||
|
||||
void lua_initrepl(lua_State *L, const char *progname) {
|
||||
const char *prompt;
|
||||
_spinlock(&lualock);
|
||||
LUA_REPL_LOCK;
|
||||
g_progname = progname;
|
||||
if ((lua_repl_isterminal = linenoiseIsTerminal())) {
|
||||
linenoiseSetCompletionCallback(lua_readline_completions);
|
||||
|
@ -224,20 +260,18 @@ void lua_initrepl(lua_State *L, const char *progname) {
|
|||
}
|
||||
lua_repl_linenoise = linenoiseBegin(prompt, 0, 1);
|
||||
lua_pop(L, 1); /* remove prompt */
|
||||
__nomultics = 2;
|
||||
__replmode = true;
|
||||
}
|
||||
_spunlock(&lualock);
|
||||
LUA_REPL_UNLOCK;
|
||||
}
|
||||
|
||||
|
||||
void lua_freerepl(void) {
|
||||
_spinlock(&lualock);
|
||||
__nomultics = false;
|
||||
LUA_REPL_LOCK;
|
||||
__replmode = false;
|
||||
linenoiseEnd(lua_repl_linenoise);
|
||||
free(g_historypath);
|
||||
_spunlock(&lualock);
|
||||
LUA_REPL_UNLOCK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -254,16 +288,16 @@ int lua_loadline (lua_State *L) {
|
|||
ssize_t rc;
|
||||
int status;
|
||||
lua_settop(L, 0);
|
||||
_spinlock(&lualock);
|
||||
LUA_REPL_LOCK;
|
||||
if ((rc = pushline(L, 1)) != 1) {
|
||||
_spunlock(&lualock);
|
||||
LUA_REPL_UNLOCK;
|
||||
return rc - 1; /* eof or error */
|
||||
}
|
||||
if ((status = addreturn(L)) != LUA_OK) /* 'return ...' did not work? */
|
||||
status = multiline(L); /* try as command, maybe with continuation lines */
|
||||
lua_remove(L, 1); /* remove line from the stack */
|
||||
lua_assert(lua_gettop(L) == 1);
|
||||
_spunlock(&lualock);
|
||||
LUA_REPL_UNLOCK;
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
17
third_party/lua/lrepl.h
vendored
17
third_party/lua/lrepl.h
vendored
|
@ -1,14 +1,29 @@
|
|||
#ifndef COSMOPOLITAN_THIRD_PARTY_LUA_LREPL_H_
|
||||
#define COSMOPOLITAN_THIRD_PARTY_LUA_LREPL_H_
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/spinlock.h"
|
||||
#include "third_party/linenoise/linenoise.h"
|
||||
#include "third_party/lua/lauxlib.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
extern char lualock;
|
||||
#if !defined(STATIC) && SupportsWindows()
|
||||
#define LUA_REPL_LOCK _spinlock(&lua_repl_lock)
|
||||
#else
|
||||
#define LUA_REPL_LOCK (void)0
|
||||
#endif
|
||||
|
||||
#if !defined(STATIC) && SupportsWindows()
|
||||
#define LUA_REPL_UNLOCK _spunlock(&lua_repl_lock)
|
||||
#else
|
||||
#define LUA_REPL_UNLOCK (void)0
|
||||
#endif
|
||||
|
||||
extern char lua_repl_lock;
|
||||
extern bool lua_repl_blocking;
|
||||
extern bool lua_repl_isterminal;
|
||||
extern struct linenoiseState *lua_repl_linenoise;
|
||||
extern linenoiseCompletionCallback *lua_repl_completions_callback;
|
||||
|
||||
void lua_freerepl(void);
|
||||
int lua_loadline(lua_State *);
|
||||
|
|
41
third_party/lua/lstate.c
vendored
41
third_party/lua/lstate.c
vendored
|
@ -1,12 +1,32 @@
|
|||
/*
|
||||
** $Id: lstate.c $
|
||||
** Global State
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╚──────────────────────────────────────────────────────────────────────────────╝
|
||||
│ │
|
||||
│ Lua │
|
||||
│ Copyright © 2004-2021 Lua.org, PUC-Rio. │
|
||||
│ │
|
||||
│ Permission is hereby granted, free of charge, to any person obtaining │
|
||||
│ a copy of this software and associated documentation files (the │
|
||||
│ "Software"), to deal in the Software without restriction, including │
|
||||
│ without limitation the rights to use, copy, modify, merge, publish, │
|
||||
│ distribute, sublicense, and/or sell copies of the Software, and to │
|
||||
│ permit persons to whom the Software is furnished to do so, subject to │
|
||||
│ the following conditions: │
|
||||
│ │
|
||||
│ The above copyright notice and this permission notice shall be │
|
||||
│ included in all copies or substantial portions of the Software. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │
|
||||
│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │
|
||||
│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │
|
||||
│ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY │
|
||||
│ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, │
|
||||
│ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │
|
||||
│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#define lstate_c
|
||||
#define LUA_CORE
|
||||
|
||||
#include "libc/time/time.h"
|
||||
#include "third_party/lua/lapi.h"
|
||||
#include "third_party/lua/ldebug.h"
|
||||
|
@ -21,8 +41,13 @@
|
|||
#include "third_party/lua/ltable.h"
|
||||
#include "third_party/lua/ltm.h"
|
||||
#include "third_party/lua/lua.h"
|
||||
// clang-format off
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Lua 5.4.3 (MIT License)\\n\
|
||||
Copyright 1994–2021 Lua.org, PUC-Rio.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
|
||||
/* clang-format off */
|
||||
|
||||
/*
|
||||
** thread state + extra space
|
||||
|
|
6
third_party/lua/lstate.h
vendored
6
third_party/lua/lstate.h
vendored
|
@ -1,9 +1,3 @@
|
|||
/*
|
||||
** $Id: lstate.h $
|
||||
** Global State
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
#ifndef lstate_h
|
||||
#define lstate_h
|
||||
|
||||
|
|
41
third_party/lua/lstring.c
vendored
41
third_party/lua/lstring.c
vendored
|
@ -1,12 +1,32 @@
|
|||
/*
|
||||
** $Id: lstring.c $
|
||||
** String table (keeps all strings handled by Lua)
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╚──────────────────────────────────────────────────────────────────────────────╝
|
||||
│ │
|
||||
│ Lua │
|
||||
│ Copyright © 2004-2021 Lua.org, PUC-Rio. │
|
||||
│ │
|
||||
│ Permission is hereby granted, free of charge, to any person obtaining │
|
||||
│ a copy of this software and associated documentation files (the │
|
||||
│ "Software"), to deal in the Software without restriction, including │
|
||||
│ without limitation the rights to use, copy, modify, merge, publish, │
|
||||
│ distribute, sublicense, and/or sell copies of the Software, and to │
|
||||
│ permit persons to whom the Software is furnished to do so, subject to │
|
||||
│ the following conditions: │
|
||||
│ │
|
||||
│ The above copyright notice and this permission notice shall be │
|
||||
│ included in all copies or substantial portions of the Software. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │
|
||||
│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │
|
||||
│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │
|
||||
│ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY │
|
||||
│ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, │
|
||||
│ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │
|
||||
│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#define lstring_c
|
||||
#define LUA_CORE
|
||||
|
||||
#include "third_party/lua/ldebug.h"
|
||||
#include "third_party/lua/ldo.h"
|
||||
#include "third_party/lua/lmem.h"
|
||||
|
@ -15,8 +35,13 @@
|
|||
#include "third_party/lua/lstate.h"
|
||||
#include "third_party/lua/lstring.h"
|
||||
#include "third_party/lua/lua.h"
|
||||
// clang-format off
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Lua 5.4.3 (MIT License)\\n\
|
||||
Copyright 1994–2021 Lua.org, PUC-Rio.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
|
||||
/* clang-format off */
|
||||
|
||||
/*
|
||||
** Maximum size for string table.
|
||||
|
|
6
third_party/lua/lstring.h
vendored
6
third_party/lua/lstring.h
vendored
|
@ -1,9 +1,3 @@
|
|||
/*
|
||||
** $Id: lstring.h $
|
||||
** String table (keep all strings handled by Lua)
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
#ifndef lstring_h
|
||||
#define lstring_h
|
||||
|
||||
|
|
61
third_party/lua/lstrlib.c
vendored
61
third_party/lua/lstrlib.c
vendored
|
@ -1,19 +1,44 @@
|
|||
/*
|
||||
** $Id: lstrlib.c $
|
||||
** Standard library for string operations and pattern-matching
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╚──────────────────────────────────────────────────────────────────────────────╝
|
||||
│ │
|
||||
│ Lua │
|
||||
│ Copyright © 2004-2021 Lua.org, PUC-Rio. │
|
||||
│ │
|
||||
│ Permission is hereby granted, free of charge, to any person obtaining │
|
||||
│ a copy of this software and associated documentation files (the │
|
||||
│ "Software"), to deal in the Software without restriction, including │
|
||||
│ without limitation the rights to use, copy, modify, merge, publish, │
|
||||
│ distribute, sublicense, and/or sell copies of the Software, and to │
|
||||
│ permit persons to whom the Software is furnished to do so, subject to │
|
||||
│ the following conditions: │
|
||||
│ │
|
||||
│ The above copyright notice and this permission notice shall be │
|
||||
│ included in all copies or substantial portions of the Software. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │
|
||||
│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │
|
||||
│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │
|
||||
│ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY │
|
||||
│ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, │
|
||||
│ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │
|
||||
│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#define lstrlib_c
|
||||
#define LUA_LIB
|
||||
|
||||
#include "libc/math.h"
|
||||
#include "third_party/lua/cosmo.h"
|
||||
#include "third_party/lua/lauxlib.h"
|
||||
#include "third_party/lua/lprefix.h"
|
||||
#include "third_party/lua/lua.h"
|
||||
#include "third_party/lua/lualib.h"
|
||||
// clang-format off
|
||||
|
||||
/* clang-format off */
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Lua 5.4.3 (MIT License)\\n\
|
||||
Copyright 1994–2021 Lua.org, PUC-Rio.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
|
||||
|
||||
/*
|
||||
|
@ -41,6 +66,8 @@
|
|||
|
||||
|
||||
|
||||
static int str_format(lua_State *);
|
||||
|
||||
|
||||
static int str_len (lua_State *L) {
|
||||
size_t l;
|
||||
|
@ -297,7 +324,21 @@ static int arith_mul (lua_State *L) {
|
|||
}
|
||||
|
||||
static int arith_mod (lua_State *L) {
|
||||
return arith(L, LUA_OPMOD, "__mod");
|
||||
int i, n;
|
||||
if (lua_istable(L, 2)) { // [jart] python printf operator
|
||||
lua_len(L, 2);
|
||||
n = lua_tointeger(L, -1);
|
||||
lua_pop(L, 1);
|
||||
lua_pushcfunction(L, str_format);
|
||||
lua_pushvalue(L, 1);
|
||||
for (i = 1; i <= n; ++i) {
|
||||
lua_geti(L, 2, i);
|
||||
}
|
||||
lua_call(L, 1 + n, 1);
|
||||
return 1;
|
||||
} else {
|
||||
return arith(L, LUA_OPMOD, "__mod");
|
||||
}
|
||||
}
|
||||
|
||||
static int arith_pow (lua_State *L) {
|
||||
|
@ -536,7 +577,7 @@ static const char *start_capture (MatchState *ms, const char *s,
|
|||
|
||||
|
||||
static const char *end_capture (MatchState *ms, const char *s,
|
||||
const char *p) {
|
||||
const char *p) {
|
||||
int l = capture_to_close(ms);
|
||||
const char *res;
|
||||
ms->capture[l].len = s - ms->capture[l].init; /* close capture */
|
||||
|
|
41
third_party/lua/ltable.c
vendored
41
third_party/lua/ltable.c
vendored
|
@ -1,12 +1,32 @@
|
|||
/*
|
||||
** $Id: ltable.c $
|
||||
** Lua tables (hash)
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╚──────────────────────────────────────────────────────────────────────────────╝
|
||||
│ │
|
||||
│ Lua │
|
||||
│ Copyright © 2004-2021 Lua.org, PUC-Rio. │
|
||||
│ │
|
||||
│ Permission is hereby granted, free of charge, to any person obtaining │
|
||||
│ a copy of this software and associated documentation files (the │
|
||||
│ "Software"), to deal in the Software without restriction, including │
|
||||
│ without limitation the rights to use, copy, modify, merge, publish, │
|
||||
│ distribute, sublicense, and/or sell copies of the Software, and to │
|
||||
│ permit persons to whom the Software is furnished to do so, subject to │
|
||||
│ the following conditions: │
|
||||
│ │
|
||||
│ The above copyright notice and this permission notice shall be │
|
||||
│ included in all copies or substantial portions of the Software. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │
|
||||
│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │
|
||||
│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │
|
||||
│ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY │
|
||||
│ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, │
|
||||
│ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │
|
||||
│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#define ltable_c
|
||||
#define LUA_CORE
|
||||
|
||||
#include "third_party/lua/ldebug.h"
|
||||
#include "third_party/lua/ldo.h"
|
||||
#include "third_party/lua/lgc.h"
|
||||
|
@ -18,8 +38,13 @@
|
|||
#include "third_party/lua/ltable.h"
|
||||
#include "third_party/lua/lua.h"
|
||||
#include "third_party/lua/lvm.h"
|
||||
// clang-format off
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Lua 5.4.3 (MIT License)\\n\
|
||||
Copyright 1994–2021 Lua.org, PUC-Rio.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
|
||||
/* clang-format off */
|
||||
|
||||
/*
|
||||
** Implementation of tables (aka arrays, objects, or hash tables).
|
||||
|
|
6
third_party/lua/ltable.h
vendored
6
third_party/lua/ltable.h
vendored
|
@ -1,9 +1,3 @@
|
|||
/*
|
||||
** $Id: ltable.h $
|
||||
** Lua tables (hash)
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
#ifndef ltable_h
|
||||
#define ltable_h
|
||||
|
||||
|
|
41
third_party/lua/ltablib.c
vendored
41
third_party/lua/ltablib.c
vendored
|
@ -1,20 +1,45 @@
|
|||
/*
|
||||
** $Id: ltablib.c $
|
||||
** Library for Table Manipulation
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╚──────────────────────────────────────────────────────────────────────────────╝
|
||||
│ │
|
||||
│ Lua │
|
||||
│ Copyright © 2004-2021 Lua.org, PUC-Rio. │
|
||||
│ │
|
||||
│ Permission is hereby granted, free of charge, to any person obtaining │
|
||||
│ a copy of this software and associated documentation files (the │
|
||||
│ "Software"), to deal in the Software without restriction, including │
|
||||
│ without limitation the rights to use, copy, modify, merge, publish, │
|
||||
│ distribute, sublicense, and/or sell copies of the Software, and to │
|
||||
│ permit persons to whom the Software is furnished to do so, subject to │
|
||||
│ the following conditions: │
|
||||
│ │
|
||||
│ The above copyright notice and this permission notice shall be │
|
||||
│ included in all copies or substantial portions of the Software. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │
|
||||
│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │
|
||||
│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │
|
||||
│ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY │
|
||||
│ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, │
|
||||
│ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │
|
||||
│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#define ltablib_c
|
||||
#define LUA_LIB
|
||||
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/time/time.h"
|
||||
#include "third_party/lua/lauxlib.h"
|
||||
#include "third_party/lua/lprefix.h"
|
||||
#include "third_party/lua/lua.h"
|
||||
#include "third_party/lua/lualib.h"
|
||||
// clang-format off
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Lua 5.4.3 (MIT License)\\n\
|
||||
Copyright 1994–2021 Lua.org, PUC-Rio.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
|
||||
/* clang-format off */
|
||||
|
||||
/*
|
||||
** Operations that an object must define to mimic a table
|
||||
|
|
41
third_party/lua/ltests.c
vendored
41
third_party/lua/ltests.c
vendored
|
@ -1,12 +1,32 @@
|
|||
/*
|
||||
** $Id: ltests.c $
|
||||
** Internal Module for Debugging of the Lua Implementation
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╚──────────────────────────────────────────────────────────────────────────────╝
|
||||
│ │
|
||||
│ Lua │
|
||||
│ Copyright © 2004-2021 Lua.org, PUC-Rio. │
|
||||
│ │
|
||||
│ Permission is hereby granted, free of charge, to any person obtaining │
|
||||
│ a copy of this software and associated documentation files (the │
|
||||
│ "Software"), to deal in the Software without restriction, including │
|
||||
│ without limitation the rights to use, copy, modify, merge, publish, │
|
||||
│ distribute, sublicense, and/or sell copies of the Software, and to │
|
||||
│ permit persons to whom the Software is furnished to do so, subject to │
|
||||
│ the following conditions: │
|
||||
│ │
|
||||
│ The above copyright notice and this permission notice shall be │
|
||||
│ included in all copies or substantial portions of the Software. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │
|
||||
│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │
|
||||
│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │
|
||||
│ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY │
|
||||
│ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, │
|
||||
│ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │
|
||||
│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#define ltests_c
|
||||
#define LUA_CORE
|
||||
|
||||
#include "third_party/lua/lapi.h"
|
||||
#include "third_party/lua/lauxlib.h"
|
||||
#include "third_party/lua/lcode.h"
|
||||
|
@ -23,8 +43,13 @@
|
|||
#include "third_party/lua/ltable.h"
|
||||
#include "third_party/lua/lua.h"
|
||||
#include "third_party/lua/lualib.h"
|
||||
// clang-format off
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Lua 5.4.3 (MIT License)\\n\
|
||||
Copyright 1994–2021 Lua.org, PUC-Rio.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
|
||||
/* clang-format off */
|
||||
|
||||
/*
|
||||
** The whole module only makes sense with LUA_DEBUG on
|
||||
|
|
7
third_party/lua/ltests.h
vendored
7
third_party/lua/ltests.h
vendored
|
@ -1,12 +1,5 @@
|
|||
/*
|
||||
** $Id: ltests.h $
|
||||
** Internal Header for Debugging of the Lua Implementation
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
#ifndef ltests_h
|
||||
#define ltests_h
|
||||
|
||||
#include "third_party/lua/lua.h"
|
||||
|
||||
/* clang-format off */
|
||||
|
|
41
third_party/lua/ltm.c
vendored
41
third_party/lua/ltm.c
vendored
|
@ -1,12 +1,32 @@
|
|||
/*
|
||||
** $Id: ltm.c $
|
||||
** Tag methods
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╚──────────────────────────────────────────────────────────────────────────────╝
|
||||
│ │
|
||||
│ Lua │
|
||||
│ Copyright © 2004-2021 Lua.org, PUC-Rio. │
|
||||
│ │
|
||||
│ Permission is hereby granted, free of charge, to any person obtaining │
|
||||
│ a copy of this software and associated documentation files (the │
|
||||
│ "Software"), to deal in the Software without restriction, including │
|
||||
│ without limitation the rights to use, copy, modify, merge, publish, │
|
||||
│ distribute, sublicense, and/or sell copies of the Software, and to │
|
||||
│ permit persons to whom the Software is furnished to do so, subject to │
|
||||
│ the following conditions: │
|
||||
│ │
|
||||
│ The above copyright notice and this permission notice shall be │
|
||||
│ included in all copies or substantial portions of the Software. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │
|
||||
│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │
|
||||
│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │
|
||||
│ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY │
|
||||
│ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, │
|
||||
│ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │
|
||||
│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#define ltm_c
|
||||
#define LUA_CORE
|
||||
|
||||
#include "third_party/lua/ldebug.h"
|
||||
#include "third_party/lua/ldo.h"
|
||||
#include "third_party/lua/lgc.h"
|
||||
|
@ -18,8 +38,13 @@
|
|||
#include "third_party/lua/ltm.h"
|
||||
#include "third_party/lua/lua.h"
|
||||
#include "third_party/lua/lvm.h"
|
||||
// clang-format off
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Lua 5.4.3 (MIT License)\\n\
|
||||
Copyright 1994–2021 Lua.org, PUC-Rio.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
|
||||
/* clang-format off */
|
||||
|
||||
static const char udatatypename[] = "userdata";
|
||||
|
||||
|
|
8
third_party/lua/ltm.h
vendored
8
third_party/lua/ltm.h
vendored
|
@ -1,16 +1,8 @@
|
|||
/*
|
||||
** $Id: ltm.h $
|
||||
** Tag methods
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
#ifndef ltm_h
|
||||
#define ltm_h
|
||||
|
||||
#include "third_party/lua/lobject.h"
|
||||
#include "third_party/lua/luaconf.h"
|
||||
#include "third_party/lua/tms.h"
|
||||
|
||||
/* clang-format off */
|
||||
|
||||
/*
|
||||
|
|
42
third_party/lua/lua.main.c
vendored
42
third_party/lua/lua.main.c
vendored
|
@ -1,11 +1,31 @@
|
|||
/*
|
||||
** $Id: lua.c $
|
||||
** Lua stand-alone interpreter
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╚──────────────────────────────────────────────────────────────────────────────╝
|
||||
│ │
|
||||
│ Lua │
|
||||
│ Copyright © 2004-2021 Lua.org, PUC-Rio. │
|
||||
│ │
|
||||
│ Permission is hereby granted, free of charge, to any person obtaining │
|
||||
│ a copy of this software and associated documentation files (the │
|
||||
│ "Software"), to deal in the Software without restriction, including │
|
||||
│ without limitation the rights to use, copy, modify, merge, publish, │
|
||||
│ distribute, sublicense, and/or sell copies of the Software, and to │
|
||||
│ permit persons to whom the Software is furnished to do so, subject to │
|
||||
│ the following conditions: │
|
||||
│ │
|
||||
│ The above copyright notice and this permission notice shall be │
|
||||
│ included in all copies or substantial portions of the Software. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │
|
||||
│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │
|
||||
│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │
|
||||
│ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY │
|
||||
│ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, │
|
||||
│ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │
|
||||
│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#define lua_c
|
||||
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/sigbits.h"
|
||||
#include "libc/calls/struct/sigaction.h"
|
||||
|
@ -28,11 +48,15 @@
|
|||
#include "third_party/lua/lrepl.h"
|
||||
#include "third_party/lua/lua.h"
|
||||
#include "third_party/lua/lualib.h"
|
||||
// clang-format off
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Lua 5.4.3 (MIT License)\\n\
|
||||
Copyright 1994–2021 Lua.org, PUC-Rio.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
|
||||
STATIC_STACK_SIZE(0x40000);
|
||||
|
||||
/* clang-format off */
|
||||
|
||||
#if !defined(LUA_PROGNAME)
|
||||
#define LUA_PROGNAME "lua"
|
||||
#endif
|
||||
|
|
41
third_party/lua/luac.main.c
vendored
41
third_party/lua/luac.main.c
vendored
|
@ -1,12 +1,32 @@
|
|||
/*
|
||||
** $Id: luac.c $
|
||||
** Lua compiler (saves bytecodes to files; also lists bytecodes)
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╚──────────────────────────────────────────────────────────────────────────────╝
|
||||
│ │
|
||||
│ Lua │
|
||||
│ Copyright © 2004-2021 Lua.org, PUC-Rio. │
|
||||
│ │
|
||||
│ Permission is hereby granted, free of charge, to any person obtaining │
|
||||
│ a copy of this software and associated documentation files (the │
|
||||
│ "Software"), to deal in the Software without restriction, including │
|
||||
│ without limitation the rights to use, copy, modify, merge, publish, │
|
||||
│ distribute, sublicense, and/or sell copies of the Software, and to │
|
||||
│ permit persons to whom the Software is furnished to do so, subject to │
|
||||
│ the following conditions: │
|
||||
│ │
|
||||
│ The above copyright notice and this permission notice shall be │
|
||||
│ included in all copies or substantial portions of the Software. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │
|
||||
│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │
|
||||
│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │
|
||||
│ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY │
|
||||
│ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, │
|
||||
│ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │
|
||||
│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#define luac_c
|
||||
#define LUA_CORE
|
||||
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/sigbits.h"
|
||||
#include "libc/calls/struct/sigaction.h"
|
||||
|
@ -22,8 +42,13 @@
|
|||
#include "third_party/lua/lua.h"
|
||||
#include "third_party/lua/lualib.h"
|
||||
#include "third_party/lua/lundump.h"
|
||||
// clang-format off
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Lua 5.4.3 (MIT License)\\n\
|
||||
Copyright 1994–2021 Lua.org, PUC-Rio.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
|
||||
/* clang-format off */
|
||||
|
||||
static void PrintFunction(const Proto* f, int full);
|
||||
#define luaU_print PrintFunction
|
||||
|
|
7
third_party/lua/lualib.h
vendored
7
third_party/lua/lualib.h
vendored
|
@ -1,12 +1,5 @@
|
|||
/*
|
||||
** $Id: lualib.h $
|
||||
** Lua standard libraries
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
#ifndef lualib_h
|
||||
#define lualib_h
|
||||
|
||||
#include "third_party/lua/lua.h"
|
||||
|
||||
/* clang-format off */
|
||||
|
|
31
third_party/lua/luaprintstack.c
vendored
Normal file
31
third_party/lua/luaprintstack.c
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2022 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "third_party/lua/cosmo.h"
|
||||
#include "third_party/lua/lua.h"
|
||||
|
||||
/**
|
||||
* Development tool for quickly viewing the Lua stack.
|
||||
*/
|
||||
void LuaPrintStack(lua_State *L) {
|
||||
char *s = LuaFormatStack(L);
|
||||
fputs(s, stderr);
|
||||
fputc('\n', stderr);
|
||||
free(s);
|
||||
}
|
7
third_party/lua/lundump.h
vendored
7
third_party/lua/lundump.h
vendored
|
@ -1,12 +1,5 @@
|
|||
/*
|
||||
** $Id: lundump.h $
|
||||
** load precompiled Lua chunks
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
#ifndef lundump_h
|
||||
#define lundump_h
|
||||
|
||||
#include "third_party/lua/llimits.h"
|
||||
#include "third_party/lua/lobject.h"
|
||||
#include "third_party/lua/lzio.h"
|
||||
|
|
41
third_party/lua/lvm.c
vendored
41
third_party/lua/lvm.c
vendored
|
@ -1,12 +1,32 @@
|
|||
/*
|
||||
** $Id: lvm.c $
|
||||
** Lua virtual machine
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╚──────────────────────────────────────────────────────────────────────────────╝
|
||||
│ │
|
||||
│ Lua │
|
||||
│ Copyright © 2004-2021 Lua.org, PUC-Rio. │
|
||||
│ │
|
||||
│ Permission is hereby granted, free of charge, to any person obtaining │
|
||||
│ a copy of this software and associated documentation files (the │
|
||||
│ "Software"), to deal in the Software without restriction, including │
|
||||
│ without limitation the rights to use, copy, modify, merge, publish, │
|
||||
│ distribute, sublicense, and/or sell copies of the Software, and to │
|
||||
│ permit persons to whom the Software is furnished to do so, subject to │
|
||||
│ the following conditions: │
|
||||
│ │
|
||||
│ The above copyright notice and this permission notice shall be │
|
||||
│ included in all copies or substantial portions of the Software. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │
|
||||
│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │
|
||||
│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │
|
||||
│ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY │
|
||||
│ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, │
|
||||
│ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │
|
||||
│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#define lvm_c
|
||||
#define LUA_CORE
|
||||
|
||||
#include "third_party/lua/ldebug.h"
|
||||
#include "third_party/lua/ldo.h"
|
||||
#include "third_party/lua/lfunc.h"
|
||||
|
@ -20,8 +40,13 @@
|
|||
#include "third_party/lua/ltm.h"
|
||||
#include "third_party/lua/lua.h"
|
||||
#include "third_party/lua/lvm.h"
|
||||
// clang-format off
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Lua 5.4.3 (MIT License)\\n\
|
||||
Copyright 1994–2021 Lua.org, PUC-Rio.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
|
||||
/* clang-format off */
|
||||
|
||||
/*
|
||||
** By default, use jump tables in the main interpreter loop on gcc
|
||||
|
|
7
third_party/lua/lvm.h
vendored
7
third_party/lua/lvm.h
vendored
|
@ -1,12 +1,5 @@
|
|||
/*
|
||||
** $Id: lvm.h $
|
||||
** Lua virtual machine
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
#ifndef lvm_h
|
||||
#define lvm_h
|
||||
|
||||
#include "third_party/lua/ldo.h"
|
||||
#include "third_party/lua/lobject.h"
|
||||
#include "third_party/lua/ltm.h"
|
||||
|
|
41
third_party/lua/lzio.c
vendored
41
third_party/lua/lzio.c
vendored
|
@ -1,20 +1,45 @@
|
|||
/*
|
||||
** $Id: lzio.c $
|
||||
** Buffered streams
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╚──────────────────────────────────────────────────────────────────────────────╝
|
||||
│ │
|
||||
│ Lua │
|
||||
│ Copyright © 2004-2021 Lua.org, PUC-Rio. │
|
||||
│ │
|
||||
│ Permission is hereby granted, free of charge, to any person obtaining │
|
||||
│ a copy of this software and associated documentation files (the │
|
||||
│ "Software"), to deal in the Software without restriction, including │
|
||||
│ without limitation the rights to use, copy, modify, merge, publish, │
|
||||
│ distribute, sublicense, and/or sell copies of the Software, and to │
|
||||
│ permit persons to whom the Software is furnished to do so, subject to │
|
||||
│ the following conditions: │
|
||||
│ │
|
||||
│ The above copyright notice and this permission notice shall be │
|
||||
│ included in all copies or substantial portions of the Software. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │
|
||||
│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │
|
||||
│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │
|
||||
│ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY │
|
||||
│ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, │
|
||||
│ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │
|
||||
│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#define lzio_c
|
||||
#define LUA_CORE
|
||||
|
||||
#include "third_party/lua/llimits.h"
|
||||
#include "third_party/lua/lmem.h"
|
||||
#include "third_party/lua/lprefix.h"
|
||||
#include "third_party/lua/lstate.h"
|
||||
#include "third_party/lua/lua.h"
|
||||
#include "third_party/lua/lzio.h"
|
||||
// clang-format off
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Lua 5.4.3 (MIT License)\\n\
|
||||
Copyright 1994–2021 Lua.org, PUC-Rio.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
|
||||
/* clang-format off */
|
||||
|
||||
int luaZ_fill (ZIO *z) {
|
||||
size_t size;
|
||||
|
|
2
third_party/python/Modules/termios.c
vendored
2
third_party/python/Modules/termios.c
vendored
|
@ -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);
|
||||
|
|
10
third_party/python/pyobj.c
vendored
10
third_party/python/pyobj.c
vendored
|
@ -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);
|
||||
|
|
11
third_party/python/repl.c
vendored
11
third_party/python/repl.c
vendored
|
@ -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);
|
||||
|
|
35
third_party/zip/zip.c
vendored
35
third_party/zip/zip.c
vendored
|
@ -34,6 +34,7 @@
|
|||
#include "libc/log/log.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/stdio/temp.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "third_party/bzip2/bzlib.h"
|
||||
|
||||
#define MAXCOM 256 /* Maximum one-line comment size */
|
||||
|
@ -646,13 +647,6 @@ local void help()
|
|||
}
|
||||
}
|
||||
|
||||
static const char *GetPagerPath(char path[PATH_MAX]) {
|
||||
const char *s;
|
||||
if ((s = commandv("less", path))) return s;
|
||||
if ((s = commandv("more", path))) return s;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef VMSCLI
|
||||
void help_extended()
|
||||
#else
|
||||
|
@ -660,10 +654,7 @@ local void help_extended()
|
|||
#endif
|
||||
/* Print extended help to stdout. */
|
||||
{
|
||||
extent i; /* counter for help array */
|
||||
|
||||
/* help array */
|
||||
const char *text = "\n\
|
||||
__paginate(1, "\n\
|
||||
Extended Help for Zip\n\
|
||||
\n\
|
||||
See the Zip Manual for more detailed help\n\
|
||||
|
@ -986,27 +977,7 @@ More option highlights (see manual for additional options and details):\n\
|
|||
-so show all available options on this system\n\
|
||||
-X default=strip old extra fields, -X- keep old, -X strip most\n\
|
||||
-ws wildcards don't span directory boundaries in paths\n\
|
||||
";
|
||||
|
||||
int pip[2];
|
||||
char *args[2] = {0};
|
||||
char pathbuf[PATH_MAX];
|
||||
if (isatty(0) && isatty(1) && (args[0] = GetPagerPath(pathbuf))) {
|
||||
sigaction(SIGPIPE, &(struct sigaction){.sa_handler = SIG_IGN}, 0);
|
||||
close(0);
|
||||
pipe(pip);
|
||||
if (!fork()) {
|
||||
close(pip[1]);
|
||||
execv(args[0], args);
|
||||
_Exit(127);
|
||||
}
|
||||
close(0);
|
||||
write(pip[1], text, strlen(text));
|
||||
close(pip[1]);
|
||||
wait(0);
|
||||
} else {
|
||||
fputs(text, stdout);
|
||||
}
|
||||
");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue