Skip to content

Commit 78d6ad1

Browse files
committed
Update to Lua 5.3.3
1 parent f64554d commit 78d6ad1

29 files changed

+973
-589
lines changed

lua/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ TO_MAN= lua.1 luac.1
4646

4747
# Lua version and release.
4848
V= 5.3
49-
R= $V.2
49+
R= $V.3
5050

5151
# Targets start here.
5252
all: $(PLAT)

lua/README

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
This is Lua 5.3.2, released on 25 Nov 2015.
2+
This is Lua 5.3.3, released on 30 May 2016.
33

44
For installation instructions, license details, and
55
further information about Lua, see doc/readme.html.

lua/src/lapi.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
** $Id: lapi.c,v 2.257 2015/11/02 18:48:07 roberto Exp $
2+
** $Id: lapi.c,v 2.259 2016/02/29 14:27:14 roberto Exp $
33
** Lua API
44
** See Copyright Notice in lua.h
55
*/
@@ -378,9 +378,9 @@ LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) {
378378
return NULL;
379379
}
380380
lua_lock(L); /* 'luaO_tostring' may create a new string */
381+
luaO_tostring(L, o);
381382
luaC_checkGC(L);
382383
o = index2addr(L, idx); /* previous call may reallocate the stack */
383-
luaO_tostring(L, o);
384384
lua_unlock(L);
385385
}
386386
if (len != NULL)
@@ -479,10 +479,10 @@ LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) {
479479
LUA_API const char *lua_pushlstring (lua_State *L, const char *s, size_t len) {
480480
TString *ts;
481481
lua_lock(L);
482-
luaC_checkGC(L);
483482
ts = (len == 0) ? luaS_new(L, "") : luaS_newlstr(L, s, len);
484483
setsvalue2s(L, L->top, ts);
485484
api_incr_top(L);
485+
luaC_checkGC(L);
486486
lua_unlock(L);
487487
return getstr(ts);
488488
}
@@ -494,12 +494,12 @@ LUA_API const char *lua_pushstring (lua_State *L, const char *s) {
494494
setnilvalue(L->top);
495495
else {
496496
TString *ts;
497-
luaC_checkGC(L);
498497
ts = luaS_new(L, s);
499498
setsvalue2s(L, L->top, ts);
500499
s = getstr(ts); /* internal copy's address */
501500
}
502501
api_incr_top(L);
502+
luaC_checkGC(L);
503503
lua_unlock(L);
504504
return s;
505505
}
@@ -509,8 +509,8 @@ LUA_API const char *lua_pushvfstring (lua_State *L, const char *fmt,
509509
va_list argp) {
510510
const char *ret;
511511
lua_lock(L);
512-
luaC_checkGC(L);
513512
ret = luaO_pushvfstring(L, fmt, argp);
513+
luaC_checkGC(L);
514514
lua_unlock(L);
515515
return ret;
516516
}
@@ -520,10 +520,10 @@ LUA_API const char *lua_pushfstring (lua_State *L, const char *fmt, ...) {
520520
const char *ret;
521521
va_list argp;
522522
lua_lock(L);
523-
luaC_checkGC(L);
524523
va_start(argp, fmt);
525524
ret = luaO_pushvfstring(L, fmt, argp);
526525
va_end(argp);
526+
luaC_checkGC(L);
527527
lua_unlock(L);
528528
return ret;
529529
}
@@ -538,7 +538,6 @@ LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
538538
CClosure *cl;
539539
api_checknelems(L, n);
540540
api_check(L, n <= MAXUPVAL, "upvalue index too large");
541-
luaC_checkGC(L);
542541
cl = luaF_newCclosure(L, n);
543542
cl->f = fn;
544543
L->top -= n;
@@ -549,6 +548,7 @@ LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
549548
setclCvalue(L, L->top, cl);
550549
}
551550
api_incr_top(L);
551+
luaC_checkGC(L);
552552
lua_unlock(L);
553553
}
554554

@@ -585,16 +585,16 @@ LUA_API int lua_pushthread (lua_State *L) {
585585

586586

587587
static int auxgetstr (lua_State *L, const TValue *t, const char *k) {
588-
const TValue *aux;
588+
const TValue *slot;
589589
TString *str = luaS_new(L, k);
590-
if (luaV_fastget(L, t, str, aux, luaH_getstr)) {
591-
setobj2s(L, L->top, aux);
590+
if (luaV_fastget(L, t, str, slot, luaH_getstr)) {
591+
setobj2s(L, L->top, slot);
592592
api_incr_top(L);
593593
}
594594
else {
595595
setsvalue2s(L, L->top, str);
596596
api_incr_top(L);
597-
luaV_finishget(L, t, L->top - 1, L->top - 1, aux);
597+
luaV_finishget(L, t, L->top - 1, L->top - 1, slot);
598598
}
599599
lua_unlock(L);
600600
return ttnov(L->top - 1);
@@ -626,17 +626,17 @@ LUA_API int lua_getfield (lua_State *L, int idx, const char *k) {
626626

627627
LUA_API int lua_geti (lua_State *L, int idx, lua_Integer n) {
628628
StkId t;
629-
const TValue *aux;
629+
const TValue *slot;
630630
lua_lock(L);
631631
t = index2addr(L, idx);
632-
if (luaV_fastget(L, t, n, aux, luaH_getint)) {
633-
setobj2s(L, L->top, aux);
632+
if (luaV_fastget(L, t, n, slot, luaH_getint)) {
633+
setobj2s(L, L->top, slot);
634634
api_incr_top(L);
635635
}
636636
else {
637637
setivalue(L->top, n);
638638
api_incr_top(L);
639-
luaV_finishget(L, t, L->top - 1, L->top - 1, aux);
639+
luaV_finishget(L, t, L->top - 1, L->top - 1, slot);
640640
}
641641
lua_unlock(L);
642642
return ttnov(L->top - 1);
@@ -683,12 +683,12 @@ LUA_API int lua_rawgetp (lua_State *L, int idx, const void *p) {
683683
LUA_API void lua_createtable (lua_State *L, int narray, int nrec) {
684684
Table *t;
685685
lua_lock(L);
686-
luaC_checkGC(L);
687686
t = luaH_new(L);
688687
sethvalue(L, L->top, t);
689688
api_incr_top(L);
690689
if (narray > 0 || nrec > 0)
691690
luaH_resize(L, t, narray, nrec);
691+
luaC_checkGC(L);
692692
lua_unlock(L);
693693
}
694694

@@ -740,15 +740,15 @@ LUA_API int lua_getuservalue (lua_State *L, int idx) {
740740
** t[k] = value at the top of the stack (where 'k' is a string)
741741
*/
742742
static void auxsetstr (lua_State *L, const TValue *t, const char *k) {
743-
const TValue *aux;
743+
const TValue *slot;
744744
TString *str = luaS_new(L, k);
745745
api_checknelems(L, 1);
746-
if (luaV_fastset(L, t, str, aux, luaH_getstr, L->top - 1))
746+
if (luaV_fastset(L, t, str, slot, luaH_getstr, L->top - 1))
747747
L->top--; /* pop value */
748748
else {
749749
setsvalue2s(L, L->top, str); /* push 'str' (to make it a TValue) */
750750
api_incr_top(L);
751-
luaV_finishset(L, t, L->top - 1, L->top - 2, aux);
751+
luaV_finishset(L, t, L->top - 1, L->top - 2, slot);
752752
L->top -= 2; /* pop value and key */
753753
}
754754
lua_unlock(L); /* lock done by caller */
@@ -781,16 +781,16 @@ LUA_API void lua_setfield (lua_State *L, int idx, const char *k) {
781781

782782
LUA_API void lua_seti (lua_State *L, int idx, lua_Integer n) {
783783
StkId t;
784-
const TValue *aux;
784+
const TValue *slot;
785785
lua_lock(L);
786786
api_checknelems(L, 1);
787787
t = index2addr(L, idx);
788-
if (luaV_fastset(L, t, n, aux, luaH_getint, L->top - 1))
788+
if (luaV_fastset(L, t, n, slot, luaH_getint, L->top - 1))
789789
L->top--; /* pop value */
790790
else {
791791
setivalue(L->top, n);
792792
api_incr_top(L);
793-
luaV_finishset(L, t, L->top - 1, L->top - 2, aux);
793+
luaV_finishset(L, t, L->top - 1, L->top - 2, slot);
794794
L->top -= 2; /* pop value and key */
795795
}
796796
lua_unlock(L);
@@ -1140,14 +1140,14 @@ LUA_API void lua_concat (lua_State *L, int n) {
11401140
lua_lock(L);
11411141
api_checknelems(L, n);
11421142
if (n >= 2) {
1143-
luaC_checkGC(L);
11441143
luaV_concat(L, n);
11451144
}
11461145
else if (n == 0) { /* push empty string */
11471146
setsvalue2s(L, L->top, luaS_newlstr(L, "", 0));
11481147
api_incr_top(L);
11491148
}
11501149
/* else n == 1; nothing to do */
1150+
luaC_checkGC(L);
11511151
lua_unlock(L);
11521152
}
11531153

@@ -1183,10 +1183,10 @@ LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud) {
11831183
LUA_API void *lua_newuserdata (lua_State *L, size_t size) {
11841184
Udata *u;
11851185
lua_lock(L);
1186-
luaC_checkGC(L);
11871186
u = luaS_newudata(L, size);
11881187
setuvalue(L, L->top, u);
11891188
api_incr_top(L);
1189+
luaC_checkGC(L);
11901190
lua_unlock(L);
11911191
return getudatamem(u);
11921192
}

lua/src/lauxlib.c

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
** $Id: lauxlib.c,v 1.284 2015/11/19 19:16:22 roberto Exp $
2+
** $Id: lauxlib.c,v 1.286 2016/01/08 15:33:09 roberto Exp $
33
** Auxiliary functions for building Lua libraries
44
** See Copyright Notice in lua.h
55
*/
@@ -17,7 +17,8 @@
1717
#include <string.h>
1818

1919

20-
/* This file uses only the official API of Lua.
20+
/*
21+
** This file uses only the official API of Lua.
2122
** Any function declared here could be written as an application function.
2223
*/
2324

@@ -198,6 +199,10 @@ static void tag_error (lua_State *L, int arg, int tag) {
198199
}
199200

200201

202+
/*
203+
** The use of 'lua_pushfstring' ensures this function does not
204+
** need reserved stack space when called.
205+
*/
201206
LUALIB_API void luaL_where (lua_State *L, int level) {
202207
lua_Debug ar;
203208
if (lua_getstack(L, level, &ar)) { /* check function at level */
@@ -207,10 +212,15 @@ LUALIB_API void luaL_where (lua_State *L, int level) {
207212
return;
208213
}
209214
}
210-
lua_pushliteral(L, ""); /* else, no information available... */
215+
lua_pushfstring(L, ""); /* else, no information available... */
211216
}
212217

213218

219+
/*
220+
** Again, the use of 'lua_pushvfstring' ensures this function does
221+
** not need reserved stack space when called. (At worst, it generates
222+
** an error with "stack overflow" instead of the given message.)
223+
*/
214224
LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) {
215225
va_list argp;
216226
va_start(argp, fmt);
@@ -349,10 +359,15 @@ LUALIB_API int luaL_checkoption (lua_State *L, int arg, const char *def,
349359
}
350360

351361

362+
/*
363+
** Ensures the stack has at least 'space' extra slots, raising an error
364+
** if it cannot fulfill the request. (The error handling needs a few
365+
** extra slots to format the error message. In case of an error without
366+
** this extra space, Lua will generate the same 'stack overflow' error,
367+
** but without 'msg'.)
368+
*/
352369
LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *msg) {
353-
/* keep some extra space to run error routines, if needed */
354-
const int extra = LUA_MINSTACK;
355-
if (!lua_checkstack(L, space + extra)) {
370+
if (!lua_checkstack(L, space)) {
356371
if (msg)
357372
luaL_error(L, "stack overflow (%s)", msg);
358373
else
@@ -678,7 +693,7 @@ static int skipcomment (LoadF *lf, int *cp) {
678693
if (c == '#') { /* first line is a comment (Unix exec. file)? */
679694
do { /* skip first line */
680695
c = getc(lf->f);
681-
} while (c != EOF && c != '\n') ;
696+
} while (c != EOF && c != '\n');
682697
*cp = getc(lf->f); /* skip end-of-line, if present */
683698
return 1; /* there was a comment */
684699
}

lua/src/lbaselib.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
** $Id: lbaselib.c,v 1.312 2015/10/29 15:21:04 roberto Exp $
2+
** $Id: lbaselib.c,v 1.313 2016/04/11 19:18:40 roberto Exp $
33
** Basic library
44
** See Copyright Notice in lua.h
55
*/
@@ -102,8 +102,8 @@ static int luaB_tonumber (lua_State *L) {
102102
static int luaB_error (lua_State *L) {
103103
int level = (int)luaL_optinteger(L, 2, 1);
104104
lua_settop(L, 1);
105-
if (lua_isstring(L, 1) && level > 0) { /* add extra information? */
106-
luaL_where(L, level);
105+
if (lua_type(L, 1) == LUA_TSTRING && level > 0) {
106+
luaL_where(L, level); /* add extra information */
107107
lua_pushvalue(L, 1);
108108
lua_concat(L, 2);
109109
}
@@ -251,9 +251,8 @@ static int ipairsaux (lua_State *L) {
251251

252252

253253
/*
254-
** This function will use either 'ipairsaux' or 'ipairsaux_raw' to
255-
** traverse a table, depending on whether the table has metamethods
256-
** that can affect the traversal.
254+
** 'ipairs' function. Returns 'ipairsaux', given "table", 0.
255+
** (The given "table" may not be a table.)
257256
*/
258257
static int luaB_ipairs (lua_State *L) {
259258
#if defined(LUA_COMPAT_IPAIRS)

0 commit comments

Comments
 (0)