Skip to content

Commit ddd03c3

Browse files
sfan5nerzhul
authored andcommittedMay 30, 2018
Update embedded Lua to 5.1.5 (#7387)
1 parent e3e98f9 commit ddd03c3

File tree

14 files changed

+36
-33
lines changed

14 files changed

+36
-33
lines changed
 

‎lib/lua/COPYRIGHT

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ For details and rationale, see http://www.lua.org/license.html .
99

1010
===============================================================================
1111

12-
Copyright (C) 1994-2008 Lua.org, PUC-Rio.
12+
Copyright (C) 1994-2012 Lua.org, PUC-Rio.
1313

1414
Permission is hereby granted, free of charge, to any person obtaining a copy
1515
of this software and associated documentation files (the "Software"), to deal

‎lib/lua/src/lauxlib.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -574,8 +574,7 @@ LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) {
574574
lf.f = freopen(filename, "rb", lf.f); /* reopen in binary mode */
575575
if (lf.f == NULL) return errfile(L, "reopen", fnameindex);
576576
/* skip eventual `#!...' */
577-
while ((c = getc(lf.f)) != EOF && c != LUA_SIGNATURE[0])
578-
{}
577+
while ((c = getc(lf.f)) != EOF && c != LUA_SIGNATURE[0]) ;
579578
lf.extraline = 0;
580579
}
581580
ungetc(c, lf.f);

‎lib/lua/src/lbaselib.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ static void base_open (lua_State *L) {
631631
luaL_register(L, "_G", base_funcs);
632632
lua_pushliteral(L, LUA_VERSION);
633633
lua_setglobal(L, "_VERSION"); /* set global _VERSION */
634-
/* `ipairs' and `pairs' need auxliliary functions as upvalues */
634+
/* `ipairs' and `pairs' need auxiliary functions as upvalues */
635635
auxopen(L, "ipairs", luaB_ipairs, ipairsaux);
636636
auxopen(L, "pairs", luaB_pairs, luaB_next);
637637
/* `newproxy' needs a weaktable as upvalue */

‎lib/lua/src/lcode.c

+1-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
** $Id: lcode.c,v 2.25.1.3 2007/12/28 15:32:23 roberto Exp $
2+
** $Id: lcode.c,v 2.25.1.5 2011/01/31 14:53:16 roberto Exp $
33
** Code generator for Lua
44
** See Copyright Notice in lua.h
55
*/
@@ -544,10 +544,6 @@ void luaK_goiftrue (FuncState *fs, expdesc *e) {
544544
pc = NO_JUMP; /* always true; do nothing */
545545
break;
546546
}
547-
case VFALSE: {
548-
pc = luaK_jump(fs); /* always jump */
549-
break;
550-
}
551547
case VJMP: {
552548
invertjump(fs, e);
553549
pc = e->u.s.info;
@@ -572,10 +568,6 @@ static void luaK_goiffalse (FuncState *fs, expdesc *e) {
572568
pc = NO_JUMP; /* always false; do nothing */
573569
break;
574570
}
575-
case VTRUE: {
576-
pc = luaK_jump(fs); /* always jump */
577-
break;
578-
}
579571
case VJMP: {
580572
pc = e->u.s.info;
581573
break;

‎lib/lua/src/ldblib.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
** $Id: ldblib.c,v 1.104.1.3 2008/01/21 13:11:21 roberto Exp $
2+
** $Id: ldblib.c,v 1.104.1.4 2009/08/04 18:50:18 roberto Exp $
33
** Interface from Lua to its debug API
44
** See Copyright Notice in lua.h
55
*/
@@ -45,6 +45,7 @@ static int db_setmetatable (lua_State *L) {
4545

4646

4747
static int db_getfenv (lua_State *L) {
48+
luaL_checkany(L, 1);
4849
lua_getfenv(L, 1);
4950
return 1;
5051
}

‎lib/lua/src/ldo.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
** $Id: ldo.c,v 2.38.1.3 2008/01/18 22:31:22 roberto Exp $
2+
** $Id: ldo.c,v 2.38.1.4 2012/01/18 02:27:10 roberto Exp $
33
** Stack and Call structure of Lua
44
** See Copyright Notice in lua.h
55
*/
@@ -217,6 +217,7 @@ static StkId adjust_varargs (lua_State *L, Proto *p, int actual) {
217217
int nvar = actual - nfixargs; /* number of extra arguments */
218218
lua_assert(p->is_vararg & VARARG_HASARG);
219219
luaC_checkGC(L);
220+
luaD_checkstack(L, p->maxstacksize);
220221
htab = luaH_new(L, nvar, 1); /* create `arg' table */
221222
for (i=0; i<nvar; i++) /* put extra arguments into `arg' table */
222223
setobj2n(L, luaH_setnum(L, htab, i+1), L->top - nvar + i);

‎lib/lua/src/lgc.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
** $Id: lgc.c,v 2.38.1.1 2007/12/27 13:02:25 roberto Exp $
2+
** $Id: lgc.c,v 2.38.1.2 2011/03/18 18:05:38 roberto Exp $
33
** Garbage Collector
44
** See Copyright Notice in lua.h
55
*/
@@ -627,7 +627,6 @@ void luaC_step (lua_State *L) {
627627
}
628628
}
629629
else {
630-
lua_assert(g->totalbytes >= g->estimate);
631630
setthreshold(g);
632631
}
633632
}

‎lib/lua/src/liolib.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
** $Id: liolib.c,v 2.73.1.3 2008/01/18 17:47:43 roberto Exp $
2+
** $Id: liolib.c,v 2.73.1.4 2010/05/14 15:33:51 roberto Exp $
33
** Standard I/O (and system) library
44
** See Copyright Notice in lua.h
55
*/
@@ -276,7 +276,10 @@ static int read_number (lua_State *L, FILE *f) {
276276
lua_pushnumber(L, d);
277277
return 1;
278278
}
279-
else return 0; /* read fails */
279+
else {
280+
lua_pushnil(L); /* "result" to be removed */
281+
return 0; /* read fails */
282+
}
280283
}
281284

282285

‎lib/lua/src/llex.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
** $Id: llex.c,v 2.20.1.1 2007/12/27 13:02:25 roberto Exp $
2+
** $Id: llex.c,v 2.20.1.2 2009/11/23 14:58:22 roberto Exp $
33
** Lexical Analyzer
44
** See Copyright Notice in lua.h
55
*/
@@ -118,8 +118,10 @@ TString *luaX_newstring (LexState *ls, const char *str, size_t l) {
118118
lua_State *L = ls->L;
119119
TString *ts = luaS_newlstr(L, str, l);
120120
TValue *o = luaH_setstr(L, ls->fs->h, ts); /* entry for `str' */
121-
if (ttisnil(o))
121+
if (ttisnil(o)) {
122122
setbvalue(o, 1); /* make sure `str' will not be collected */
123+
luaC_checkGC(L);
124+
}
123125
return ts;
124126
}
125127

‎lib/lua/src/loadlib.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
** $Id: loadlib.c,v 1.52.1.3 2008/08/06 13:29:28 roberto Exp $
2+
** $Id: loadlib.c,v 1.52.1.4 2009/09/09 13:17:16 roberto Exp $
33
** Dynamic library loader for Lua
44
** See Copyright Notice in lua.h
55
**
@@ -639,7 +639,7 @@ LUALIB_API int luaopen_package (lua_State *L) {
639639
lua_pushvalue(L, -1);
640640
lua_replace(L, LUA_ENVIRONINDEX);
641641
/* create `loaders' table */
642-
lua_createtable(L, 0, sizeof(loaders)/sizeof(loaders[0]) - 1);
642+
lua_createtable(L, sizeof(loaders)/sizeof(loaders[0]) - 1, 0);
643643
/* fill it with pre-defined loaders */
644644
for (i=0; loaders[i] != NULL; i++) {
645645
lua_pushcfunction(L, loaders[i]);

‎lib/lua/src/lparser.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
** $Id: lparser.c,v 2.42.1.3 2007/12/28 15:32:23 roberto Exp $
2+
** $Id: lparser.c,v 2.42.1.4 2011/10/21 19:31:42 roberto Exp $
33
** Lua Parser
44
** See Copyright Notice in lua.h
55
*/
@@ -374,9 +374,9 @@ static void close_func (LexState *ls) {
374374
lua_assert(luaG_checkcode(f));
375375
lua_assert(fs->bl == NULL);
376376
ls->fs = fs->prev;
377-
L->top -= 2; /* remove table and prototype from the stack */
378377
/* last token read was anchored in defunct function; must reanchor it */
379378
if (fs) anchor_token(ls);
379+
L->top -= 2; /* remove table and prototype from the stack */
380380
}
381381

382382

‎lib/lua/src/lstrlib.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
** $Id: lstrlib.c,v 1.132.1.4 2008/07/11 17:27:21 roberto Exp $
2+
** $Id: lstrlib.c,v 1.132.1.5 2010/05/14 15:34:19 roberto Exp $
33
** Standard library for string operations and pattern-matching
44
** See Copyright Notice in lua.h
55
*/
@@ -754,6 +754,7 @@ static void addintlen (char *form) {
754754

755755

756756
static int str_format (lua_State *L) {
757+
int top = lua_gettop(L);
757758
int arg = 1;
758759
size_t sfl;
759760
const char *strfrmt = luaL_checklstring(L, arg, &sfl);
@@ -768,7 +769,8 @@ static int str_format (lua_State *L) {
768769
else { /* format item */
769770
char form[MAX_FORMAT]; /* to store the format (`%...') */
770771
char buff[MAX_ITEM]; /* to store the formatted item */
771-
arg++;
772+
if (++arg > top)
773+
luaL_argerror(L, arg, "no value");
772774
strfrmt = scanformat(L, strfrmt, form);
773775
switch (*strfrmt++) {
774776
case 'c': {

‎lib/lua/src/lua.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
** $Id: lua.h,v 1.218.1.5 2008/08/06 13:30:12 roberto Exp $
2+
** $Id: lua.h,v 1.218.1.7 2012/01/13 20:36:20 roberto Exp $
33
** Lua - An Extensible Extension Language
44
** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
55
** See Copyright Notice at the end of this file
@@ -17,9 +17,9 @@
1717

1818

1919
#define LUA_VERSION "Lua 5.1"
20-
#define LUA_RELEASE "Lua 5.1.4"
20+
#define LUA_RELEASE "Lua 5.1.5"
2121
#define LUA_VERSION_NUM 501
22-
#define LUA_COPYRIGHT "Copyright (C) 1994-2008 Lua.org, PUC-Rio"
22+
#define LUA_COPYRIGHT "Copyright (C) 1994-2012 Lua.org, PUC-Rio"
2323
#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes"
2424

2525

@@ -362,7 +362,7 @@ struct lua_Debug {
362362

363363

364364
/******************************************************************************
365-
* Copyright (C) 1994-2008 Lua.org, PUC-Rio. All rights reserved.
365+
* Copyright (C) 1994-2012 Lua.org, PUC-Rio. All rights reserved.
366366
*
367367
* Permission is hereby granted, free of charge, to any person obtaining
368368
* a copy of this software and associated documentation files (the

‎lib/lua/src/lvm.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
** $Id: lvm.c,v 2.63.1.3 2007/12/28 15:32:23 roberto Exp $
2+
** $Id: lvm.c,v 2.63.1.5 2011/08/17 20:43:11 roberto Exp $
33
** Lua virtual machine
44
** See Copyright Notice in lua.h
55
*/
@@ -133,6 +133,7 @@ void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) {
133133

134134
void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) {
135135
int loop;
136+
TValue temp;
136137
for (loop = 0; loop < MAXTAGLOOP; loop++) {
137138
const TValue *tm;
138139
if (ttistable(t)) { /* `t' is a table? */
@@ -141,6 +142,7 @@ void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) {
141142
if (!ttisnil(oldval) || /* result is no nil? */
142143
(tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL) { /* or no TM? */
143144
setobj2t(L, oldval, val);
145+
h->flags = 0;
144146
luaC_barriert(L, h, val);
145147
return;
146148
}
@@ -152,7 +154,9 @@ void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) {
152154
callTM(L, tm, t, key, val);
153155
return;
154156
}
155-
t = tm; /* else repeat with `tm' */
157+
/* else repeat with `tm' */
158+
setobj(L, &temp, tm); /* avoid pointing inside table (may rehash) */
159+
t = &temp;
156160
}
157161
luaG_runerror(L, "loop in settable");
158162
}

0 commit comments

Comments
 (0)
Please sign in to comment.