Skip to content

Commit d651672

Browse files
committed
Update Lua 5.4 to 5.4.1 and bump version to 541.0.0
1 parent f3df462 commit d651672

Some content is hidden

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

61 files changed

+535
-306
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "lua-src"
3-
version = "540.0.1"
3+
version = "541.0.0"
44
authors = ["Aleksandr Orlenko <[email protected]>"]
55
edition = "2018"
66
repository = "https://github.com/khvzak/lua-src-rs"

lua-5.4.0/lapi.c renamed to lua-5.4.1/lapi.c

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,9 @@ static StkId index2stack (lua_State *L, int idx) {
9797

9898
LUA_API int lua_checkstack (lua_State *L, int n) {
9999
int res;
100-
CallInfo *ci = L->ci;
100+
CallInfo *ci;
101101
lua_lock(L);
102+
ci = L->ci;
102103
api_check(L, n >= 0, "negative 'n'");
103104
if (L->stack_last - L->top > n) /* stack large enough? */
104105
res = 1; /* yes; check is OK */
@@ -170,10 +171,12 @@ LUA_API int lua_gettop (lua_State *L) {
170171

171172

172173
LUA_API void lua_settop (lua_State *L, int idx) {
173-
CallInfo *ci = L->ci;
174-
StkId func = ci->func;
174+
CallInfo *ci;
175+
StkId func;
175176
ptrdiff_t diff; /* difference for new top */
176177
lua_lock(L);
178+
ci = L->ci;
179+
func = ci->func;
177180
if (idx >= 0) {
178181
api_check(L, idx <= ci->top - (func + 1), "new top too large");
179182
diff = ((func + 1) + idx) - L->top;
@@ -376,20 +379,22 @@ LUA_API int lua_toboolean (lua_State *L, int idx) {
376379

377380

378381
LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) {
379-
TValue *o = index2value(L, idx);
382+
TValue *o;
383+
lua_lock(L);
384+
o = index2value(L, idx);
380385
if (!ttisstring(o)) {
381386
if (!cvt2str(o)) { /* not convertible? */
382387
if (len != NULL) *len = 0;
388+
lua_unlock(L);
383389
return NULL;
384390
}
385-
lua_lock(L); /* 'luaO_tostring' may create a new string */
386391
luaO_tostring(L, o);
387392
luaC_checkGC(L);
388393
o = index2value(L, idx); /* previous call may reallocate the stack */
389-
lua_unlock(L);
390394
}
391395
if (len != NULL)
392396
*len = vslen(o);
397+
lua_unlock(L);
393398
return svalue(o);
394399
}
395400

@@ -563,6 +568,7 @@ LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
563568
while (n--) {
564569
setobj2n(L, &cl->upvalue[n], s2v(L->top + n));
565570
/* does not need barrier because closure is white */
571+
lua_assert(iswhite(cl));
566572
}
567573
setclCvalue(L, s2v(L->top), cl);
568574
api_incr_top(L);
@@ -624,8 +630,9 @@ static int auxgetstr (lua_State *L, const TValue *t, const char *k) {
624630

625631

626632
LUA_API int lua_getglobal (lua_State *L, const char *name) {
627-
Table *reg = hvalue(&G(L)->l_registry);
633+
Table *reg;
628634
lua_lock(L);
635+
reg = hvalue(&G(L)->l_registry);
629636
return auxgetstr(L, luaH_getint(reg, LUA_RIDX_GLOBALS), name);
630637
}
631638

@@ -804,8 +811,9 @@ static void auxsetstr (lua_State *L, const TValue *t, const char *k) {
804811

805812

806813
LUA_API void lua_setglobal (lua_State *L, const char *name) {
807-
Table *reg = hvalue(&G(L)->l_registry);
814+
Table *reg;
808815
lua_lock(L); /* unlock done in 'auxsetstr' */
816+
reg = hvalue(&G(L)->l_registry);
809817
auxsetstr(L, luaH_getint(reg, LUA_RIDX_GLOBALS), name);
810818
}
811819

@@ -1093,8 +1101,9 @@ LUA_API int lua_status (lua_State *L) {
10931101
LUA_API int lua_gc (lua_State *L, int what, ...) {
10941102
va_list argp;
10951103
int res = 0;
1096-
global_State *g = G(L);
1104+
global_State *g;
10971105
lua_lock(L);
1106+
g = G(L);
10981107
va_start(argp, what);
10991108
switch (what) {
11001109
case LUA_GCSTOP: {
@@ -1194,9 +1203,15 @@ LUA_API int lua_gc (lua_State *L, int what, ...) {
11941203

11951204

11961205
LUA_API int lua_error (lua_State *L) {
1206+
TValue *errobj;
11971207
lua_lock(L);
1208+
errobj = s2v(L->top - 1);
11981209
api_checknelems(L, 1);
1199-
luaG_errormsg(L);
1210+
/* error object is the memory error message? */
1211+
if (ttisshrstring(errobj) && eqshrstr(tsvalue(errobj), G(L)->memerrmsg))
1212+
luaM_error(L); /* raise a memory error */
1213+
else
1214+
luaG_errormsg(L); /* raise a regular error */
12001215
/* code unreachable; will unlock when control actually leaves the kernel */
12011216
return 0; /* to avoid warnings */
12021217
}
@@ -1238,14 +1253,12 @@ LUA_API void lua_toclose (lua_State *L, int idx) {
12381253
LUA_API void lua_concat (lua_State *L, int n) {
12391254
lua_lock(L);
12401255
api_checknelems(L, n);
1241-
if (n >= 2) {
1256+
if (n > 0)
12421257
luaV_concat(L, n);
1243-
}
1244-
else if (n == 0) { /* push empty string */
1245-
setsvalue2s(L, L->top, luaS_newlstr(L, "", 0));
1258+
else { /* nothing to concatenate */
1259+
setsvalue2s(L, L->top, luaS_newlstr(L, "", 0)); /* push empty string */
12461260
api_incr_top(L);
12471261
}
1248-
/* else n == 1; nothing to do */
12491262
luaC_checkGC(L);
12501263
lua_unlock(L);
12511264
}
File renamed without changes.

lua-5.4.0/lauxlib.c renamed to lua-5.4.1/lauxlib.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,10 @@ static void *resizebox (lua_State *L, int idx, size_t newsize) {
475475
lua_Alloc allocf = lua_getallocf(L, &ud);
476476
UBox *box = (UBox *)lua_touserdata(L, idx);
477477
void *temp = allocf(ud, box->box, box->bsize, newsize);
478-
if (temp == NULL && newsize > 0) /* allocation error? */
479-
luaL_error(L, "not enough memory");
478+
if (temp == NULL && newsize > 0) { /* allocation error? */
479+
lua_pushliteral(L, "not enough memory");
480+
lua_error(L); /* raise a memory error */
481+
}
480482
box->box = temp;
481483
box->bsize = newsize;
482484
return temp;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

lua-5.4.0/lcorolib.c renamed to lua-5.4.1/lcorolib.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,12 @@ static int luaB_coresume (lua_State *L) {
7373
static int luaB_auxwrap (lua_State *L) {
7474
lua_State *co = lua_tothread(L, lua_upvalueindex(1));
7575
int r = auxresume(L, co, lua_gettop(L));
76-
if (r < 0) {
76+
if (r < 0) { /* error? */
7777
int stat = lua_status(co);
78-
if (stat != LUA_OK && stat != LUA_YIELD)
79-
lua_resetthread(co); /* close variables in case of errors */
80-
if (lua_type(L, -1) == LUA_TSTRING) { /* error object is a string? */
78+
if (stat != LUA_OK && stat != LUA_YIELD) /* error in the coroutine? */
79+
lua_resetthread(co); /* close its tbc variables */
80+
if (stat != LUA_ERRMEM && /* not a memory error and ... */
81+
lua_type(L, -1) == LUA_TSTRING) { /* ... error object is a string? */
8182
luaL_where(L, 1); /* add extra info, if available */
8283
lua_insert(L, -2);
8384
lua_concat(L, 2);
File renamed without changes.

0 commit comments

Comments
 (0)