History

Lua 5.2.2

Lua Team committed 13 years ago

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

Showing the changes to src (9 of 12 files). Show all

Unified · Split

9 files
  1. src/lapi.c +2 −2
  2. src/lauxlib.c +2 −2
  3. src/lbitlib.c +5 −3
  4. src/lgc.c +3 −3
  5. src/liolib.c +17 −9
  6. src/llex.c +2 −2
  7. src/lua.h +6 −1
  8. src/luaconf.h +3 −3
  9. src/lvm.c +2 −2
src/lapi.c+2−2
@@ -1,5 +1,5 @@
11 /*
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 $
33 ** Lua API
44 ** See Copyright Notice in lua.h
55 */
@@ -1106,7 +1106,7 @@ LUA_API int lua_error (lua_State *L) { · 1100 unmodified lines
11061106 lua_lock(L);
11071107 api_checknelems(L, 1);
11081108 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 */
11101110 return 0; /* to avoid warnings */
11111111 }
11121112
src/lauxlib.c+2−2
@@ -1,5 +1,5 @@
11 /*
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 $
33 ** Auxiliary functions for building Lua libraries
44 ** See Copyright Notice in lua.h
55 */
@@ -599,7 +599,7 @@ static int skipBOM (LoadF *lf) { · 593 unmodified lines
599599 lf->n = 0;
600600 do {
601601 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;
603603 lf->buff[lf->n++] = c; /* to be read by the parser */
604604 } while (*p != '\0');
605605 lf->n = 0; /* prefix matched; discard it */
src/lbitlib.c+5−3
@@ -1,5 +1,5 @@
11 /*
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 $
33 ** Standard library for bitwise operations
44 ** See Copyright Notice in lua.h
55 */
@@ -147,7 +147,9 @@ static int b_rrot (lua_State *L) { · 141 unmodified lines
147147
148148 /*
149149 ** get field and width arguments for field-manipulation functions,
150−** checking whether they are valid
150+** checking whether they are valid.
151+** ('luaL_error' called without 'return' to avoid later warnings about
152+** 'width' being used uninitialized.)
151153 */
152154 static int fieldargs (lua_State *L, int farg, int *width) {
153155 int f = luaL_checkint(L, farg);
@@ -155,7 +157,7 @@ static int fieldargs (lua_State *L, int farg, int *width) { · 1 unmodified line
155157 luaL_argcheck(L, 0 <= f, farg, "field cannot be negative");
156158 luaL_argcheck(L, 0 < w, farg + 1, "width must be positive");
157159 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");
159161 *width = w;
160162 return f;
161163 }
src/lgc.c+3−3
@@ -1,5 +1,5 @@
11 /*
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 $
33 ** Garbage Collector
44 ** See Copyright Notice in lua.h
55 */
@@ -450,7 +450,7 @@ static lu_mem traversetable (global_State *g, Table *h) { · 444 unmodified lines
450450 else /* not weak */
451451 traversestrongtable(g, h);
452452 return sizeof(Table) + sizeof(TValue) * h->sizearray +
453− sizeof(Node) * sizenode(h);
453+ sizeof(Node) * cast(size_t, sizenode(h));
454454 }
455455
456456
@@ -924,7 +924,7 @@ static void setpause (global_State *g, l_mem estimate) { · 467 unmodified lines
924924 ** object inside the list (instead of to the header), so that the real
925925 ** sweep do not need to skip objects created between "now" and the start
926926 ** of the real sweep.
927−** Returns how many objects it sweeped.
927+** Returns how many objects it swept.
928928 */
929929 static int entersweep (lua_State *L) {
930930 global_State *g = G(L);
src/liolib.c+17−9
@@ -1,5 +1,5 @@
11 /*
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 $
33 ** Standard I/O (and system) library
44 ** See Copyright Notice in lua.h
55 */
@@ -29,6 +29,20 @@ · 23 unmodified lines
2929 #include "lualib.h"
3030
3131
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
3246
3347 /*
3448 ** {======================================================
@@ -212,14 +226,8 @@ static int io_open (lua_State *L) { · 177 unmodified lines
212226 const char *filename = luaL_checkstring(L, 1);
213227 const char *mode = luaL_optstring(L, 2, "r");
214228 LStream *p = newfile(L);
215− int i = 0;
216− /* check whether 'mode' matches '[rwa]%+?b?' */
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);
229+ const char *md = mode; /* to traverse/check mode */
230+ luaL_argcheck(L, lua_checkmode(md), 2, "invalid mode");
223231 p->f = fopen(filename, mode);
224232 return (p->f == NULL) ? luaL_fileresult(L, 0, filename) : 1;
225233 }
src/llex.c+2−2
@@ -1,5 +1,5 @@
11 /*
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 $
33 ** Lexical Analyzer
44 ** See Copyright Notice in lua.h
55 */
@@ -313,7 +313,7 @@ static int readhexaesc (LexState *ls) { · 307 unmodified lines
313313 int c[3], i; /* keep input for error message */
314314 int r = 0; /* result accumulator */
315315 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 */
317317 c[i] = next(ls);
318318 if (!lisxdigit(c[i]))
319319 escerror(ls, c, i + 1, "hexadecimal digit expected");
src/lua.h+6−1
@@ -1,5 +1,5 @@
11 /*
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 $
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
@@ -119,6 +119,11 @@ typedef LUA_UNSIGNED lua_Unsigned; · 113 unmodified lines
119119 #endif
120120
121121
122+/*
123+** RCS ident string
124+*/
125+extern const char lua_ident[];
126+
122127
123128 /*
124129 ** state manipulation
src/luaconf.h+3−3
@@ -1,5 +1,5 @@
11 /*
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 $
33 ** Configuration file for Lua
44 ** See Copyright Notice in lua.h
55 */
@@ -44,7 +44,7 @@ · 38 unmodified lines
4444 #define LUA_USE_POSIX
4545 #define LUA_USE_DLOPEN /* needs an extra library: -ldl */
4646 #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 */
4848 #define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */
4949 #define LUA_USE_LONGLONG /* assume support for long long */
5050 #endif
@@ -53,7 +53,7 @@ · 2 unmodified lines
5353 #define LUA_USE_POSIX
5454 #define LUA_USE_DLOPEN /* does not need -ldl */
5555 #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 */
5757 #define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */
5858 #define LUA_USE_LONGLONG /* assume support for long long */
5959 #endif
src/lvm.c+2−2
@@ -1,5 +1,5 @@
11 /*
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 $
33 ** Lua virtual machine
44 ** See Copyright Notice in lua.h
55 */
@@ -83,7 +83,7 @@ static void traceexec (lua_State *L) { · 77 unmodified lines
8383 if (counthook)
8484 L->hookcount = 1; /* undo decrement to zero */
8585 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 */
8787 ci->func = L->top - 1; /* protect stack below results */
8888 luaD_throw(L, LUA_YIELD);
8989 }