Skip to content

Commit 86e6abb

Browse files
committed
Lua 5.4.8
1 parent 3576449 commit 86e6abb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+46
-23
lines changed

lua-5.4.7/lapi.c renamed to lua-5.4.8/lapi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1343,7 +1343,7 @@ void lua_warning (lua_State *L, const char *msg, int tocont) {
13431343
LUA_API void *lua_newuserdatauv (lua_State *L, size_t size, int nuvalue) {
13441344
Udata *u;
13451345
lua_lock(L);
1346-
api_check(L, 0 <= nuvalue && nuvalue < USHRT_MAX, "invalid value");
1346+
api_check(L, 0 <= nuvalue && nuvalue < SHRT_MAX, "invalid value");
13471347
u = luaS_newudata(L, size, nuvalue);
13481348
setuvalue(L, s2v(L->top.p), u);
13491349
api_incr_top(L);
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

lua-5.4.7/lcode.c renamed to lua-5.4.8/lcode.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#define MAXREGS 255
3636

3737

38+
/* (note that expressions VJMP also have jumps.) */
3839
#define hasjumps(e) ((e)->t != (e)->f)
3940

4041

@@ -985,7 +986,7 @@ void luaK_exp2anyregup (FuncState *fs, expdesc *e) {
985986
** or it is a constant.
986987
*/
987988
void luaK_exp2val (FuncState *fs, expdesc *e) {
988-
if (hasjumps(e))
989+
if (e->k == VJMP || hasjumps(e))
989990
luaK_exp2anyreg(fs, e);
990991
else
991992
luaK_dischargevars(fs, e);
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

lua-5.4.7/ldebug.c renamed to lua-5.4.8/ldebug.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
static const char *funcnamefromcall (lua_State *L, CallInfo *ci,
3838
const char **name);
3939

40+
static const char strlocal[] = "local";
41+
static const char strupval[] = "upvalue";
42+
4043

4144
static int currentpc (CallInfo *ci) {
4245
lua_assert(isLua(ci));
@@ -497,7 +500,7 @@ static const char *basicgetobjname (const Proto *p, int *ppc, int reg,
497500
int pc = *ppc;
498501
*name = luaF_getlocalname(p, reg + 1, pc);
499502
if (*name) /* is a local? */
500-
return "local";
503+
return strlocal;
501504
/* else try symbolic execution */
502505
*ppc = pc = findsetreg(p, pc, reg);
503506
if (pc != -1) { /* could find instruction? */
@@ -512,7 +515,7 @@ static const char *basicgetobjname (const Proto *p, int *ppc, int reg,
512515
}
513516
case OP_GETUPVAL: {
514517
*name = upvalname(p, GETARG_B(i));
515-
return "upvalue";
518+
return strupval;
516519
}
517520
case OP_LOADK: return kname(p, GETARG_Bx(i), name);
518521
case OP_LOADKX: return kname(p, GETARG_Ax(p->code[pc + 1]), name);
@@ -547,15 +550,21 @@ static void rkname (const Proto *p, int pc, Instruction i, const char **name) {
547550

548551
/*
549552
** Check whether table being indexed by instruction 'i' is the
550-
** environment '_ENV'
553+
** environment '_ENV'. If the table is an upvalue, get its name;
554+
** otherwise, find some "name" for the table and check whether
555+
** that name is the name of a local variable (and not, for instance,
556+
** a string). Then check that, if there is a name, it is '_ENV'.
551557
*/
552558
static const char *isEnv (const Proto *p, int pc, Instruction i, int isup) {
553559
int t = GETARG_B(i); /* table index */
554560
const char *name; /* name of indexed variable */
555561
if (isup) /* is 't' an upvalue? */
556562
name = upvalname(p, t);
557-
else /* 't' is a register */
558-
basicgetobjname(p, &pc, t, &name);
563+
else { /* 't' is a register */
564+
const char *what = basicgetobjname(p, &pc, t, &name);
565+
if (what != strlocal && what != strupval)
566+
name = NULL; /* cannot be the variable _ENV */
567+
}
559568
return (name && strcmp(name, LUA_ENV) == 0) ? "global" : "field";
560569
}
561570

@@ -701,7 +710,7 @@ static const char *getupvalname (CallInfo *ci, const TValue *o,
701710
for (i = 0; i < c->nupvalues; i++) {
702711
if (c->upvals[i]->v.p == o) {
703712
*name = upvalname(c->p, i);
704-
return "upvalue";
713+
return strupval;
705714
}
706715
}
707716
return NULL;
File renamed without changes.

lua-5.4.7/ldo.c renamed to lua-5.4.8/ldo.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@ void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop) {
9494
setsvalue2s(L, oldtop, G(L)->memerrmsg); /* reuse preregistered msg. */
9595
break;
9696
}
97-
case LUA_ERRERR: {
98-
setsvalue2s(L, oldtop, luaS_newliteral(L, "error in error handling"));
99-
break;
100-
}
10197
case LUA_OK: { /* special case only for closing upvalues */
10298
setnilvalue(s2v(oldtop)); /* no error message */
10399
break;
@@ -120,6 +116,7 @@ l_noret luaD_throw (lua_State *L, int errcode) {
120116
else { /* thread has no error handler */
121117
global_State *g = G(L);
122118
errcode = luaE_resetthread(L, errcode); /* close all upvalues */
119+
L->status = errcode;
123120
if (g->mainthread->errorJmp) { /* main thread has a handler? */
124121
setobjs2s(L, g->mainthread->top.p++, L->top.p - 1); /* copy error obj. */
125122
luaD_throw(g->mainthread, errcode); /* re-throw in main thread */
@@ -198,6 +195,16 @@ static void correctstack (lua_State *L) {
198195
/* some space for error handling */
199196
#define ERRORSTACKSIZE (LUAI_MAXSTACK + 200)
200197

198+
199+
/* raise an error while running the message handler */
200+
l_noret luaD_errerr (lua_State *L) {
201+
TString *msg = luaS_newliteral(L, "error in error handling");
202+
setsvalue2s(L, L->top.p, msg);
203+
L->top.p++; /* assume EXTRA_STACK */
204+
luaD_throw(L, LUA_ERRERR);
205+
}
206+
207+
201208
/*
202209
** Reallocate the stack to a new size, correcting all pointers into it.
203210
** In ISO C, any pointer use after the pointer has been deallocated is
@@ -247,7 +254,7 @@ int luaD_growstack (lua_State *L, int n, int raiseerror) {
247254
a stack error; cannot grow further than that. */
248255
lua_assert(stacksize(L) == ERRORSTACKSIZE);
249256
if (raiseerror)
250-
luaD_throw(L, LUA_ERRERR); /* error inside message handler */
257+
luaD_errerr(L); /* error inside message handler */
251258
return 0; /* if not 'raiseerror', just signal it */
252259
}
253260
else if (n < LUAI_MAXSTACK) { /* avoids arithmetic overflows */

lua-5.4.7/ldo.h renamed to lua-5.4.8/ldo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
/* type of protected functions, to be ran by 'runprotected' */
6161
typedef void (*Pfunc) (lua_State *L, void *ud);
6262

63+
LUAI_FUNC l_noret luaD_errerr (lua_State *L);
6364
LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop);
6465
LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name,
6566
const char *mode);
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

lua-5.4.7/lparser.c renamed to lua-5.4.8/lparser.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ static int new_localvar (LexState *ls, TString *name) {
198198
checklimit(fs, dyd->actvar.n + 1 - fs->firstlocal,
199199
MAXVARS, "local variables");
200200
luaM_growvector(L, dyd->actvar.arr, dyd->actvar.n + 1,
201-
dyd->actvar.size, Vardesc, USHRT_MAX, "local variables");
201+
dyd->actvar.size, Vardesc, SHRT_MAX, "local variables");
202202
var = &dyd->actvar.arr[dyd->actvar.n++];
203203
var->vd.kind = VDKREG; /* default */
204204
var->vd.name = name;
@@ -849,12 +849,11 @@ static void recfield (LexState *ls, ConsControl *cc) {
849849
FuncState *fs = ls->fs;
850850
int reg = ls->fs->freereg;
851851
expdesc tab, key, val;
852-
if (ls->t.token == TK_NAME) {
853-
checklimit(fs, cc->nh, MAX_INT, "items in a constructor");
852+
if (ls->t.token == TK_NAME)
854853
codename(ls, &key);
855-
}
856854
else /* ls->t.token == '[' */
857855
yindex(ls, &key);
856+
checklimit(fs, cc->nh, MAX_INT, "items in a constructor");
858857
cc->nh++;
859858
checknext(ls, '=');
860859
tab = *cc->t;
File renamed without changes.
File renamed without changes.

lua-5.4.7/lstate.c renamed to lua-5.4.8/lstate.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ void luaE_checkcstack (lua_State *L) {
166166
if (getCcalls(L) == LUAI_MAXCCALLS)
167167
luaG_runerror(L, "C stack overflow");
168168
else if (getCcalls(L) >= (LUAI_MAXCCALLS / 10 * 11))
169-
luaD_throw(L, LUA_ERRERR); /* error while handling stack error */
169+
luaD_errerr(L); /* error while handling stack error */
170170
}
171171

172172

@@ -272,7 +272,9 @@ static void close_state (lua_State *L) {
272272
luaC_freeallobjects(L); /* just collect its objects */
273273
else { /* closing a fully built state */
274274
L->ci = &L->base_ci; /* unwind CallInfo list */
275+
L->errfunc = 0; /* stack unwind can "throw away" the error function */
275276
luaD_closeprotected(L, 1, LUA_OK); /* close all upvalues */
277+
L->top.p = L->stack.p + 1; /* empty the stack to run finalizers */
276278
luaC_freeallobjects(L); /* collect all objects */
277279
luai_userstateclose(L);
278280
}
@@ -328,6 +330,7 @@ int luaE_resetthread (lua_State *L, int status) {
328330
if (status == LUA_YIELD)
329331
status = LUA_OK;
330332
L->status = LUA_OK; /* so it can run __close metamethods */
333+
L->errfunc = 0; /* stack unwind can "throw away" the error function */
331334
status = luaD_closeprotected(L, 1, status);
332335
if (status != LUA_OK) /* errors? */
333336
luaD_seterrorobj(L, status, L->stack.p + 1);
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

lua-5.4.7/lua.h renamed to lua-5.4.8/lua.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818

1919
#define LUA_VERSION_MAJOR "5"
2020
#define LUA_VERSION_MINOR "4"
21-
#define LUA_VERSION_RELEASE "7"
21+
#define LUA_VERSION_RELEASE "8"
2222

2323
#define LUA_VERSION_NUM 504
24-
#define LUA_VERSION_RELEASE_NUM (LUA_VERSION_NUM * 100 + 7)
24+
#define LUA_VERSION_RELEASE_NUM (LUA_VERSION_NUM * 100 + 8)
2525

2626
#define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
2727
#define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE
28-
#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2024 Lua.org, PUC-Rio"
28+
#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2025 Lua.org, PUC-Rio"
2929
#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo, W. Celes"
3030

3131

@@ -497,7 +497,7 @@ struct lua_Debug {
497497

498498

499499
/******************************************************************************
500-
* Copyright (C) 1994-2024 Lua.org, PUC-Rio.
500+
* Copyright (C) 1994-2025 Lua.org, PUC-Rio.
501501
*
502502
* Permission is hereby granted, free of charge, to any person obtaining
503503
* a copy of this software and associated documentation files (the
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

lua-5.4.7/lvm.c renamed to lua-5.4.8/lvm.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,10 @@ void luaV_finishset (lua_State *L, const TValue *t, TValue *key,
339339
lua_assert(isempty(slot)); /* slot must be empty */
340340
tm = fasttm(L, h->metatable, TM_NEWINDEX); /* get metamethod */
341341
if (tm == NULL) { /* no metamethod? */
342+
sethvalue2s(L, L->top.p, h); /* anchor 't' */
343+
L->top.p++; /* assume EXTRA_STACK */
342344
luaH_finishset(L, h, key, slot, val); /* set new value */
345+
L->top.p--;
343346
invalidateTMcache(h);
344347
luaC_barrierback(L, obj2gco(h), val);
345348
return;
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ impl Version {
140140
Lua51 => "lua-5.1.5",
141141
Lua52 => "lua-5.2.4",
142142
Lua53 => "lua-5.3.6",
143-
Lua54 => "lua-5.4.7",
143+
Lua54 => "lua-5.4.8",
144144
}
145145
}
146146

0 commit comments

Comments
 (0)