History

Lua 5.3.0-rc3

Lua Team committed 11 years ago

Commit 48416b81 parent f4a972718 files · +220 −181Browse files

Unified · Split

18 files
  1. README +1 −1
  2. doc/contents.html +1 −1
  3. doc/manual.html +21 −17
  4. doc/readme.html +1 −1
  5. src/Makefile +1 −1
  6. src/lapi.c +2 −2
  7. src/lcode.c +10 −24
  8. src/ldblib.c +7 −2
  9. src/ldebug.c +4 −3
  10. src/liolib.c +3 −5
  11. src/lmathlib.c +5 −3
  12. src/lobject.c +2 −2
  13. src/loslib.c +3 −3
  14. src/lparser.c +4 −4
  15. src/lprefix.h +8 −2
  16. src/lua.h +3 −3
  17. src/luaconf.h +2 −10
  18. src/lvm.c +142 −97
README+1−1
@@ -1,5 +1,5 @@
11
2−This is Lua 5.3.0, released on 22 Dec 2014.
2+This is Lua 5.3.0, released on 02 Jan 2015.
33
44 For installation instructions, license details, and
55 further information about Lua, see doc/readme.html.
doc/contents.html+1−1
@@ -33,7 +33,7 @@ For a complete introduction to Lua programming, see the book · 32 unmodified lines
3333 <A HREF="#index">index</A>
3434 <HR>
3535 <SMALL>
36−Copyright &copy; 2014 Lua.org, PUC-Rio.
36+Copyright &copy; 2015 Lua.org, PUC-Rio.
3737 Freely available under the terms of the
3838 <A HREF="http://www.lua.org/license.html">Lua license</A>.
3939 </SMALL>
doc/manual.html+21−17
@@ -19,7 +19,7 @@ Lua 5.3 Reference Manual · 18 unmodified lines
1919 by Roberto Ierusalimschy, Luiz Henrique de Figueiredo, Waldemar Celes
2020 <p>
2121 <small>
22−Copyright &copy; 2014 Lua.org, PUC-Rio.
22+Copyright &copy; 2015 Lua.org, PUC-Rio.
2323 Freely available under the terms of the
2424 <a href="http://www.lua.org/license.html">Lua license</a>.
2525 </small>
@@ -33,7 +33,7 @@ Freely available under the terms of the · 7 unmodified lines
3333 <!-- ====================================================================== -->
3434 <p>
3535
36−<!-- $Id: manual.of,v 1.142 2014/12/22 13:31:36 roberto Exp $ -->
36+<!-- $Id: manual.of,v 1.143 2015/01/02 13:07:38 roberto Exp $ -->
3737
3838
3939
@@ -1855,7 +1855,7 @@ Lua supports the following arithmetic operators: · 1815 unmodified lines
18551855 </ul>
18561856
18571857 <p>
1858−With the exception of float division and exponentiation,
1858+With the exception of exponentiation and float division,
18591859 the arithmetic operators work as follows:
18601860 If both operands are integers,
18611861 the operation is performed over integers and the result is an integer.
@@ -1870,7 +1870,7 @@ and the result is a float. · 8 unmodified lines
18701870
18711871
18721872 <p>
1873−Float division (<code>/</code>) and exponentiation
1873+Exponentiation and float division (<code>/</code>)
18741874 always convert their operands to floats
18751875 and the result is always a float.
18761876 Exponentiation uses the ISO&nbsp;C function <code>pow</code>,
@@ -1932,7 +1932,7 @@ result in zero (as all bits are shifted out). · 55 unmodified lines
19321932 Lua provides some automatic conversions between some
19331933 types and representations at run time.
19341934 Bitwise operators always convert float operands to integers.
1935−Float division and exponentiation
1935+Exponentiation and float division
19361936 always convert integer operands to floats.
19371937 All other arithmetic operations applied to mixed numbers
19381938 (integers and floats) convert the integer operand to a float;
@@ -2893,7 +2893,7 @@ replacing <a href="#lua_pcall"><code>lua_pcall</code></a> by <a href="#lua_pcall · 954 unmodified lines
28932893 </pre><p>
28942894 Note the external, explicit call to the continuation:
28952895 Lua will call the continuation only if needed, that is,
2896−in case of errors or resuming after an yield.
2896+in case of errors or resuming after a yield.
28972897 If the called function returns normally without ever yielding,
28982898 <a href="#lua_pcallk"><code>lua_pcallk</code></a> (and <a href="#lua_callk"><code>lua_callk</code></a>) will also return normally.
28992899 (Of course, instead of calling the continuation in that case,
@@ -2910,7 +2910,7 @@ it only passes this value from the original function to the · 10 unmodified lines
29102910 continuation function.)
29112911 For <a href="#lua_pcallk"><code>lua_pcallk</code></a>,
29122912 the status is the same value that would be returned by <a href="#lua_pcallk"><code>lua_pcallk</code></a>,
2913−except that it is <a href="#pdf-LUA_YIELD"><code>LUA_YIELD</code></a> when being executed after an yield
2913+except that it is <a href="#pdf-LUA_YIELD"><code>LUA_YIELD</code></a> when being executed after a yield
29142914 (instead of <a href="#pdf-LUA_OK"><code>LUA_OK</code></a>).
29152915 For <a href="#lua_yieldk"><code>lua_yieldk</code></a> and <a href="#lua_callk"><code>lua_callk</code></a>,
29162916 the status is always <a href="#pdf-LUA_YIELD"><code>LUA_YIELD</code></a> when Lua calls the continuation.
@@ -5785,7 +5785,7 @@ when the index is greater than the number of upvalues. · 2868 unmodified lines
57855785 <pre>void *lua_upvalueid (lua_State *L, int funcindex, int n);</pre>
57865786
57875787 <p>
5788−Returns an unique identifier for the upvalue numbered <code>n</code>
5788+Returns a unique identifier for the upvalue numbered <code>n</code>
57895789 from the closure at index <code>funcindex</code>.
57905790 Parameters <code>funcindex</code> and <code>n</code> are as in the <a href="#lua_getupvalue"><code>lua_getupvalue</code></a>
57915791 (see <a href="#lua_getupvalue"><code>lua_getupvalue</code></a>)
@@ -6576,6 +6576,7 @@ creates a new table to be used as a metatable for userdata, · 784 unmodified lines
65766576 adds to this new table the pair <code>__name = tname</code>,
65776577 adds to the registry the pair <code>[tname] = new table</code>,
65786578 and returns 1.
6579+(The entry <code>__name</code> is used by some error-reporting functions.)
65796580
65806581
65816582 <p>
@@ -6782,7 +6783,7 @@ Type for arrays of functions to be registered by · 200 unmodified lines
67826783 <a href="#luaL_setfuncs"><code>luaL_setfuncs</code></a>.
67836784 <code>name</code> is the function name and <code>func</code> is a pointer to
67846785 the function.
6785−Any array of <a href="#luaL_Reg"><code>luaL_Reg</code></a> must end with an sentinel entry
6786+Any array of <a href="#luaL_Reg"><code>luaL_Reg</code></a> must end with a sentinel entry
67866787 in which both <code>name</code> and <code>func</code> are <code>NULL</code>.
67876788
67886789
@@ -8552,26 +8553,27 @@ which matches any single character in the class; · 1763 unmodified lines
85528553
85538554 <li>
85548555 a single character class followed by '<code>*</code>',
8555−which matches 0 or more repetitions of characters in the class.
8556+which matches zero or more repetitions of characters in the class.
85568557 These repetition items will always match the longest possible sequence;
85578558 </li>
85588559
85598560 <li>
85608561 a single character class followed by '<code>+</code>',
8561−which matches 1 or more repetitions of characters in the class.
8562+which matches one or more repetitions of characters in the class.
85628563 These repetition items will always match the longest possible sequence;
85638564 </li>
85648565
85658566 <li>
85668567 a single character class followed by '<code>-</code>',
8567−which also matches 0 or more repetitions of characters in the class.
8568+which also matches zero or more repetitions of characters in the class.
85688569 Unlike '<code>*</code>',
85698570 these repetition items will always match the shortest possible sequence;
85708571 </li>
85718572
85728573 <li>
85738574 a single character class followed by '<code>?</code>',
8574−which matches 0 or 1 occurrence of a character in the class;
8575+which matches zero or one occurrence of a character in the class.
8576+It always matches one occurrence if possible;
85758577 </li>
85768578
85778579 <li>
@@ -10108,7 +10110,9 @@ but also parameters, temporaries, etc. · 1530 unmodified lines
1010810110
1010910111 <p>
1011010112 The first parameter or local variable has index&nbsp;1, and so on,
10111−until the last active variable.
10113+following the order that they are declared in the code,
10114+counting only the variables that are active
10115+in the current scope of the function.
1011210116 Negative indices refer to vararg parameters;
1011310117 -1 is the first vararg parameter.
1011410118 The function returns <b>nil</b> if there is no variable with the given index,
@@ -10119,7 +10123,7 @@ and raises an error when called with a level out of range. · 4 unmodified lines
1011910123 <p>
1012010124 Variable names starting with '<code>(</code>' (open parenthesis)
1012110125 represent variables with no known names
10122−(internal variables like loop control variables,
10126+(internal variables such as loop control variables,
1012310127 and variables from chunks saved without debug information).
1012410128
1012510129
@@ -10310,7 +10314,7 @@ to start the traceback · 184 unmodified lines
1031010314
1031110315
1031210316 <p>
10313−Returns an unique identifier (as a light userdata)
10317+Returns a unique identifier (as a light userdata)
1031410318 for the upvalue numbered <code>n</code>
1031510319 from the given function.
1031610320
@@ -10770,7 +10774,7 @@ and LiteralString, see <a href="#3.1">&sect;3.1</a>.) · 453 unmodified lines
1077010774 <HR>
1077110775 <SMALL CLASS="footer">
1077210776 Last update:
10773−Mon Dec 22 12:28:03 BRST 2014
10777+Fri Jan 2 11:29:40 BRST 2015
1077410778 </SMALL>
1077510779 <!--
1077610780 Last change: revised for Lua 5.3.0 (final)
doc/readme.html+1−1
@@ -333,7 +333,7 @@ For details, see · 332 unmodified lines
333333 <A HREF="http://www.lua.org/license.html">this</A>.
334334
335335 <BLOCKQUOTE STYLE="padding-bottom: 0em">
336−Copyright &copy; 1994&ndash;2014 Lua.org, PUC-Rio.
336+Copyright &copy; 1994&ndash;2015 Lua.org, PUC-Rio.
337337
338338 <P>
339339 Permission is hereby granted, free of charge, to any person obtaining a copy
src/Makefile+1−1
@@ -6,7 +6,7 @@ · 5 unmodified lines
66 # Your platform. See PLATS for possible values.
77 PLAT= none
88
9−CC= gcc
9+CC= gcc -std=c99
1010 CFLAGS= -O2 -Wall -Wextra -DLUA_COMPAT_5_2 $(SYSCFLAGS) $(MYCFLAGS)
1111 LDFLAGS= $(SYSLDFLAGS) $(MYLDFLAGS)
1212 LIBS= -lm $(SYSLIBS) $(MYLIBS)
src/lapi.c+2−2
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lapi.c,v 2.243 2014/11/12 13:28:54 roberto Exp $
2+** $Id: lapi.c,v 2.244 2014/12/26 14:43:45 roberto Exp $
33 ** Lua API
44 ** See Copyright Notice in lua.h
55 */
@@ -676,7 +676,7 @@ LUA_API void lua_createtable (lua_State *L, int narray, int nrec) { · 670 unmodified lines
676676
677677 LUA_API int lua_getmetatable (lua_State *L, int objindex) {
678678 const TValue *obj;
679− Table *mt = NULL;
679+ Table *mt;
680680 int res = 0;
681681 lua_lock(L);
682682 obj = index2addr(L, objindex);
src/lcode.c+10−24
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lcode.c,v 2.98 2014/12/19 13:36:32 roberto Exp $
2+** $Id: lcode.c,v 2.99 2014/12/29 16:49:25 roberto Exp $
33 ** Code generator for Lua
44 ** See Copyright Notice in lua.h
55 */
@@ -33,14 +33,6 @@ · 27 unmodified lines
3333 #define MAXREGS 250
3434
3535
36−/* test for x == -0 ('signbit' needs 'math.h') */
37−#if defined(signbit)
38−#define isminuszero(x) ((x) == 0.0 && signbit(x))
39−#else
40−#define isminuszero(x) ((x) == 0.0 && 1.0/(x) < 0.0)
41−#endif
42−
43−
4436 #define hasjumps(e) ((e)->t != (e)->f)
4537
4638
@@ -364,14 +356,8 @@ int luaK_intK (FuncState *fs, lua_Integer n) { · 317 unmodified lines
364356 }
365357
366358
367−/*
368−** Both NaN and -0.0 should not go to the constant table, as they have
369−** problems with the hashing. (NaN is not a valid key, -0.0 collides
370−** with +0.0.)
371−*/
372359 static int luaK_numberK (FuncState *fs, lua_Number r) {
373360 TValue o;
374− lua_assert(!luai_numisnan(r) && !isminuszero(r));
375361 setfltvalue(&o, r);
376362 return addk(fs, &o, &o);
377363 }
@@ -761,14 +747,14 @@ void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { · 383 unmodified lines
761747 ** return false if folding can raise an error
762748 */
763749 static int validop (int op, TValue *v1, TValue *v2) {
764− lua_Integer i;
765− if (luai_numinvalidop(op, nvalue(v1), nvalue(v2))) return 0;
766750 switch (op) {
767751 case LUA_OPBAND: case LUA_OPBOR: case LUA_OPBXOR:
768− case LUA_OPSHL: case LUA_OPSHR: case LUA_OPBNOT: /* conversion errors */
752+ case LUA_OPSHL: case LUA_OPSHR: case LUA_OPBNOT: { /* conversion errors */
753+ lua_Integer i;
769754 return (tointeger(v1, &i) && tointeger(v2, &i));
770− case LUA_OPIDIV: case LUA_OPMOD: /* integer division by 0 */
771− return !(ttisinteger(v1) && ttisinteger(v2) && ivalue(v2) == 0);
755+ }
756+ case LUA_OPDIV: case LUA_OPIDIV: case LUA_OPMOD: /* division by 0 */
757+ return (nvalue(v2) != 0);
772758 default: return 1; /* everything else is valid */
773759 }
774760 }
@@ -781,15 +767,15 @@ static int constfolding (FuncState *fs, int op, expdesc *e1, expdesc *e2) { · 6 unmodified lines
781767 TValue v1, v2, res;
782768 if (!tonumeral(e1, &v1) || !tonumeral(e2, &v2) || !validop(op, &v1, &v2))
783769 return 0; /* non-numeric operands or not safe to fold */
784− luaO_arith(fs->ls->L, op, &v1, &v2, &res);
770+ luaO_arith(fs->ls->L, op, &v1, &v2, &res); /* does operation */
785771 if (ttisinteger(&res)) {
786772 e1->k = VKINT;
787773 e1->u.ival = ivalue(&res);
788774 }
789− else {
775+ else { /* folds neither NaN nor 0.0 (to avoid collapsing with -0.0) */
790776 lua_Number n = fltvalue(&res);
791− if (luai_numisnan(n) || isminuszero(n))
792− return 0; /* folds neither NaN nor -0 */
777+ if (luai_numisnan(n) || n == 0)
778+ return 0;
793779 e1->k = VKFLT;
794780 e1->u.nval = n;
795781 }
src/ldblib.c+7−2
@@ -1,5 +1,5 @@
11 /*
2−** $Id: ldblib.c,v 1.147 2014/12/08 15:47:25 roberto Exp $
2+** $Id: ldblib.c,v 1.148 2015/01/02 12:52:22 roberto Exp $
33 ** Interface from Lua to its debug API
44 ** See Copyright Notice in lua.h
55 */
@@ -207,15 +207,20 @@ static int db_getlocal (lua_State *L) { · 201 unmodified lines
207207
208208 static int db_setlocal (lua_State *L) {
209209 int arg;
210+ const char *name;
210211 lua_State *L1 = getthread(L, &arg);
211212 lua_Debug ar;
212213 int level = (int)luaL_checkinteger(L, arg + 1);
214+ int nvar = (int)luaL_checkinteger(L, arg + 2);
213215 if (!lua_getstack(L1, level, &ar)) /* out of range? */
214216 return luaL_argerror(L, arg+1, "level out of range");
215217 luaL_checkany(L, arg+3);
216218 lua_settop(L, arg+3);
217219 lua_xmove(L, L1, 1);
218− lua_pushstring(L, lua_setlocal(L1, &ar, (int)luaL_checkinteger(L, arg+2)));
220+ name = lua_setlocal(L1, &ar, nvar);
221+ if (name == NULL)
222+ lua_pop(L1, 1); /* pop value (if not popped by 'lua_setlocal') */
223+ lua_pushstring(L, name);
219224 return 1;
220225 }
221226
src/ldebug.c+4−3
@@ -1,5 +1,5 @@
11 /*
2−** $Id: ldebug.c,v 2.109 2014/12/10 11:30:09 roberto Exp $
2+** $Id: ldebug.c,v 2.110 2015/01/02 12:52:22 roberto Exp $
33 ** Debug Interface
44 ** See Copyright Notice in lua.h
55 */
@@ -167,9 +167,10 @@ LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) { · 161 unmodified lines
167167 StkId pos = 0; /* to avoid warnings */
168168 const char *name = findlocal(L, ar->i_ci, n, &pos);
169169 lua_lock(L);
170− if (name)
170+ if (name) {
171171 setobjs2s(L, pos, L->top - 1);
172− L->top--; /* pop value */
172+ L->top--; /* pop value */
173+ }
173174 lua_unlock(L);
174175 return name;
175176 }
src/liolib.c+3−5
@@ -1,5 +1,5 @@
11 /*
2−** $Id: liolib.c,v 2.141 2014/11/21 12:17:33 roberto Exp $
2+** $Id: liolib.c,v 2.142 2015/01/02 12:50:28 roberto Exp $
33 ** Standard I/O (and system) library
44 ** See Copyright Notice in lua.h
55 */
@@ -464,9 +464,9 @@ static int test_eof (lua_State *L, FILE *f) { · 458 unmodified lines
464464
465465 static int read_line (lua_State *L, FILE *f, int chop) {
466466 luaL_Buffer b;
467− int c;
467+ int c = '\0';
468468 luaL_buffinit(L, &b);
469− for (;;) {
469+ while (c != EOF && c != '\n') { /* repeat until end of line */
470470 char *buff = luaL_prepbuffer(&b); /* pre-allocate buffer */
471471 int i = 0;
472472 l_lockfile(f); /* no memory errors can happen inside the lock */
@@ -474,8 +474,6 @@ static int read_line (lua_State *L, FILE *f, int chop) { · 1 unmodified line
474474 buff[i++] = c;
475475 l_unlockfile(f);
476476 luaL_addsize(&b, i);
477− if (i < LUAL_BUFFERSIZE)
478− break;
479477 }
480478 if (!chop && c == '\n') /* want a newline and have one? */
481479 luaL_addchar(&b, c); /* add ending newline to result */
src/lmathlib.c+5−3
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lmathlib.c,v 1.113 2014/11/07 11:31:58 roberto Exp $
2+** $Id: lmathlib.c,v 1.114 2014/12/27 20:32:26 roberto Exp $
33 ** Standard mathematical library
44 ** See Copyright Notice in lua.h
55 */
@@ -27,9 +27,11 @@ · 21 unmodified lines
2727 #if defined(LUA_USE_POSIX)
2828 #define l_rand() random()
2929 #define l_srand(x) srandom(x)
30+#define L_RANDMAX 2147483647 /* (2^31 - 1), following POSIX */
3031 #else
3132 #define l_rand() rand()
3233 #define l_srand(x) srand(x)
34+#define L_RANDMAX RAND_MAX
3335 #endif
3436 #endif /* } */
3537
@@ -233,12 +235,12 @@ static int math_max (lua_State *L) { · 197 unmodified lines
233235
234236 /*
235237 ** This function uses 'double' (instead of 'lua_Number') to ensure that
236−** all bits from 'l_rand' can be represented, and that 'RAND_MAX + 1.0'
238+** all bits from 'l_rand' can be represented, and that 'RANDMAX + 1.0'
237239 ** will keep full precision (ensuring that 'r' is always less than 1.0.)
238240 */
239241 static int math_random (lua_State *L) {
240242 lua_Integer low, up;
241− double r = (double)l_rand() * (1.0 / ((double)RAND_MAX + 1.0));
243+ double r = (double)l_rand() * (1.0 / ((double)L_RANDMAX + 1.0));
242244 switch (lua_gettop(L)) { /* check number of arguments */
243245 case 0: { /* no arguments */
244246 lua_pushnumber(L, (lua_Number)r); /* Number between 0 and 1 */
src/lobject.c+2−2
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lobject.c,v 2.100 2014/11/21 12:15:57 roberto Exp $
2+** $Id: lobject.c,v 2.101 2014/12/26 14:43:45 roberto Exp $
33 ** Some generic functions over Lua objects
44 ** See Copyright Notice in lua.h
55 */
@@ -189,7 +189,7 @@ static lua_Number lua_strx2number (const char *s, char **endptr) { · 183 unmodified lines
189189 int sigdig = 0; /* number of significant digits */
190190 int nosigdig = 0; /* number of non-significant digits */
191191 int e = 0; /* exponent correction */
192− int neg = 0; /* 1 if number is negative */
192+ int neg; /* 1 if number is negative */
193193 int dot = 0; /* true after seen a dot */
194194 *endptr = cast(char *, s); /* nothing is valid yet */
195195 while (lisspace(cast_uchar(*s))) s++; /* skip initial spaces */
src/loslib.c+3−3
@@ -1,5 +1,5 @@
11 /*
2−** $Id: loslib.c,v 1.53 2014/12/10 15:42:42 roberto Exp $
2+** $Id: loslib.c,v 1.54 2014/12/26 14:46:07 roberto Exp $
33 ** Standard Operating System library
44 ** See Copyright Notice in lua.h
55 */
@@ -100,8 +100,8 @@ · 94 unmodified lines
100100 #else /* }{ */
101101
102102 /* ISO C definitions */
103−#define l_gmtime(t,r) ((void)r, gmtime(t))
104−#define l_localtime(t,r) ((void)r, localtime(t))
103+#define l_gmtime(t,r) ((void)(r)->tm_sec, gmtime(t))
104+#define l_localtime(t,r) ((void)(r)->tm_sec, localtime(t))
105105
106106 #endif /* } */
107107
src/lparser.c+4−4
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lparser.c,v 2.146 2014/11/27 18:41:43 roberto Exp $
2+** $Id: lparser.c,v 2.147 2014/12/27 20:31:43 roberto Exp $
33 ** Lua Parser
44 ** See Copyright Notice in lua.h
55 */
@@ -47,8 +47,8 @@ · 41 unmodified lines
4747 */
4848 typedef struct BlockCnt {
4949 struct BlockCnt *previous; /* chain */
50− short firstlabel; /* index of first label in this block */
51− short firstgoto; /* index of first pending goto in this block */
50+ int firstlabel; /* index of first label in this block */
51+ int firstgoto; /* index of first pending goto in this block */
5252 lu_byte nactvar; /* # active locals outside the block */
5353 lu_byte upval; /* true if some variable in the block is an upvalue */
5454 lu_byte isloop; /* true if 'block' is a loop */
@@ -386,7 +386,7 @@ static int newlabelentry (LexState *ls, Labellist *l, TString *name, · 331 unmodified lines
386386 l->arr[n].line = line;
387387 l->arr[n].nactvar = ls->fs->nactvar;
388388 l->arr[n].pc = pc;
389− l->n++;
389+ l->n = n + 1;
390390 return n;
391391 }
392392
src/lprefix.h+8−2
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lprefix.h,v 1.1 2014/11/03 15:12:44 roberto Exp $
2+** $Id: lprefix.h,v 1.2 2014/12/29 16:54:13 roberto Exp $
33 ** Definitions for Lua code that must come before any other header file
44 ** See Copyright Notice in lua.h
55 */
@@ -11,18 +11,24 @@ · 5 unmodified lines
1111 /*
1212 ** Allows POSIX/XSI stuff
1313 */
14+#if !defined(LUA_USE_C89) /* { */
15+
1416 #if !defined(_XOPEN_SOURCE)
1517 #define _XOPEN_SOURCE 600
18+#elif _XOPEN_SOURCE == 0
19+#undef _XOPEN_SOURCE /* use -D_XOPEN_SOURCE=0 to undefine it */
1620 #endif
1721
1822 /*
1923 ** Allows manipulation of large files in gcc and some other compilers
2024 */
21−#if !defined(_FILE_OFFSET_BITS)
25+#if !defined(LUA_32BITS) && !defined(_FILE_OFFSET_BITS)
2226 #define _LARGEFILE_SOURCE 1
2327 #define _FILE_OFFSET_BITS 64
2428 #endif
2529
30+#endif /* } */
31+
2632
2733 /*
2834 ** Windows stuff
src/lua.h+3−3
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lua.h,v 1.324 2014/12/08 15:12:07 roberto Exp $
2+** $Id: lua.h,v 1.325 2014/12/26 17:24:27 roberto Exp $
33 ** Lua - A Scripting Language
44 ** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
55 ** See Copyright Notice at the end of this file
@@ -23,7 +23,7 @@ · 17 unmodified lines
2323
2424 #define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
2525 #define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE
26−#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2014 Lua.org, PUC-Rio"
26+#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2015 Lua.org, PUC-Rio"
2727 #define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo, W. Celes"
2828
2929
@@ -459,7 +459,7 @@ struct lua_Debug { · 429 unmodified lines
459459
460460
461461 /******************************************************************************
462−* Copyright (C) 1994-2014 Lua.org, PUC-Rio.
462+* Copyright (C) 1994-2015 Lua.org, PUC-Rio.
463463 *
464464 * Permission is hereby granted, free of charge, to any person obtaining
465465 * a copy of this software and associated documentation files (the
src/luaconf.h+2−10
@@ -1,5 +1,5 @@
11 /*
2−** $Id: luaconf.h,v 1.236 2014/12/19 13:31:12 roberto Exp $
2+** $Id: luaconf.h,v 1.238 2014/12/29 13:27:55 roberto Exp $
33 ** Configuration file for Lua
44 ** See Copyright Notice in lua.h
55 */
@@ -476,7 +476,7 @@ · 470 unmodified lines
476476 #include <math.h>
477477
478478 /* floor division (defined as 'floor(a/b)') */
479−#define luai_numidiv(L,a,b) ((void)L, l_mathop(floor)((a)/(b)))
479+#define luai_numidiv(L,a,b) ((void)L, l_mathop(floor)(luai_numdiv(L,a,b)))
480480
481481 /*
482482 ** module: defined as 'a - floor(a/b)*b'; the previous definition gives
@@ -507,14 +507,6 @@ · 24 unmodified lines
507507 #endif
508508
509509
510−/*
511−** The following macro checks whether an operation is not safe to be
512−** performed by the constant folder. It should result in zero only if
513−** the operation is safe.
514−*/
515−#define luai_numinvalidop(op,a,b) 0
516−
517−
518510 /*
519511 @@ LUA_INTEGER is the integer type used by Lua.
520512 **
src/lvm.c+142−97
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lvm.c,v 2.231 2014/12/19 13:36:32 roberto Exp $
2+** $Id: lvm.c,v 2.232 2014/12/27 20:30:38 roberto Exp $
33 ** Lua virtual machine
44 ** See Copyright Notice in lua.h
55 */
@@ -644,8 +644,8 @@ void luaV_finishOp (lua_State *L) { · 638 unmodified lines
644644
645645
646646 #define vmdispatch(o) switch(o)
647−#define vmcase(l,b) case l: {b} break;
648−#define vmcasenb(l,b) case l: {b} /* nb = no break */
647+#define vmcase(l) case l:
648+#define vmbreak break
649649
650650 void luaV_execute (lua_State *L) {
651651 CallInfo *ci = L->ci;
@@ -670,53 +670,64 @@ void luaV_execute (lua_State *L) { · 18 unmodified lines
670670 lua_assert(base == ci->u.l.base);
671671 lua_assert(base <= L->top && L->top < L->stack + L->stacksize);
672672 vmdispatch (GET_OPCODE(i)) {
673− vmcase(OP_MOVE,
673+ vmcase(OP_MOVE) {
674674 setobjs2s(L, ra, RB(i));
675− )
676− vmcase(OP_LOADK,
675+ vmbreak;
676+ }
677+ vmcase(OP_LOADK) {
677678 TValue *rb = k + GETARG_Bx(i);
678679 setobj2s(L, ra, rb);
679− )
680− vmcase(OP_LOADKX,
680+ vmbreak;
681+ }
682+ vmcase(OP_LOADKX) {
681683 TValue *rb;
682684 lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_EXTRAARG);
683685 rb = k + GETARG_Ax(*ci->u.l.savedpc++);
684686 setobj2s(L, ra, rb);
685− )
686− vmcase(OP_LOADBOOL,
687+ vmbreak;
688+ }
689+ vmcase(OP_LOADBOOL) {
687690 setbvalue(ra, GETARG_B(i));
688691 if (GETARG_C(i)) ci->u.l.savedpc++; /* skip next instruction (if C) */
689− )
690− vmcase(OP_LOADNIL,
692+ vmbreak;
693+ }
694+ vmcase(OP_LOADNIL) {
691695 int b = GETARG_B(i);
692696 do {
693697 setnilvalue(ra++);
694698 } while (b--);
695− )
696− vmcase(OP_GETUPVAL,
699+ vmbreak;
700+ }
701+ vmcase(OP_GETUPVAL) {
697702 int b = GETARG_B(i);
698703 setobj2s(L, ra, cl->upvals[b]->v);
699− )
700− vmcase(OP_GETTABUP,
704+ vmbreak;
705+ }
706+ vmcase(OP_GETTABUP) {
701707 int b = GETARG_B(i);
702708 Protect(luaV_gettable(L, cl->upvals[b]->v, RKC(i), ra));
703− )
704− vmcase(OP_GETTABLE,
709+ vmbreak;
710+ }
711+ vmcase(OP_GETTABLE) {
705712 Protect(luaV_gettable(L, RB(i), RKC(i), ra));
706− )
707− vmcase(OP_SETTABUP,
713+ vmbreak;
714+ }
715+ vmcase(OP_SETTABUP) {
708716 int a = GETARG_A(i);
709717 Protect(luaV_settable(L, cl->upvals[a]->v, RKB(i), RKC(i)));
710− )
711− vmcase(OP_SETUPVAL,
718+ vmbreak;
719+ }
720+ vmcase(OP_SETUPVAL) {
712721 UpVal *uv = cl->upvals[GETARG_B(i)];
713722 setobj(L, uv->v, ra);
714723 luaC_upvalbarrier(L, uv);
715− )
716− vmcase(OP_SETTABLE,
724+ vmbreak;
725+ }
726+ vmcase(OP_SETTABLE) {
717727 Protect(luaV_settable(L, ra, RKB(i), RKC(i)));
718− )
719− vmcase(OP_NEWTABLE,
728+ vmbreak;
729+ }
730+ vmcase(OP_NEWTABLE) {
720731 int b = GETARG_B(i);
721732 int c = GETARG_C(i);
722733 Table *t = luaH_new(L);
@@ -724,13 +735,15 @@ void luaV_execute (lua_State *L) { · 1 unmodified line
724735 if (b != 0 || c != 0)
725736 luaH_resize(L, t, luaO_fb2int(b), luaO_fb2int(c));
726737 checkGC(L, ra + 1);
727− )
728− vmcase(OP_SELF,
738+ vmbreak;
739+ }
740+ vmcase(OP_SELF) {
729741 StkId rb = RB(i);
730742 setobjs2s(L, ra+1, rb);
731743 Protect(luaV_gettable(L, rb, RKC(i), ra));
732− )
733− vmcase(OP_ADD,
744+ vmbreak;
745+ }
746+ vmcase(OP_ADD) {
734747 TValue *rb = RKB(i);
735748 TValue *rc = RKC(i);
736749 lua_Number nb; lua_Number nc;
@@ -742,8 +755,9 @@ void luaV_execute (lua_State *L) { · 5 unmodified lines
742755 setfltvalue(ra, luai_numadd(L, nb, nc));
743756 }
744757 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_ADD)); }
745− )
746− vmcase(OP_SUB,
758+ vmbreak;
759+ }
760+ vmcase(OP_SUB) {
747761 TValue *rb = RKB(i);
748762 TValue *rc = RKC(i);
749763 lua_Number nb; lua_Number nc;
@@ -755,8 +769,9 @@ void luaV_execute (lua_State *L) { · 5 unmodified lines
755769 setfltvalue(ra, luai_numsub(L, nb, nc));
756770 }
757771 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_SUB)); }
758− )
759− vmcase(OP_MUL,
772+ vmbreak;
773+ }
774+ vmcase(OP_MUL) {
760775 TValue *rb = RKB(i);
761776 TValue *rc = RKC(i);
762777 lua_Number nb; lua_Number nc;
@@ -768,8 +783,9 @@ void luaV_execute (lua_State *L) { · 5 unmodified lines
768783 setfltvalue(ra, luai_nummul(L, nb, nc));
769784 }
770785 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_MUL)); }
771− )
772− vmcase(OP_DIV, /* float division (always with floats) */
786+ vmbreak;
787+ }
788+ vmcase(OP_DIV) { /* float division (always with floats) */
773789 TValue *rb = RKB(i);
774790 TValue *rc = RKC(i);
775791 lua_Number nb; lua_Number nc;
@@ -777,8 +793,9 @@ void luaV_execute (lua_State *L) { · 1 unmodified line
777793 setfltvalue(ra, luai_numdiv(L, nb, nc));
778794 }
779795 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_DIV)); }
780− )
781− vmcase(OP_BAND,
796+ vmbreak;
797+ }
798+ vmcase(OP_BAND) {
782799 TValue *rb = RKB(i);
783800 TValue *rc = RKC(i);
784801 lua_Integer ib; lua_Integer ic;
@@ -786,8 +803,9 @@ void luaV_execute (lua_State *L) { · 1 unmodified line
786803 setivalue(ra, intop(&, ib, ic));
787804 }
788805 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_BAND)); }
789− )
790− vmcase(OP_BOR,
806+ vmbreak;
807+ }
808+ vmcase(OP_BOR) {
791809 TValue *rb = RKB(i);
792810 TValue *rc = RKC(i);
793811 lua_Integer ib; lua_Integer ic;
@@ -795,8 +813,9 @@ void luaV_execute (lua_State *L) { · 1 unmodified line
795813 setivalue(ra, intop(|, ib, ic));
796814 }
797815 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_BOR)); }
798− )
799− vmcase(OP_BXOR,
816+ vmbreak;
817+ }
818+ vmcase(OP_BXOR) {
800819 TValue *rb = RKB(i);
801820 TValue *rc = RKC(i);
802821 lua_Integer ib; lua_Integer ic;
@@ -804,8 +823,9 @@ void luaV_execute (lua_State *L) { · 1 unmodified line
804823 setivalue(ra, intop(^, ib, ic));
805824 }
806825 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_BXOR)); }
807− )
808− vmcase(OP_SHL,
826+ vmbreak;
827+ }
828+ vmcase(OP_SHL) {
809829 TValue *rb = RKB(i);
810830 TValue *rc = RKC(i);
811831 lua_Integer ib; lua_Integer ic;
@@ -813,8 +833,9 @@ void luaV_execute (lua_State *L) { · 1 unmodified line
813833 setivalue(ra, luaV_shiftl(ib, ic));
814834 }
815835 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_SHL)); }
816− )
817− vmcase(OP_SHR,
836+ vmbreak;
837+ }
838+ vmcase(OP_SHR) {
818839 TValue *rb = RKB(i);
819840 TValue *rc = RKC(i);
820841 lua_Integer ib; lua_Integer ic;
@@ -822,8 +843,9 @@ void luaV_execute (lua_State *L) { · 1 unmodified line
822843 setivalue(ra, luaV_shiftl(ib, -ic));
823844 }
824845 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_SHR)); }
825− )
826− vmcase(OP_MOD,
846+ vmbreak;
847+ }
848+ vmcase(OP_MOD) {
827849 TValue *rb = RKB(i);
828850 TValue *rc = RKC(i);
829851 lua_Number nb; lua_Number nc;
@@ -837,8 +859,9 @@ void luaV_execute (lua_State *L) { · 7 unmodified lines
837859 setfltvalue(ra, m);
838860 }
839861 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_MOD)); }
840− )
841− vmcase(OP_IDIV, /* floor division */
862+ vmbreak;
863+ }
864+ vmcase(OP_IDIV) { /* floor division */
842865 TValue *rb = RKB(i);
843866 TValue *rc = RKC(i);
844867 lua_Number nb; lua_Number nc;
@@ -850,8 +873,9 @@ void luaV_execute (lua_State *L) { · 5 unmodified lines
850873 setfltvalue(ra, luai_numidiv(L, nb, nc));
851874 }
852875 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_IDIV)); }
853− )
854− vmcase(OP_POW,
876+ vmbreak;
877+ }
878+ vmcase(OP_POW) {
855879 TValue *rb = RKB(i);
856880 TValue *rc = RKC(i);
857881 lua_Number nb; lua_Number nc;
@@ -859,8 +883,9 @@ void luaV_execute (lua_State *L) { · 1 unmodified line
859883 setfltvalue(ra, luai_numpow(L, nb, nc));
860884 }
861885 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_POW)); }
862− )
863− vmcase(OP_UNM,
886+ vmbreak;
887+ }
888+ vmcase(OP_UNM) {
864889 TValue *rb = RB(i);
865890 lua_Number nb;
866891 if (ttisinteger(rb)) {
@@ -873,8 +898,9 @@ void luaV_execute (lua_State *L) { · 6 unmodified lines
873898 else {
874899 Protect(luaT_trybinTM(L, rb, rb, ra, TM_UNM));
875900 }
876− )
877− vmcase(OP_BNOT,
901+ vmbreak;
902+ }
903+ vmcase(OP_BNOT) {
878904 TValue *rb = RB(i);
879905 lua_Integer ib;
880906 if (tointeger(rb, &ib)) {
@@ -883,16 +909,19 @@ void luaV_execute (lua_State *L) { · 2 unmodified lines
883909 else {
884910 Protect(luaT_trybinTM(L, rb, rb, ra, TM_BNOT));
885911 }
886− )
887− vmcase(OP_NOT,
912+ vmbreak;
913+ }
914+ vmcase(OP_NOT) {
888915 TValue *rb = RB(i);
889916 int res = l_isfalse(rb); /* next assignment may change this value */
890917 setbvalue(ra, res);
891− )
892− vmcase(OP_LEN,
918+ vmbreak;
919+ }
920+ vmcase(OP_LEN) {
893921 Protect(luaV_objlen(L, ra, RB(i)));
894− )
895− vmcase(OP_CONCAT,
922+ vmbreak;
923+ }
924+ vmcase(OP_CONCAT) {
896925 int b = GETARG_B(i);
897926 int c = GETARG_C(i);
898927 StkId rb;
@@ -903,11 +932,13 @@ void luaV_execute (lua_State *L) { · 4 unmodified lines
903932 setobjs2s(L, ra, rb);
904933 checkGC(L, (ra >= rb ? ra + 1 : rb));
905934 L->top = ci->top; /* restore top */
906− )
907− vmcase(OP_JMP,
935+ vmbreak;
936+ }
937+ vmcase(OP_JMP) {
908938 dojump(ci, i, 0);
909− )
910− vmcase(OP_EQ,
939+ vmbreak;
940+ }
941+ vmcase(OP_EQ) {
911942 TValue *rb = RKB(i);
912943 TValue *rc = RKC(i);
913944 Protect(
@@ -916,30 +947,34 @@ void luaV_execute (lua_State *L) { · 2 unmodified lines
916947 else
917948 donextjump(ci);
918949 )
919− )
920− vmcase(OP_LT,
950+ vmbreak;
951+ }
952+ vmcase(OP_LT) {
921953 Protect(
922954 if (luaV_lessthan(L, RKB(i), RKC(i)) != GETARG_A(i))
923955 ci->u.l.savedpc++;
924956 else
925957 donextjump(ci);
926958 )
927− )
928− vmcase(OP_LE,
959+ vmbreak;
960+ }
961+ vmcase(OP_LE) {
929962 Protect(
930963 if (luaV_lessequal(L, RKB(i), RKC(i)) != GETARG_A(i))
931964 ci->u.l.savedpc++;
932965 else
933966 donextjump(ci);
934967 )
935− )
936− vmcase(OP_TEST,
968+ vmbreak;
969+ }
970+ vmcase(OP_TEST) {
937971 if (GETARG_C(i) ? l_isfalse(ra) : !l_isfalse(ra))
938972 ci->u.l.savedpc++;
939973 else
940974 donextjump(ci);
941− )
942− vmcase(OP_TESTSET,
975+ vmbreak;
976+ }
977+ vmcase(OP_TESTSET) {
943978 TValue *rb = RB(i);
944979 if (GETARG_C(i) ? l_isfalse(rb) : !l_isfalse(rb))
945980 ci->u.l.savedpc++;
@@ -947,8 +982,9 @@ void luaV_execute (lua_State *L) { · 1 unmodified line
947982 setobjs2s(L, ra, rb);
948983 donextjump(ci);
949984 }
950− )
951− vmcase(OP_CALL,
985+ vmbreak;
986+ }
987+ vmcase(OP_CALL) {
952988 int b = GETARG_B(i);
953989 int nresults = GETARG_C(i) - 1;
954990 if (b != 0) L->top = ra+b; /* else previous instruction set top */
@@ -961,8 +997,9 @@ void luaV_execute (lua_State *L) { · 6 unmodified lines
961997 ci->callstatus |= CIST_REENTRY;
962998 goto newframe; /* restart luaV_execute over new Lua function */
963999 }
964− )
965− vmcase(OP_TAILCALL,
1000+ vmbreak;
1001+ }
1002+ vmcase(OP_TAILCALL) {
9661003 int b = GETARG_B(i);
9671004 if (b != 0) L->top = ra+b; /* else previous instruction set top */
9681005 lua_assert(GETARG_C(i) - 1 == LUA_MULTRET);
@@ -990,8 +1027,9 @@ void luaV_execute (lua_State *L) { · 21 unmodified lines
9901027 lua_assert(L->top == oci->u.l.base + getproto(ofunc)->maxstacksize);
9911028 goto newframe; /* restart luaV_execute over new Lua function */
9921029 }
993− )
994− vmcasenb(OP_RETURN,
1030+ vmbreak;
1031+ }
1032+ vmcase(OP_RETURN) {
9951033 int b = GETARG_B(i);
9961034 if (b != 0) L->top = ra+b-1;
9971035 if (cl->p->sizep > 0) luaF_close(L, base);
@@ -1005,8 +1043,8 @@ void luaV_execute (lua_State *L) { · 7 unmodified lines
10051043 lua_assert(GET_OPCODE(*((ci)->u.l.savedpc - 1)) == OP_CALL);
10061044 goto newframe; /* restart luaV_execute over new Lua function */
10071045 }
1008− )
1009− vmcase(OP_FORLOOP,
1046+ }
1047+ vmcase(OP_FORLOOP) {
10101048 if (ttisinteger(ra)) { /* integer loop? */
10111049 lua_Integer step = ivalue(ra + 2);
10121050 lua_Integer idx = ivalue(ra) + step; /* increment index */
@@ -1028,8 +1066,9 @@ void luaV_execute (lua_State *L) { · 15 unmodified lines
10281066 setfltvalue(ra + 3, idx); /* ...and external index */
10291067 }
10301068 }
1031− )
1032− vmcase(OP_FORPREP,
1069+ vmbreak;
1070+ }
1071+ vmcase(OP_FORPREP) {
10331072 TValue *init = ra;
10341073 TValue *plimit = ra + 1;
10351074 TValue *pstep = ra + 2;
@@ -1055,8 +1094,9 @@ void luaV_execute (lua_State *L) { · 19 unmodified lines
10551094 setfltvalue(init, luai_numsub(L, ninit, nstep));
10561095 }
10571096 ci->u.l.savedpc += GETARG_sBx(i);
1058− )
1059− vmcasenb(OP_TFORCALL,
1097+ vmbreak;
1098+ }
1099+ vmcase(OP_TFORCALL) {
10601100 StkId cb = ra + 3; /* call base */
10611101 setobjs2s(L, cb+2, ra+2);
10621102 setobjs2s(L, cb+1, ra+1);
@@ -1068,15 +1108,16 @@ void luaV_execute (lua_State *L) { · 5 unmodified lines
10681108 ra = RA(i);
10691109 lua_assert(GET_OPCODE(i) == OP_TFORLOOP);
10701110 goto l_tforloop;
1071− )
1072− vmcase(OP_TFORLOOP,
1111+ }
1112+ vmcase(OP_TFORLOOP) {
10731113 l_tforloop:
10741114 if (!ttisnil(ra + 1)) { /* continue loop? */
10751115 setobjs2s(L, ra, ra + 1); /* save control variable */
10761116 ci->u.l.savedpc += GETARG_sBx(i); /* jump back */
10771117 }
1078− )
1079− vmcase(OP_SETLIST,
1118+ vmbreak;
1119+ }
1120+ vmcase(OP_SETLIST) {
10801121 int n = GETARG_B(i);
10811122 int c = GETARG_C(i);
10821123 unsigned int last;
@@ -1097,8 +1138,9 @@ void luaV_execute (lua_State *L) { · 14 unmodified lines
10971138 luaC_barrierback(L, h, val);
10981139 }
10991140 L->top = ci->top; /* correct top (in case of previous open call) */
1100− )
1101− vmcase(OP_CLOSURE,
1141+ vmbreak;
1142+ }
1143+ vmcase(OP_CLOSURE) {
11021144 Proto *p = cl->p->p[GETARG_Bx(i)];
11031145 LClosure *ncl = getcached(p, cl->upvals, base); /* cached closure */
11041146 if (ncl == NULL) /* no match? */
@@ -1106,8 +1148,9 @@ void luaV_execute (lua_State *L) { · 1 unmodified line
11061148 else
11071149 setclLvalue(L, ra, ncl); /* push cashed closure */
11081150 checkGC(L, ra + 1);
1109− )
1110− vmcase(OP_VARARG,
1151+ vmbreak;
1152+ }
1153+ vmcase(OP_VARARG) {
11111154 int b = GETARG_B(i) - 1;
11121155 int j;
11131156 int n = cast_int(base - ci->func) - cl->p->numparams - 1;
@@ -1125,10 +1168,12 @@ void luaV_execute (lua_State *L) { · 11 unmodified lines
11251168 setnilvalue(ra + j);
11261169 }
11271170 }
1128− )
1129− vmcase(OP_EXTRAARG,
1171+ vmbreak;
1172+ }
1173+ vmcase(OP_EXTRAARG) {
11301174 lua_assert(0);
1131− )
1175+ vmbreak;
1176+ }
11321177 }
11331178 }
11341179 }