History

Lua 5.2.2

Lua Team committed 13 years ago

Commit 2e785bd1 parent 46b413e12 files · +51 −36Browse files

Unified · Split

12 files
  1. README +1 −1
  2. doc/contents.html +5 −5
  3. doc/manual.html +3 −3
  4. src/lapi.c +2 −2
  5. src/lauxlib.c +2 −2
  6. src/lbitlib.c +5 −3
  7. src/lgc.c +3 −3
  8. src/liolib.c +17 −9
  9. src/llex.c +2 −2
  10. src/lua.h +6 −1
  11. src/luaconf.h +3 −3
  12. src/lvm.c +2 −2
README+1−1
@@ -1,5 +1,5 @@
1 1
2This is Lua 5.2.2, released on 7 Mar 2013.2This is Lua 5.2.2, released on 21 Mar 2013.
3 3
4For installation instructions, license details, and4For installation instructions, license details, and
5further information about Lua, see doc/readme.html.5further information about Lua, see doc/readme.html.
doc/contents.html+5−5
@@ -149,8 +149,8 @@ Freely available under the terms of the · 148 unmodified lines
149<A HREF="manual.html#pdf-error">error</A><BR>149<A HREF="manual.html#pdf-error">error</A><BR>
150<A HREF="manual.html#pdf-getmetatable">getmetatable</A><BR>150<A HREF="manual.html#pdf-getmetatable">getmetatable</A><BR>
151<A HREF="manual.html#pdf-ipairs">ipairs</A><BR>151<A HREF="manual.html#pdf-ipairs">ipairs</A><BR>
152<A HREF="manual.html#pdf-loadfile">loadfile</A><BR>
153<A HREF="manual.html#pdf-load">load</A><BR>152<A HREF="manual.html#pdf-load">load</A><BR>
153<A HREF="manual.html#pdf-loadfile">loadfile</A><BR>
154<A HREF="manual.html#pdf-next">next</A><BR>154<A HREF="manual.html#pdf-next">next</A><BR>
155<A HREF="manual.html#pdf-pairs">pairs</A><BR>155<A HREF="manual.html#pdf-pairs">pairs</A><BR>
156<A HREF="manual.html#pdf-pcall">pcall</A><BR>156<A HREF="manual.html#pdf-pcall">pcall</A><BR>
@@ -400,10 +400,10 @@ Freely available under the terms of the · 243 unmodified lines
400<A HREF="manual.html#lua_rawequal">lua_rawequal</A><BR>400<A HREF="manual.html#lua_rawequal">lua_rawequal</A><BR>
401<A HREF="manual.html#lua_rawget">lua_rawget</A><BR>401<A HREF="manual.html#lua_rawget">lua_rawget</A><BR>
402<A HREF="manual.html#lua_rawgeti">lua_rawgeti</A><BR>402<A HREF="manual.html#lua_rawgeti">lua_rawgeti</A><BR>
403<A HREF="manual.html#lua_rawgetp">lua_rawgetp</A><BR>
403<A HREF="manual.html#lua_rawlen">lua_rawlen</A><BR>404<A HREF="manual.html#lua_rawlen">lua_rawlen</A><BR>
404<A HREF="manual.html#lua_rawset">lua_rawset</A><BR>405<A HREF="manual.html#lua_rawset">lua_rawset</A><BR>
405<A HREF="manual.html#lua_rawseti">lua_rawseti</A><BR>406<A HREF="manual.html#lua_rawseti">lua_rawseti</A><BR>
406<A HREF="manual.html#lua_rawgetp">lua_rawgetp</A><BR>
407<A HREF="manual.html#lua_rawsetp">lua_rawsetp</A><BR>407<A HREF="manual.html#lua_rawsetp">lua_rawsetp</A><BR>
408<A HREF="manual.html#lua_register">lua_register</A><BR>408<A HREF="manual.html#lua_register">lua_register</A><BR>
409<A HREF="manual.html#lua_remove">lua_remove</A><BR>409<A HREF="manual.html#lua_remove">lua_remove</A><BR>
@@ -462,8 +462,8 @@ Freely available under the terms of the · 52 unmodified lines
462<A HREF="manual.html#luaL_buffinitsize">luaL_buffinitsize</A><BR>462<A HREF="manual.html#luaL_buffinitsize">luaL_buffinitsize</A><BR>
463<A HREF="manual.html#luaL_callmeta">luaL_callmeta</A><BR>463<A HREF="manual.html#luaL_callmeta">luaL_callmeta</A><BR>
464<A HREF="manual.html#luaL_checkany">luaL_checkany</A><BR>464<A HREF="manual.html#luaL_checkany">luaL_checkany</A><BR>
465<A HREF="manual.html#luaL_checkinteger">luaL_checkinteger</A><BR>
466<A HREF="manual.html#luaL_checkint">luaL_checkint</A><BR>465<A HREF="manual.html#luaL_checkint">luaL_checkint</A><BR>
466<A HREF="manual.html#luaL_checkinteger">luaL_checkinteger</A><BR>
467<A HREF="manual.html#luaL_checklong">luaL_checklong</A><BR>467<A HREF="manual.html#luaL_checklong">luaL_checklong</A><BR>
468<A HREF="manual.html#luaL_checklstring">luaL_checklstring</A><BR>468<A HREF="manual.html#luaL_checklstring">luaL_checklstring</A><BR>
469<A HREF="manual.html#luaL_checknumber">luaL_checknumber</A><BR>469<A HREF="manual.html#luaL_checknumber">luaL_checknumber</A><BR>
@@ -494,8 +494,8 @@ Freely available under the terms of the · 24 unmodified lines
494<A HREF="manual.html#luaL_newmetatable">luaL_newmetatable</A><BR>494<A HREF="manual.html#luaL_newmetatable">luaL_newmetatable</A><BR>
495<A HREF="manual.html#luaL_newstate">luaL_newstate</A><BR>495<A HREF="manual.html#luaL_newstate">luaL_newstate</A><BR>
496<A HREF="manual.html#luaL_openlibs">luaL_openlibs</A><BR>496<A HREF="manual.html#luaL_openlibs">luaL_openlibs</A><BR>
497<A HREF="manual.html#luaL_optinteger">luaL_optinteger</A><BR>
498<A HREF="manual.html#luaL_optint">luaL_optint</A><BR>497<A HREF="manual.html#luaL_optint">luaL_optint</A><BR>
498<A HREF="manual.html#luaL_optinteger">luaL_optinteger</A><BR>
499<A HREF="manual.html#luaL_optlong">luaL_optlong</A><BR>499<A HREF="manual.html#luaL_optlong">luaL_optlong</A><BR>
500<A HREF="manual.html#luaL_optlstring">luaL_optlstring</A><BR>500<A HREF="manual.html#luaL_optlstring">luaL_optlstring</A><BR>
501<A HREF="manual.html#luaL_optnumber">luaL_optnumber</A><BR>501<A HREF="manual.html#luaL_optnumber">luaL_optnumber</A><BR>
@@ -523,7 +523,7 @@ Freely available under the terms of the · 21 unmodified lines
523<HR>523<HR>
524<SMALL CLASS="footer">524<SMALL CLASS="footer">
525Last update:525Last update:
526Tue Feb 19 15:14:47 BRT 2013526Tue Mar 12 11:22:18 BRT 2013
527</SMALL>527</SMALL>
528<!--528<!--
529Last change: revised for Lua 5.2.2529Last change: revised for Lua 5.2.2
doc/manual.html+3−3
@@ -33,7 +33,7 @@ Freely available under the terms of the · 32 unmodified lines
33<!-- ====================================================================== -->33<!-- ====================================================================== -->
34<p>34<p>
35 35
36<!-- $Id: manual.of,v 1.102 2013/03/07 18:25:28 roberto Exp $ -->36<!-- $Id: manual.of,v 1.103 2013/03/14 18:51:56 roberto Exp $ -->
37 37
38 38
39 39
@@ -8417,7 +8417,7 @@ When <code>pos</code> is an integer between 1 and <code>#list</code>, · 8377 unmodified lines
8417it shifts down the elements8417it shifts down the elements
8418<code>list[pos+1], list[pos+2], &middot;&middot;&middot;, list[#list]</code>8418<code>list[pos+1], list[pos+2], &middot;&middot;&middot;, list[#list]</code>
8419and erases element <code>list[#list]</code>;8419and erases element <code>list[#list]</code>;
8420The index <code>pos</code> can also be 0, when <code>#list</code> is 0,8420The index <code>pos</code> can also be 0 when <code>#list</code> is 0,
8421or <code>#list + 1</code>;8421or <code>#list + 1</code>;
8422in those cases, the function erases the element <code>list[pos]</code>.8422in those cases, the function erases the element <code>list[pos]</code>.
8423 8423
@@ -10497,7 +10497,7 @@ Here is the complete syntax of Lua in extended BNF. · 2073 unmodified lines
10497<HR>10497<HR>
10498<SMALL CLASS="footer">10498<SMALL CLASS="footer">
10499Last update:10499Last update:
10500Thu Mar 7 15:36:34 BRT 201310500Thu Mar 21 12:58:59 BRT 2013
10501</SMALL>10501</SMALL>
10502<!--10502<!--
10503Last change: revised for Lua 5.2.210503Last change: revised for Lua 5.2.2
src/lapi.c+2−2
@@ -1,5 +1,5 @@
1/*1/*
2** $Id: lapi.c,v 2.170 2012/12/05 19:49:55 roberto Exp $2** $Id: lapi.c,v 2.171 2013/03/16 21:10:18 roberto Exp $
3** Lua API3** Lua API
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
@@ -1106,7 +1106,7 @@ LUA_API int lua_error (lua_State *L) { · 1100 unmodified lines
1106 lua_lock(L);1106 lua_lock(L);
1107 api_checknelems(L, 1);1107 api_checknelems(L, 1);
1108 luaG_errormsg(L);1108 luaG_errormsg(L);
1109 /* code unreacheable; will unlock when control actually leaves the kernel */1109 /* code unreachable; will unlock when control actually leaves the kernel */
1110 return 0; /* to avoid warnings */1110 return 0; /* to avoid warnings */
1111}1111}
1112 1112
src/lauxlib.c+2−2
@@ -1,5 +1,5 @@
1/*1/*
2** $Id: lauxlib.c,v 1.247 2012/10/19 15:55:01 roberto Exp $2** $Id: lauxlib.c,v 1.248 2013/03/21 13:54:57 roberto Exp $
3** Auxiliary functions for building Lua libraries3** Auxiliary functions for building Lua libraries
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
@@ -599,7 +599,7 @@ static int skipBOM (LoadF *lf) { · 593 unmodified lines
599 lf->n = 0;599 lf->n = 0;
600 do {600 do {
601 c = getc(lf->f);601 c = getc(lf->f);
602 if (c == EOF || c != *(unsigned char *)p++) return c;602 if (c == EOF || c != *(const unsigned char *)p++) return c;
603 lf->buff[lf->n++] = c; /* to be read by the parser */603 lf->buff[lf->n++] = c; /* to be read by the parser */
604 } while (*p != '\0');604 } while (*p != '\0');
605 lf->n = 0; /* prefix matched; discard it */605 lf->n = 0; /* prefix matched; discard it */
src/lbitlib.c+5−3
@@ -1,5 +1,5 @@
1/*1/*
2** $Id: lbitlib.c,v 1.17 2013/02/21 13:44:53 roberto Exp $2** $Id: lbitlib.c,v 1.18 2013/03/19 13:19:12 roberto Exp $
3** Standard library for bitwise operations3** Standard library for bitwise operations
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
@@ -147,7 +147,9 @@ static int b_rrot (lua_State *L) { · 141 unmodified lines
147 147
148/*148/*
149** get field and width arguments for field-manipulation functions,149** get field and width arguments for field-manipulation functions,
150** checking whether they are valid150** checking whether they are valid.
151** ('luaL_error' called without 'return' to avoid later warnings about
152** 'width' being used uninitialized.)
151*/153*/
152static int fieldargs (lua_State *L, int farg, int *width) {154static int fieldargs (lua_State *L, int farg, int *width) {
153 int f = luaL_checkint(L, farg);155 int f = luaL_checkint(L, farg);
@@ -155,7 +157,7 @@ static int fieldargs (lua_State *L, int farg, int *width) { · 1 unmodified line
155 luaL_argcheck(L, 0 <= f, farg, "field cannot be negative");157 luaL_argcheck(L, 0 <= f, farg, "field cannot be negative");
156 luaL_argcheck(L, 0 < w, farg + 1, "width must be positive");158 luaL_argcheck(L, 0 < w, farg + 1, "width must be positive");
157 if (f + w > LUA_NBITS)159 if (f + w > LUA_NBITS)
158 return luaL_error(L, "trying to access non-existent bits");160 luaL_error(L, "trying to access non-existent bits");
159 *width = w;161 *width = w;
160 return f;162 return f;
161}163}
src/lgc.c+3−3
@@ -1,5 +1,5 @@
1/*1/*
2** $Id: lgc.c,v 2.138 2012/10/19 19:00:33 roberto Exp $2** $Id: lgc.c,v 2.140 2013/03/16 21:10:18 roberto Exp $
3** Garbage Collector3** Garbage Collector
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
@@ -450,7 +450,7 @@ static lu_mem traversetable (global_State *g, Table *h) { · 444 unmodified lines
450 else /* not weak */450 else /* not weak */
451 traversestrongtable(g, h);451 traversestrongtable(g, h);
452 return sizeof(Table) + sizeof(TValue) * h->sizearray +452 return sizeof(Table) + sizeof(TValue) * h->sizearray +
453 sizeof(Node) * sizenode(h);453 sizeof(Node) * cast(size_t, sizenode(h));
454}454}
455 455
456 456
@@ -924,7 +924,7 @@ static void setpause (global_State *g, l_mem estimate) { · 467 unmodified lines
924** object inside the list (instead of to the header), so that the real924** object inside the list (instead of to the header), so that the real
925** sweep do not need to skip objects created between "now" and the start925** sweep do not need to skip objects created between "now" and the start
926** of the real sweep.926** of the real sweep.
927** Returns how many objects it sweeped.927** Returns how many objects it swept.
928*/928*/
929static int entersweep (lua_State *L) {929static int entersweep (lua_State *L) {
930 global_State *g = G(L);930 global_State *g = G(L);
src/liolib.c+17−9
@@ -1,5 +1,5 @@
1/*1/*
2** $Id: liolib.c,v 2.108 2011/11/25 12:50:03 roberto Exp $2** $Id: liolib.c,v 2.111 2013/03/21 13:57:27 roberto Exp $
3** Standard I/O (and system) library3** Standard I/O (and system) library
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
@@ -29,6 +29,20 @@ · 23 unmodified lines
29#include "lualib.h"29#include "lualib.h"
30 30
31 31
32#if !defined(lua_checkmode)
33
34/*
35** Check whether 'mode' matches '[rwa]%+?b?'.
36** Change this macro to accept other modes for 'fopen' besides
37** the standard ones.
38*/
39#define lua_checkmode(mode) \
40 (*mode != '\0' && strchr("rwa", *(mode++)) != NULL && \
41 (*mode != '+' || ++mode) && /* skip if char is '+' */ \
42 (*mode != 'b' || ++mode) && /* skip if char is 'b' */ \
43 (*mode == '\0'))
44
45#endif
32 46
33/*47/*
34** {======================================================48** {======================================================
@@ -212,14 +226,8 @@ static int io_open (lua_State *L) { · 177 unmodified lines
212 const char *filename = luaL_checkstring(L, 1);226 const char *filename = luaL_checkstring(L, 1);
213 const char *mode = luaL_optstring(L, 2, "r");227 const char *mode = luaL_optstring(L, 2, "r");
214 LStream *p = newfile(L);228 LStream *p = newfile(L);
215 int i = 0;229 const char *md = mode; /* to traverse/check mode */
216 /* check whether 'mode' matches '[rwa]%+?b?' */230 luaL_argcheck(L, lua_checkmode(md), 2, "invalid mode");
217 if (!(mode[i] != '\0' && strchr("rwa", mode[i++]) != NULL &&
218 (mode[i] != '+' || ++i) && /* skip if char is '+' */
219 (mode[i] != 'b' || ++i) && /* skip if char is 'b' */
220 (mode[i] == '\0')))
221 return luaL_error(L, "invalid mode " LUA_QS
222 " (should match " LUA_QL("[rwa]%%+?b?") ")", mode);
223 p->f = fopen(filename, mode);231 p->f = fopen(filename, mode);
224 return (p->f == NULL) ? luaL_fileresult(L, 0, filename) : 1;232 return (p->f == NULL) ? luaL_fileresult(L, 0, filename) : 1;
225}233}
src/llex.c+2−2
@@ -1,5 +1,5 @@
1/*1/*
2** $Id: llex.c,v 2.62 2012/12/05 19:57:00 roberto Exp $2** $Id: llex.c,v 2.63 2013/03/16 21:10:18 roberto Exp $
3** Lexical Analyzer3** Lexical Analyzer
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
@@ -313,7 +313,7 @@ static int readhexaesc (LexState *ls) { · 307 unmodified lines
313 int c[3], i; /* keep input for error message */313 int c[3], i; /* keep input for error message */
314 int r = 0; /* result accumulator */314 int r = 0; /* result accumulator */
315 c[0] = 'x'; /* for error message */315 c[0] = 'x'; /* for error message */
316 for (i = 1; i < 3; i++) { /* read two hexa digits */316 for (i = 1; i < 3; i++) { /* read two hexadecimal digits */
317 c[i] = next(ls);317 c[i] = next(ls);
318 if (!lisxdigit(c[i]))318 if (!lisxdigit(c[i]))
319 escerror(ls, c, i + 1, "hexadecimal digit expected");319 escerror(ls, c, i + 1, "hexadecimal digit expected");
src/lua.h+6−1
@@ -1,5 +1,5 @@
1/*1/*
2** $Id: lua.h,v 1.284 2013/02/19 18:39:04 roberto Exp $2** $Id: lua.h,v 1.285 2013/03/15 13:04:22 roberto Exp $
3** Lua - A Scripting Language3** Lua - A Scripting Language
4** Lua.org, PUC-Rio, Brazil (http://www.lua.org)4** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
5** See Copyright Notice at the end of this file5** See Copyright Notice at the end of this file
@@ -119,6 +119,11 @@ typedef LUA_UNSIGNED lua_Unsigned; · 113 unmodified lines
119#endif119#endif
120 120
121 121
122/*
123** RCS ident string
124*/
125extern const char lua_ident[];
126
122 127
123/*128/*
124** state manipulation129** state manipulation
src/luaconf.h+3−3
@@ -1,5 +1,5 @@
1/*1/*
2** $Id: luaconf.h,v 1.175 2013/01/29 16:00:40 roberto Exp $2** $Id: luaconf.h,v 1.176 2013/03/16 21:10:18 roberto Exp $
3** Configuration file for Lua3** Configuration file for Lua
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
@@ -44,7 +44,7 @@ · 38 unmodified lines
44#define LUA_USE_POSIX44#define LUA_USE_POSIX
45#define LUA_USE_DLOPEN /* needs an extra library: -ldl */45#define LUA_USE_DLOPEN /* needs an extra library: -ldl */
46#define LUA_USE_READLINE /* needs some extra libraries */46#define LUA_USE_READLINE /* needs some extra libraries */
47#define LUA_USE_STRTODHEX /* assume 'strtod' handles hexa formats */47#define LUA_USE_STRTODHEX /* assume 'strtod' handles hex formats */
48#define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */48#define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */
49#define LUA_USE_LONGLONG /* assume support for long long */49#define LUA_USE_LONGLONG /* assume support for long long */
50#endif50#endif
@@ -53,7 +53,7 @@ · 2 unmodified lines
53#define LUA_USE_POSIX53#define LUA_USE_POSIX
54#define LUA_USE_DLOPEN /* does not need -ldl */54#define LUA_USE_DLOPEN /* does not need -ldl */
55#define LUA_USE_READLINE /* needs an extra library: -lreadline */55#define LUA_USE_READLINE /* needs an extra library: -lreadline */
56#define LUA_USE_STRTODHEX /* assume 'strtod' handles hexa formats */56#define LUA_USE_STRTODHEX /* assume 'strtod' handles hex formats */
57#define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */57#define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */
58#define LUA_USE_LONGLONG /* assume support for long long */58#define LUA_USE_LONGLONG /* assume support for long long */
59#endif59#endif
src/lvm.c+2−2
@@ -1,5 +1,5 @@
1/*1/*
2** $Id: lvm.c,v 2.154 2012/08/16 17:34:28 roberto Exp $2** $Id: lvm.c,v 2.155 2013/03/16 21:10:18 roberto Exp $
3** Lua virtual machine3** Lua virtual machine
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
@@ -83,7 +83,7 @@ static void traceexec (lua_State *L) { · 77 unmodified lines
83 if (counthook)83 if (counthook)
84 L->hookcount = 1; /* undo decrement to zero */84 L->hookcount = 1; /* undo decrement to zero */
85 ci->u.l.savedpc--; /* undo increment (resume will increment it again) */85 ci->u.l.savedpc--; /* undo increment (resume will increment it again) */
86 ci->callstatus |= CIST_HOOKYIELD; /* mark that it yieled */86 ci->callstatus |= CIST_HOOKYIELD; /* mark that it yielded */
87 ci->func = L->top - 1; /* protect stack below results */87 ci->func = L->top - 1; /* protect stack below results */
88 luaD_throw(L, LUA_YIELD);88 luaD_throw(L, LUA_YIELD);
89 }89 }