diff -r lua-5.4.6/Makefile lua-5.4.7/Makefile
49c49
< R= $V.6
---
> R= $V.7
diff -r lua-5.4.6/README lua-5.4.7/README
2c2
< This is Lua 5.4.6, released on 02 May 2023.
---
> This is Lua 5.4.7, released on 13 Jun 2024.
Only in lua-5.4.7/doc: OSIApproved_100X125.png
diff -r lua-5.4.6/doc/contents.html lua-5.4.7/doc/contents.html
13c13
<
---
>
21c21
< Programming in Lua.
---
> Programming in Lua.
30c30
< other versions
---
> other versions
35c35
< Copyright © 2020–2023 Lua.org, PUC-Rio.
---
> Copyright © 2020–2024 Lua.org, PUC-Rio.
37c37
< Lua license.
---
> Lua license.
671c671
< Sat Apr 1 17:57:05 UTC 2023
---
> Thu May 9 14:47:09 UTC 2024
674c674
< Last change: revised for Lua 5.4.5
---
> Last change: revised for Lua 5.4.7
diff -r lua-5.4.6/doc/lua.1 lua-5.4.7/doc/lua.1
1,2c1,2
< .\" $Id: lua.man,v 1.14 2022/09/23 09:06:36 lhf Exp $
< .TH LUA 1 "$Date: 2022/09/23 09:06:36 $"
---
> .\" $Id: lua.man,v 1.14 2024/05/08 18:48:27 lhf Exp $
> .TH LUA 1 "$Date: 2024/05/08 18:48:27 $"
126c126
< Initial value of package.cpath,
---
> Initial value of package.path,
diff -r lua-5.4.6/doc/lua.css lua-5.4.7/doc/lua.css
145a146
> border-radius: 2px ;
diff -r lua-5.4.6/doc/manual.html lua-5.4.7/doc/manual.html
13c13
<
---
>
22c22
< Copyright © 2020–2023 Lua.org, PUC-Rio.
---
> Copyright © 2020–2024 Lua.org, PUC-Rio.
24c24
< Lua license.
---
> Lua license.
32c32
< other versions
---
> other versions
394c394
< but programs may generate errors with
---
> but programs can generate errors with
404c404
< you may give a message handler
---
> you can give a message handler
456c456
< a metamethod may in fact be any callable value,
---
> a metamethod can in fact be any callable value,
1728c1728
< A goto may jump to any visible label as long as it does not
---
> A goto can jump to any visible label as long as it does not
5574c5574
< [-0, +0, m]
---
> [-0, +0, v]
5594a5595,5599
> This function raises an error if the value at the given slot
> neither has a __close
metamethod nor is a false value.
>
>
>
5666a5672,5677 >
> This function can raise memory errors only
> when converting a number to a string
> (as then it may create a new string).
>
>
11279,11280c11290
< If present,
< the option 'f
'
---
> The option 'f
'
11282,11285c11292,11296
< If present,
< the option 'L
'
< adds a field named activelines
with the table of
< valid lines.
---
> The option 'L
' adds a field named activelines
> with the table of valid lines,
> provided the function is a Lua function.
> If the function has no debug information,
> the table is empty.
11621a11633,11636
> To signal to the libraries that this option is on,
> the stand-alone interpreter sets the field
> "LUA_NOENV"
in the registry to a true value.
> Other libraries may consult this field for the same purpose.
12036d12050
<
12039c12053
< Tue May 2 20:09:38 UTC 2023
---
> Thu Jun 13 22:15:52 UTC 2024
12042c12056
< Last change: revised for Lua 5.4.6
---
> Last change: revised for Lua 5.4.7
Only in lua-5.4.6/doc: osi-certified-72x60.png
diff -r lua-5.4.6/doc/readme.html lua-5.4.7/doc/readme.html
32c32
<
---
>
52c52
< team
---
> team
54c54
< PUC-Rio,
---
> PUC-Rio,
59c59
< many products and projects
---
> many products and projects
64c64
< official web site
---
> official website
69c69,71
< executive summary
---
> executive summary,
> tips on
> getting started,
72c74
< documentation,
---
> documentation,
74c76
< reference manual,
---
> reference manual,
82c84
< source
---
> source
91c93
< such as Linux and Mac OS X.
---
> such as Linux and macOS.
100c102
< LuaBinaries.
---
> LuaBinaries.
110c112
< the top-level directory, which is named lua-5.4.6.
---
> the top-level directory, which is named lua-5.4.7.
214,215c216,217
< On the other hand, if you need to customize some Lua features, you'll need
< to edit src/luaconf.h before building and installing Lua.
---
> On the other hand, if you need to customize some Lua features,
> edit src/luaconf.h before building and installing Lua.
244c246
< To use Lua as a library in your own programs, you'll need to know how to
---
> To use Lua as a library in your own programs, you need to know how to
287,288c289,290
<
<
---
>
>
291c293
< MIT license
---
> MIT license
299,300c301,302
< For details, see
< this.
---
> For details, see the
> license page.
303c305
< Copyright © 1994–2023 Lua.org, PUC-Rio.
---
> Copyright © 1994–2024 Lua.org, PUC-Rio.
330c332
< Tue May 2 20:08:55 UTC 2023
---
> Wed May 8 21:56:16 UTC 2024
333c335
< Last change: revised for Lua 5.4.6
---
> Last change: revised for Lua 5.4.7
diff -r lua-5.4.6/src/lapi.c lua-5.4.7/src/lapi.c
420c420
< *len = vslen(o);
---
> *len = tsslen(tsvalue(o));
422c422
< return svalue(o);
---
> return getstr(tsvalue(o));
diff -r lua-5.4.6/src/lauxlib.c lua-5.4.7/src/lauxlib.c
82a83
> luaL_checkstack(L, 6, "not enough stack"); /* slots for 'findfield' */
251a253
> const char *msg;
252a255
> msg = (en != 0) ? strerror(en) : "(no extra info)";
254c257
< lua_pushfstring(L, "%s: %s", fname, strerror(en));
---
> lua_pushfstring(L, "%s: %s", fname, msg);
256c259
< lua_pushstring(L, strerror(en));
---
> lua_pushstring(L, msg);
735c738
< const char *serr = strerror(errno);
---
> int err = errno;
737c740,743
< lua_pushfstring(L, "cannot %s %s: %s", what, filename, serr);
---
> if (err != 0)
> lua_pushfstring(L, "cannot %s %s: %s", what, filename, strerror(err));
> else
> lua_pushfstring(L, "cannot %s %s", what, filename);
789a796
> errno = 0;
798a806
> errno = 0;
805a814
> errno = 0;
936c945
< if (l->func == NULL) /* place holder? */
---
> if (l->func == NULL) /* placeholder? */
1027a1037,1040
> /*
> ** Standard panic funcion just prints an error message. The test
> ** with 'lua_type' avoids possible memory errors in 'lua_tostring'.
> */
1029,1030c1042,1044
< const char *msg = lua_tostring(L, -1);
< if (msg == NULL) msg = "error object is not a string";
---
> const char *msg = (lua_type(L, -1) == LUA_TSTRING)
> ? lua_tostring(L, -1)
> : "error object is not a string";
diff -r lua-5.4.6/src/lcode.c lua-5.4.7/src/lcode.c
418c418
< int luaK_codeAsBx (FuncState *fs, OpCode o, int a, int bc) {
---
> static int codeAsBx (FuncState *fs, OpCode o, int a, int bc) {
674c674
< luaK_codeAsBx(fs, OP_LOADI, reg, cast_int(i));
---
> codeAsBx(fs, OP_LOADI, reg, cast_int(i));
683c683
< luaK_codeAsBx(fs, OP_LOADF, reg, cast_int(fi));
---
> codeAsBx(fs, OP_LOADF, reg, cast_int(fi));
779c779,780
< e->u.info = e->u.var.ridx;
---
> int temp = e->u.var.ridx;
> e->u.info = temp; /* (can't do a direct assignment; values overlap) */
1028c1029
< int luaK_exp2RK (FuncState *fs, expdesc *e) {
---
> static int exp2RK (FuncState *fs, expdesc *e) {
1040c1041
< int k = luaK_exp2RK(fs, ec);
---
> int k = exp2RK(fs, ec);
1218c1219
< ** Check whether expression 'e' is a small literal string
---
> ** Check whether expression 'e' is a short literal string
1228c1229
< int luaK_isKint (expdesc *e) {
---
> static int isKint (expdesc *e) {
1238c1239
< return luaK_isKint(e) && (l_castS2U(e->u.ival) <= l_castS2U(MAXARG_C));
---
> return isKint(e) && (l_castS2U(e->u.ival) <= l_castS2U(MAXARG_C));
1247c1248
< return luaK_isKint(e) && fitsC(e->u.ival);
---
> return isKint(e) && fitsC(e->u.ival);
1286,1287c1287,1290
< t->u.ind.t = t->u.info; /* upvalue index */
< t->u.ind.idx = k->u.info; /* literal string */
---
> int temp = t->u.info; /* upvalue index */
> lua_assert(isKstr(fs, k));
> t->u.ind.t = temp; /* (can't do a direct assignment; values overlap) */
> t->u.ind.idx = k->u.info; /* literal short string */
1294c1297
< t->u.ind.idx = k->u.info; /* literal string */
---
> t->u.ind.idx = k->u.info; /* literal short string */
1462c1465
< if (!luaK_isKint(e2))
---
> if (!isKint(e2))
1595c1598
< else if (luaK_exp2RK(fs, e2)) { /* 2nd expression is constant? */
---
> else if (exp2RK(fs, e2)) { /* 2nd expression is constant? */
1661c1664
< luaK_exp2RK(fs, v);
---
> exp2RK(fs, v);
diff -r lua-5.4.6/src/lcode.h lua-5.4.7/src/lcode.h
64d63
< LUAI_FUNC int luaK_codeAsBx (FuncState *fs, OpCode o, int A, int Bx);
67d65
< LUAI_FUNC int luaK_isKint (expdesc *e);
79d76
< LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e);
diff -r lua-5.4.6/src/ldebug.c lua-5.4.7/src/ldebug.c
34c34
< #define noLuaClosure(f) ((f) == NULL || (f)->c.tt == LUA_VCCL)
---
> #define LuaClosure(f) ((f) != NULL && (f)->c.tt == LUA_VLCL)
257c257
< if (noLuaClosure(cl)) {
---
> if (!LuaClosure(cl)) {
291c291
< if (noLuaClosure(f)) {
---
> if (!LuaClosure(f)) {
296,297d295
< int i;
< TValue v;
303,313c301,315
< setbtvalue(&v); /* boolean 'true' to be the value of all indices */
< if (!p->is_vararg) /* regular function? */
< i = 0; /* consider all instructions */
< else { /* vararg function */
< lua_assert(GET_OPCODE(p->code[0]) == OP_VARARGPREP);
< currentline = nextline(p, currentline, 0);
< i = 1; /* skip first instruction (OP_VARARGPREP) */
< }
< for (; i < p->sizelineinfo; i++) { /* for each instruction */
< currentline = nextline(p, currentline, i); /* get its line */
< luaH_setint(L, t, currentline, &v); /* table[line] = true */
---
> if (p->lineinfo != NULL) { /* proto with debug information? */
> int i;
> TValue v;
> setbtvalue(&v); /* boolean 'true' to be the value of all indices */
> if (!p->is_vararg) /* regular function? */
> i = 0; /* consider all instructions */
> else { /* vararg function */
> lua_assert(GET_OPCODE(p->code[0]) == OP_VARARGPREP);
> currentline = nextline(p, currentline, 0);
> i = 1; /* skip first instruction (OP_VARARGPREP) */
> }
> for (; i < p->sizelineinfo; i++) { /* for each instruction */
> currentline = nextline(p, currentline, i); /* get its line */
> luaH_setint(L, t, currentline, &v); /* table[line] = true */
> }
342c344
< if (noLuaClosure(f)) {
---
> if (!LuaClosure(f)) {
420,453d421
< static const char *getobjname (const Proto *p, int lastpc, int reg,
< const char **name);
<
<
< /*
< ** Find a "name" for the constant 'c'.
< */
< static void kname (const Proto *p, int c, const char **name) {
< TValue *kvalue = &p->k[c];
< *name = (ttisstring(kvalue)) ? svalue(kvalue) : "?";
< }
<
<
< /*
< ** Find a "name" for the register 'c'.
< */
< static void rname (const Proto *p, int pc, int c, const char **name) {
< const char *what = getobjname(p, pc, c, name); /* search for 'c' */
< if (!(what && *what == 'c')) /* did not find a constant name? */
< *name = "?";
< }
<
<
< /*
< ** Find a "name" for a 'C' value in an RK instruction.
< */
< static void rkname (const Proto *p, int pc, Instruction i, const char **name) {
< int c = GETARG_C(i); /* key index */
< if (GETARG_k(i)) /* is 'c' a constant? */
< kname(p, c, name);
< else /* 'c' is a register */
< rname(p, pc, c, name);
< }
<
512,513c480
< ** Check whether table being indexed by instruction 'i' is the
< ** environment '_ENV'
---
> ** Find a "name" for the constant 'c'.
515,522c482,491
< static const char *gxf (const Proto *p, int pc, Instruction i, int isup) {
< int t = GETARG_B(i); /* table index */
< const char *name; /* name of indexed variable */
< if (isup) /* is an upvalue? */
< name = upvalname(p, t);
< else
< getobjname(p, pc, t, &name);
< return (name && strcmp(name, LUA_ENV) == 0) ? "global" : "field";
---
> static const char *kname (const Proto *p, int index, const char **name) {
> TValue *kvalue = &p->k[index];
> if (ttisstring(kvalue)) {
> *name = getstr(tsvalue(kvalue));
> return "constant";
> }
> else {
> *name = "?";
> return NULL;
> }
526,529c495,498
< static const char *getobjname (const Proto *p, int lastpc, int reg,
< const char **name) {
< int pc;
< *name = luaF_getlocalname(p, reg + 1, lastpc);
---
> static const char *basicgetobjname (const Proto *p, int *ppc, int reg,
> const char **name) {
> int pc = *ppc;
> *name = luaF_getlocalname(p, reg + 1, pc);
533c502
< pc = findsetreg(p, lastpc, reg);
---
> *ppc = pc = findsetreg(p, pc, reg);
541c510
< return getobjname(p, pc, b, name); /* get name for 'b' */
---
> return basicgetobjname(p, ppc, b, name); /* get name for 'b' */
543a513,574
> case OP_GETUPVAL: {
> *name = upvalname(p, GETARG_B(i));
> return "upvalue";
> }
> case OP_LOADK: return kname(p, GETARG_Bx(i), name);
> case OP_LOADKX: return kname(p, GETARG_Ax(p->code[pc + 1]), name);
> default: break;
> }
> }
> return NULL; /* could not find reasonable name */
> }
>
>
> /*
> ** Find a "name" for the register 'c'.
> */
> static void rname (const Proto *p, int pc, int c, const char **name) {
> const char *what = basicgetobjname(p, &pc, c, name); /* search for 'c' */
> if (!(what && *what == 'c')) /* did not find a constant name? */
> *name = "?";
> }
>
>
> /*
> ** Find a "name" for a 'C' value in an RK instruction.
> */
> static void rkname (const Proto *p, int pc, Instruction i, const char **name) {
> int c = GETARG_C(i); /* key index */
> if (GETARG_k(i)) /* is 'c' a constant? */
> kname(p, c, name);
> else /* 'c' is a register */
> rname(p, pc, c, name);
> }
>
>
> /*
> ** Check whether table being indexed by instruction 'i' is the
> ** environment '_ENV'
> */
> static const char *isEnv (const Proto *p, int pc, Instruction i, int isup) {
> int t = GETARG_B(i); /* table index */
> const char *name; /* name of indexed variable */
> if (isup) /* is 't' an upvalue? */
> name = upvalname(p, t);
> else /* 't' is a register */
> basicgetobjname(p, &pc, t, &name);
> return (name && strcmp(name, LUA_ENV) == 0) ? "global" : "field";
> }
>
>
> /*
> ** Extend 'basicgetobjname' to handle table accesses
> */
> static const char *getobjname (const Proto *p, int lastpc, int reg,
> const char **name) {
> const char *kind = basicgetobjname(p, &lastpc, reg, name);
> if (kind != NULL)
> return kind;
> else if (lastpc != -1) { /* could find instruction? */
> Instruction i = p->code[lastpc];
> OpCode op = GET_OPCODE(i);
> switch (op) {
547c578
< return gxf(p, pc, i, 1);
---
> return isEnv(p, lastpc, i, 1);
551,552c582,583
< rname(p, pc, k, name);
< return gxf(p, pc, i, 0);
---
> rname(p, lastpc, k, name);
> return isEnv(p, lastpc, i, 0);
561,575c592
< return gxf(p, pc, i, 0);
< }
< case OP_GETUPVAL: {
< *name = upvalname(p, GETARG_B(i));
< return "upvalue";
< }
< case OP_LOADK:
< case OP_LOADKX: {
< int b = (op == OP_LOADK) ? GETARG_Bx(i)
< : GETARG_Ax(p->code[pc + 1]);
< if (ttisstring(&p->k[b])) {
< *name = svalue(&p->k[b]);
< return "constant";
< }
< break;
---
> return isEnv(p, lastpc, i, 0);
578c595
< rkname(p, pc, i, name);
---
> rkname(p, lastpc, i, name);
630c647
< *name = getstr(G(L)->tmname[tm]) + 2;
---
> *name = getshrstr(G(L)->tmname[tm]) + 2;
868a886,907
> ** Traces Lua calls. If code is running the first instruction of a function,
> ** and function is not vararg, and it is not coming from an yield,
> ** calls 'luaD_hookcall'. (Vararg functions will call 'luaD_hookcall'
> ** after adjusting its variable arguments; otherwise, they could call
> ** a line/count hook before the call hook. Functions coming from
> ** an yield already called 'luaD_hookcall' before yielding.)
> */
> int luaG_tracecall (lua_State *L) {
> CallInfo *ci = L->ci;
> Proto *p = ci_func(ci)->p;
> ci->u.l.trap = 1; /* ensure hooks will be checked */
> if (ci->u.l.savedpc == p->code) { /* first instruction (not resuming)? */
> if (p->is_vararg)
> return 0; /* hooks will start at VARARGPREP instruction */
> else if (!(ci->callstatus & CIST_HOOKYIELD)) /* not yieded? */
> luaD_hookcall(L, ci); /* check 'call' hook */
> }
> return 1; /* keep 'trap' on */
> }
>
>
> /*
891c930
< counthook = (--L->hookcount == 0 && (mask & LUA_MASKCOUNT));
---
> counthook = (mask & LUA_MASKCOUNT) && (--L->hookcount == 0);
896c935
< if (ci->callstatus & CIST_HOOKYIELD) { /* called hook last time? */
---
> if (ci->callstatus & CIST_HOOKYIELD) { /* hook yielded last time? */
918d956
< ci->u.l.savedpc--; /* undo increment (resume will increment it again) */
diff -r lua-5.4.6/src/ldebug.h lua-5.4.7/src/ldebug.h
60a61
> LUAI_FUNC int luaG_tracecall (lua_State *L);
diff -r lua-5.4.6/src/ldo.c lua-5.4.7/src/ldo.c
412c412
< StkId luaD_tryfuncTM (lua_State *L, StkId func) {
---
> static StkId tryfuncTM (lua_State *L, StkId func) {
571c571
< func = luaD_tryfuncTM(L, func); /* try to get '__call' metamethod */
---
> func = tryfuncTM(L, func); /* try to get '__call' metamethod */
612c612
< func = luaD_tryfuncTM(L, func); /* try to get '__call' metamethod */
---
> func = tryfuncTM(L, func); /* try to get '__call' metamethod */
794a795,798
> /* undo increment made by 'luaG_traceexec': instruction was not
> executed yet */
> lua_assert(ci->callstatus & CIST_HOOKYIELD);
> ci->u.l.savedpc--;
diff -r lua-5.4.6/src/ldo.h lua-5.4.7/src/ldo.h
74d73
< LUAI_FUNC StkId luaD_tryfuncTM (lua_State *L, StkId func);
diff -r lua-5.4.6/src/lgc.c lua-5.4.7/src/lgc.c
544a545
> TString *smode;
546,548c547,550
< if (mode && ttisstring(mode) && /* is there a weak mode? */
< (cast_void(weakkey = strchr(svalue(mode), 'k')),
< cast_void(weakvalue = strchr(svalue(mode), 'v')),
---
> if (mode && ttisshrstring(mode) && /* is there a weak mode? */
> (cast_void(smode = tsvalue(mode)),
> cast_void(weakkey = strchr(getshrstr(smode), 'k')),
> cast_void(weakvalue = strchr(getshrstr(smode), 'v')),
641c643,645
< for (; o < th->stack_last.p + EXTRA_STACK; o++)
---
> if (!g->gcemergency)
> luaD_shrinkstack(th); /* do not change stack in emergency cycle */
> for (o = th->top.p; o < th->stack_last.p + EXTRA_STACK; o++)
649,650d652
< else if (!g->gcemergency)
< luaD_shrinkstack(th); /* do not change stack in emergency cycle */
1412c1414
< g->GCestimate = gettotalbytes(g); /* first estimate */;
---
> g->GCestimate = gettotalbytes(g); /* first estimate */
1607c1609
< g->GCestimate = gettotalbytes(g); /* first estimate */;
---
> g->GCestimate = gettotalbytes(g); /* first estimate */
1712a1715,1716
> luaC_runtilstate(L, bitmask(GCSpropagate)); /* start new cycle */
> g->gcstate = GCSenteratomic; /* go straight to atomic phase */
diff -r lua-5.4.6/src/liolib.c lua-5.4.7/src/liolib.c
248,249c248,249
< int res = fclose(p->f);
< return luaL_fileresult(L, (res == 0), NULL);
---
> errno = 0;
> return luaL_fileresult(L, (fclose(p->f) == 0), NULL);
274a275
> errno = 0;
294a296
> errno = 0;
302a305
> errno = 0;
569a573
> errno = 0;
662a667
> errno = 0;
681c686,687
< else return luaL_fileresult(L, status, NULL);
---
> else
> return luaL_fileresult(L, status, NULL);
705a712
> errno = 0;
722c729,731
< int res = setvbuf(f, NULL, mode[op], (size_t)sz);
---
> int res;
> errno = 0;
> res = setvbuf(f, NULL, mode[op], (size_t)sz);
729c738,740
< return luaL_fileresult(L, fflush(getiofile(L, IO_OUTPUT)) == 0, NULL);
---
> FILE *f = getiofile(L, IO_OUTPUT);
> errno = 0;
> return luaL_fileresult(L, fflush(f) == 0, NULL);
734c745,747
< return luaL_fileresult(L, fflush(tofile(L)) == 0, NULL);
---
> FILE *f = tofile(L);
> errno = 0;
> return luaL_fileresult(L, fflush(f) == 0, NULL);
776c789
< {"__index", NULL}, /* place holder */
---
> {"__index", NULL}, /* placeholder */
diff -r lua-5.4.6/src/lmathlib.c lua-5.4.7/src/lmathlib.c
251a252,260
> /*
> ** This code uses lots of shifts. ANSI C does not allow shifts greater
> ** than or equal to the width of the type being shifted, so some shifts
> ** are written in convoluted ways to match that restriction. For
> ** preprocessor tests, it assumes a width of 32 bits, so the maximum
> ** shift there is 31 bits.
> */
>
>
273a283
> #define SRand64 long
278a289
> #define SRand64 long long
283a295
> #define SRand64 lua_Integer
322,324d333
< /* must take care to not shift stuff by more than 63 slots */
<
<
328a338,342
> ** Some old Microsoft compilers cannot cast an unsigned long
> ** to a floating-point number, so we use a signed long as an
> ** intermediary. When lua_Number is float or double, the shift ensures
> ** that 'sx' is non negative; in that case, a good compiler will remove
> ** the correction.
334c348
< /* to scale to [0, 1), multiply by scaleFIG = 2^(-FIGS) */
---
> /* 2^(-FIGS) == 2^-1 / 2^(FIGS-1) */
338c352,357
< return (lua_Number)(trim64(x) >> shift64_FIG) * scaleFIG;
---
> SRand64 sx = (SRand64)(trim64(x) >> shift64_FIG);
> lua_Number res = (lua_Number)(sx) * scaleFIG;
> if (sx < 0)
> res += l_mathop(1.0); /* correct the two's complement if negative */
> lua_assert(0 <= res && res < 1);
> return res;
473,474d491
<
< /* must take care to not shift stuff by more than 31 slots */
diff -r lua-5.4.6/src/loadlib.c lua-5.4.7/src/loadlib.c
28,36d27
< ** LUA_IGMARK is a mark to ignore all before it when building the
< ** luaopen_ function name.
< */
< #if !defined (LUA_IGMARK)
< #define LUA_IGMARK "-"
< #endif
<
<
< /*
diff -r lua-5.4.6/src/lobject.c lua-5.4.7/src/lobject.c
545c545
< return svalue(s2v(L->top.p - 1));
---
> return getstr(tsvalue(s2v(L->top.p - 1)));
diff -r lua-5.4.6/src/lobject.h lua-5.4.7/src/lobject.h
389c389
< lu_byte shrlen; /* length for short strings */
---
> lu_byte shrlen; /* length for short strings, 0xFF for long strings */
401c401,402
< ** Get the actual string (array of bytes) from a 'TString'.
---
> ** Get the actual string (array of bytes) from a 'TString'. (Generic
> ** version and specialized versions for long and short strings.)
403c404,406
< #define getstr(ts) ((ts)->contents)
---
> #define getstr(ts) ((ts)->contents)
> #define getlngstr(ts) check_exp((ts)->shrlen == 0xFF, (ts)->contents)
> #define getshrstr(ts) check_exp((ts)->shrlen != 0xFF, (ts)->contents)
406,408d408
< /* get the actual string (array of bytes) from a Lua value */
< #define svalue(o) getstr(tsvalue(o))
<
410,413c410,411
< #define tsslen(s) ((s)->tt == LUA_VSHRSTR ? (s)->shrlen : (s)->u.lnglen)
<
< /* get string length from 'TValue *o' */
< #define vslen(o) tsslen(tsvalue(o))
---
> #define tsslen(s) \
> ((s)->shrlen != 0xFF ? (s)->shrlen : (s)->u.lnglen)
diff -r lua-5.4.6/src/lopcodes.h lua-5.4.7/src/lopcodes.h
213c213
< OP_GETTABUP,/* A B C R[A] := UpValue[B][K[C]:string] */
---
> OP_GETTABUP,/* A B C R[A] := UpValue[B][K[C]:shortstring] */
216c216
< OP_GETFIELD,/* A B C R[A] := R[B][K[C]:string] */
---
> OP_GETFIELD,/* A B C R[A] := R[B][K[C]:shortstring] */
218c218
< OP_SETTABUP,/* A B C UpValue[A][K[B]:string] := RK(C) */
---
> OP_SETTABUP,/* A B C UpValue[A][K[B]:shortstring] := RK(C) */
221c221
< OP_SETFIELD,/* A B C R[A][K[B]:string] := RK(C) */
---
> OP_SETFIELD,/* A B C R[A][K[B]:shortstring] := RK(C) */
diff -r lua-5.4.6/src/loslib.c lua-5.4.7/src/loslib.c
157a158
> errno = 0;
164a166
> errno = 0;
diff -r lua-5.4.6/src/lparser.c lua-5.4.7/src/lparser.c
1025c1025
< static void funcargs (LexState *ls, expdesc *f, int line) {
---
> static void funcargs (LexState *ls, expdesc *f) {
1028a1029
> int line = ls->linenumber;
1066,1067c1067,1068
< fs->freereg = base+1; /* call remove function and arguments and leaves
< (unless changed) one result */
---
> fs->freereg = base+1; /* call removes function and arguments and leaves
> one result (unless changed later) */
1106d1106
< int line = ls->linenumber;
1126c1126
< funcargs(ls, v, line);
---
> funcargs(ls, v);
1131c1131
< funcargs(ls, v, line);
---
> funcargs(ls, v);
diff -r lua-5.4.6/src/lstate.c lua-5.4.7/src/lstate.c
122c122
< void luaE_freeCI (lua_State *L) {
---
> static void freeCI (lua_State *L) {
207c207
< luaE_freeCI(L);
---
> freeCI(L);
436c436
< ? svalue(errobj)
---
> ? getstr(tsvalue(errobj))
diff -r lua-5.4.6/src/lstate.h lua-5.4.7/src/lstate.h
184c184
< volatile l_signalT trap;
---
> volatile l_signalT trap; /* function is tracing lines/counts */
399d398
< LUAI_FUNC void luaE_freeCI (lua_State *L);
diff -r lua-5.4.6/src/lstring.c lua-5.4.7/src/lstring.c
39c39
< (memcmp(getstr(a), getstr(b), len) == 0)); /* equal contents */
---
> (memcmp(getlngstr(a), getlngstr(b), len) == 0)); /* equal contents */
55c55
< ts->hash = luaS_hash(getstr(ts), len, ts->hash);
---
> ts->hash = luaS_hash(getlngstr(ts), len, ts->hash);
159a160
> ts->shrlen = 0xFF; /* signals that it is a long string */
196c197
< if (l == ts->shrlen && (memcmp(str, getstr(ts), l * sizeof(char)) == 0)) {
---
> if (l == ts->shrlen && (memcmp(str, getshrstr(ts), l * sizeof(char)) == 0)) {
209d209
< memcpy(getstr(ts), str, l * sizeof(char));
210a211
> memcpy(getshrstr(ts), str, l * sizeof(char));
226c227
< if (l_unlikely(l >= (MAX_SIZE - sizeof(TString))/sizeof(char)))
---
> if (l_unlikely(l * sizeof(char) >= (MAX_SIZE - sizeof(TString))))
229c230
< memcpy(getstr(ts), str, l * sizeof(char));
---
> memcpy(getlngstr(ts), str, l * sizeof(char));
diff -r lua-5.4.6/src/ltable.c lua-5.4.7/src/ltable.c
255c255
< /* compute the smallest power of 2 not smaller than 'n' */
---
> /* compute the smallest power of 2 not smaller than 'size' */
665c665,666
< void luaH_newkey (lua_State *L, Table *t, const TValue *key, TValue *value) {
---
> static void luaH_newkey (lua_State *L, Table *t, const TValue *key,
> TValue *value) {
724,728c725,743
< ** directly from the array part. Otherwise, if 'alimit' is not equal to
< ** the real size of the array, key still can be in the array part. In
< ** this case, try to avoid a call to 'luaH_realasize' when key is just
< ** one more than the limit (so that it can be incremented without
< ** changing the real size of the array).
---
> ** directly from the array part. Otherwise, if 'alimit' is not
> ** the real size of the array, the key still can be in the array part.
> ** In this case, do the "Xmilia trick" to check whether 'key-1' is
> ** smaller than the real size.
> ** The trick works as follow: let 'p' be an integer such that
> ** '2^(p+1) >= alimit > 2^p', or '2^(p+1) > alimit-1 >= 2^p'.
> ** That is, 2^(p+1) is the real size of the array, and 'p' is the highest
> ** bit on in 'alimit-1'. What we have to check becomes 'key-1 < 2^(p+1)'.
> ** We compute '(key-1) & ~(alimit-1)', which we call 'res'; it will
> ** have the 'p' bit cleared. If the key is outside the array, that is,
> ** 'key-1 >= 2^(p+1)', then 'res' will have some bit on higher than 'p',
> ** therefore it will be larger or equal to 'alimit', and the check
> ** will fail. If 'key-1 < 2^(p+1)', then 'res' has no bit on higher than
> ** 'p', and as the bit 'p' itself was cleared, 'res' will be smaller
> ** than 2^p, therefore smaller than 'alimit', and the check succeeds.
> ** As special cases, when 'alimit' is 0 the condition is trivially false,
> ** and when 'alimit' is 1 the condition simplifies to 'key-1 < alimit'.
> ** If key is 0 or negative, 'res' will have its higher bit on, so that
> ** if cannot be smaller than alimit.
731c746,747
< if (l_castS2U(key) - 1u < t->alimit) /* 'key' in [1, t->alimit]? */
---
> lua_Unsigned alimit = t->alimit;
> if (l_castS2U(key) - 1u < alimit) /* 'key' in [1, t->alimit]? */
733,735c749,750
< else if (!limitequalsasize(t) && /* key still may be in the array part? */
< (l_castS2U(key) == t->alimit + 1 ||
< l_castS2U(key) - 1u < luaH_realasize(t))) {
---
> else if (!isrealasize(t) && /* key still may be in the array part? */
> (((l_castS2U(key) - 1u) & ~(alimit - 1u)) < alimit)) {
739c754
< else {
---
> else { /* key is not in the array part; check the hash */
diff -r lua-5.4.6/src/ltable.h lua-5.4.7/src/ltable.h
44,45d43
< LUAI_FUNC void luaH_newkey (lua_State *L, Table *t, const TValue *key,
< TValue *value);
diff -r lua-5.4.6/src/ltm.h lua-5.4.7/src/ltm.h
12d11
< #include "lstate.h"
99,100c98,99
< CallInfo *ci, const Proto *p);
< LUAI_FUNC void luaT_getvarargs (lua_State *L, CallInfo *ci,
---
> struct CallInfo *ci, const Proto *p);
> LUAI_FUNC void luaT_getvarargs (lua_State *L, struct CallInfo *ci,
diff -r lua-5.4.6/src/lua.c lua-5.4.7/src/lua.c
118,119c118
< ** message on the top of the stack. It assumes that the error object
< ** is a string, as it was either generated by Lua or by 'msghandler'.
---
> ** message on the top of the stack.
123a123,124
> if (msg == NULL)
> msg = "(error message not a string)";
212a214,215
> ** If there is no explicit modname and globname contains a '-', cut
> ** the suffix after '-' (the "version") to make the global name.
215a219
> char *suffix = NULL;
217c221
< if (modname == NULL) /* no explicit name? */
---
> if (modname == NULL) { /* no explicit name? */
218a223,224
> suffix = strchr(modname, *LUA_IGMARK); /* look for a suffix mark */
> }
226c232,234
< if (status == LUA_OK)
---
> if (status == LUA_OK) {
> if (suffix != NULL) /* is there a suffix mark? */
> *suffix = '\0'; /* remove suffix from global name */
227a236
> }
diff -r lua-5.4.6/src/lua.h lua-5.4.7/src/lua.h
21c21
< #define LUA_VERSION_RELEASE "6"
---
> #define LUA_VERSION_RELEASE "7"
24c24
< #define LUA_VERSION_RELEASE_NUM (LUA_VERSION_NUM * 100 + 6)
---
> #define LUA_VERSION_RELEASE_NUM (LUA_VERSION_NUM * 100 + 7)
28c28
< #define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2023 Lua.org, PUC-Rio"
---
> #define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2024 Lua.org, PUC-Rio"
500c500
< * Copyright (C) 1994-2023 Lua.org, PUC-Rio.
---
> * Copyright (C) 1994-2024 Lua.org, PUC-Rio.
diff -r lua-5.4.6/src/luaconf.h lua-5.4.7/src/luaconf.h
259a260,268
>
> /*
> ** LUA_IGMARK is a mark to ignore all after it when building the
> ** module name (e.g., used to build the luaopen_ function name).
> ** Typically, the suffix after the mark is the module version,
> ** as in "mod-v1.2.so".
> */
> #define LUA_IGMARK "-"
>
diff -r lua-5.4.6/src/lundump.c lua-5.4.7/src/lundump.c
84c84
< return loadUnsigned(S, ~(size_t)0);
---
> return loadUnsigned(S, MAX_SIZET);
125c125
< loadVector(S, getstr(ts), size); /* load directly in final place */
---
> loadVector(S, getlngstr(ts), size); /* load directly in final place */
diff -r lua-5.4.6/src/lundump.h lua-5.4.7/src/lundump.h
24,25c24
< #define MYINT(s) (s[0]-'0') /* assume one-digit numerals */
< #define LUAC_VERSION (MYINT(LUA_VERSION_MAJOR)*16+MYINT(LUA_VERSION_MINOR))
---
> #define LUAC_VERSION (((LUA_VERSION_NUM / 100) * 16) + LUA_VERSION_NUM % 100)
diff -r lua-5.4.6/src/lvm.c lua-5.4.7/src/lvm.c
94,95c94,97
< else
< return (luaO_str2num(svalue(obj), result) == vslen(obj) + 1);
---
> else {
> TString *st = tsvalue(obj);
> return (luaO_str2num(getstr(st), result) == tsslen(st) + 1);
> }
369,370c371,372
< ** Compare two strings 'ls' x 'rs', returning an integer less-equal-
< ** -greater than zero if 'ls' is less-equal-greater than 'rs'.
---
> ** Compare two strings 'ts1' x 'ts2', returning an integer less-equal-
> ** -greater than zero if 'ts1' is less-equal-greater than 'ts2'.
372,379c374,382
< ** and it uses 'strcoll' (to respect locales) for each segments
< ** of the strings.
< */
< static int l_strcmp (const TString *ls, const TString *rs) {
< const char *l = getstr(ls);
< size_t ll = tsslen(ls);
< const char *r = getstr(rs);
< size_t lr = tsslen(rs);
---
> ** and it uses 'strcoll' (to respect locales) for each segment
> ** of the strings. Note that segments can compare equal but still
> ** have different lengths.
> */
> static int l_strcmp (const TString *ts1, const TString *ts2) {
> const char *s1 = getstr(ts1);
> size_t rl1 = tsslen(ts1); /* real length */
> const char *s2 = getstr(ts2);
> size_t rl2 = tsslen(ts2);
381c384
< int temp = strcoll(l, r);
---
> int temp = strcoll(s1, s2);
385,392c388,396
< size_t len = strlen(l); /* index of first '\0' in both strings */
< if (len == lr) /* 'rs' is finished? */
< return (len == ll) ? 0 : 1; /* check 'ls' */
< else if (len == ll) /* 'ls' is finished? */
< return -1; /* 'ls' is less than 'rs' ('rs' is not finished) */
< /* both strings longer than 'len'; go on comparing after the '\0' */
< len++;
< l += len; ll -= len; r += len; lr -= len;
---
> size_t zl1 = strlen(s1); /* index of first '\0' in 's1' */
> size_t zl2 = strlen(s2); /* index of first '\0' in 's2' */
> if (zl2 == rl2) /* 's2' is finished? */
> return (zl1 == rl1) ? 0 : 1; /* check 's1' */
> else if (zl1 == rl1) /* 's1' is finished? */
> return -1; /* 's1' is less than 's2' ('s2' is not finished) */
> /* both strings longer than 'zl'; go on comparing after the '\0' */
> zl1++; zl2++;
> s1 += zl1; rl1 -= zl1; s2 += zl2; rl2 -= zl2;
627,628c631,633
< size_t l = vslen(s2v(top - n)); /* length of string being copied */
< memcpy(buff + tl, svalue(s2v(top - n)), l * sizeof(char));
---
> TString *st = tsvalue(s2v(top - n));
> size_t l = tsslen(st); /* length of string being copied */
> memcpy(buff + tl, getstr(st), l * sizeof(char));
654c659
< size_t tl = vslen(s2v(top - 1));
---
> size_t tl = tsslen(tsvalue(s2v(top - 1)));
658,659c663,664
< size_t l = vslen(s2v(top - n - 1));
< if (l_unlikely(l >= (MAX_SIZE/sizeof(char)) - tl)) {
---
> size_t l = tsslen(tsvalue(s2v(top - n - 1)));
> if (l_unlikely(l >= MAX_SIZE - sizeof(TString) - tl)) {
672c677
< copy2buff(top, n, getstr(ts));
---
> copy2buff(top, n, getlngstr(ts));
1158c1163
< cl = clLvalue(s2v(ci->func.p));
---
> cl = ci_func(ci);
1161,1169c1166,1167
< if (l_unlikely(trap)) {
< if (pc == cl->p->code) { /* first instruction (not resuming)? */
< if (cl->p->is_vararg)
< trap = 0; /* hooks will start after VARARGPREP instruction */
< else /* check 'call' hook */
< luaD_hookcall(L, ci);
< }
< ci->u.l.trap = 1; /* assume trap is on, for now */
< }
---
> if (l_unlikely(trap))
> trap = luaG_tracecall(L);
1256c1254
< TString *key = tsvalue(rc); /* key must be a string */
---
> TString *key = tsvalue(rc); /* key must be a short string */
1299c1297
< TString *key = tsvalue(rc); /* key must be a string */
---
> TString *key = tsvalue(rc); /* key must be a short string */
1312c1310
< TString *key = tsvalue(rb); /* key must be a string */
---
> TString *key = tsvalue(rb); /* key must be a short string */
1355c1353
< TString *key = tsvalue(rb); /* key must be a string */
---
> TString *key = tsvalue(rb); /* key must be a short string */