diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lapi.c | 4 | ||||
-rw-r--r-- | src/lauxlib.c | 4 | ||||
-rw-r--r-- | src/lbitlib.c | 8 | ||||
-rw-r--r-- | src/lgc.c | 6 | ||||
-rw-r--r-- | src/liolib.c | 26 | ||||
-rw-r--r-- | src/llex.c | 4 | ||||
-rw-r--r-- | src/lua.h | 7 | ||||
-rw-r--r-- | src/luaconf.h | 6 | ||||
-rw-r--r-- | src/lvm.c | 4 |
9 files changed, 42 insertions, 27 deletions
@@ -1,5 +1,5 @@ /* -** $Id: lapi.c,v 2.170 2012/12/05 19:49:55 roberto Exp $ +** $Id: lapi.c,v 2.171 2013/03/16 21:10:18 roberto Exp $ ** Lua API ** See Copyright Notice in lua.h */ @@ -1106,7 +1106,7 @@ LUA_API int lua_error (lua_State *L) { lua_lock(L); api_checknelems(L, 1); luaG_errormsg(L); - /* code unreacheable; will unlock when control actually leaves the kernel */ + /* code unreachable; will unlock when control actually leaves the kernel */ return 0; /* to avoid warnings */ } diff --git a/src/lauxlib.c b/src/lauxlib.c index 42521bce..2e989d66 100644 --- a/src/lauxlib.c +++ b/src/lauxlib.c @@ -1,5 +1,5 @@ /* -** $Id: lauxlib.c,v 1.247 2012/10/19 15:55:01 roberto Exp $ +** $Id: lauxlib.c,v 1.248 2013/03/21 13:54:57 roberto Exp $ ** Auxiliary functions for building Lua libraries ** See Copyright Notice in lua.h */ @@ -599,7 +599,7 @@ static int skipBOM (LoadF *lf) { lf->n = 0; do { c = getc(lf->f); - if (c == EOF || c != *(unsigned char *)p++) return c; + if (c == EOF || c != *(const unsigned char *)p++) return c; lf->buff[lf->n++] = c; /* to be read by the parser */ } while (*p != '\0'); lf->n = 0; /* prefix matched; discard it */ diff --git a/src/lbitlib.c b/src/lbitlib.c index 9cd91474..9637532e 100644 --- a/src/lbitlib.c +++ b/src/lbitlib.c @@ -1,5 +1,5 @@ /* -** $Id: lbitlib.c,v 1.17 2013/02/21 13:44:53 roberto Exp $ +** $Id: lbitlib.c,v 1.18 2013/03/19 13:19:12 roberto Exp $ ** Standard library for bitwise operations ** See Copyright Notice in lua.h */ @@ -147,7 +147,9 @@ static int b_rrot (lua_State *L) { /* ** get field and width arguments for field-manipulation functions, -** checking whether they are valid +** checking whether they are valid. +** ('luaL_error' called without 'return' to avoid later warnings about +** 'width' being used uninitialized.) */ static int fieldargs (lua_State *L, int farg, int *width) { int f = luaL_checkint(L, farg); @@ -155,7 +157,7 @@ static int fieldargs (lua_State *L, int farg, int *width) { luaL_argcheck(L, 0 <= f, farg, "field cannot be negative"); luaL_argcheck(L, 0 < w, farg + 1, "width must be positive"); if (f + w > LUA_NBITS) - return luaL_error(L, "trying to access non-existent bits"); + luaL_error(L, "trying to access non-existent bits"); *width = w; return f; } @@ -1,5 +1,5 @@ /* -** $Id: lgc.c,v 2.138 2012/10/19 19:00:33 roberto Exp $ +** $Id: lgc.c,v 2.140 2013/03/16 21:10:18 roberto Exp $ ** Garbage Collector ** See Copyright Notice in lua.h */ @@ -450,7 +450,7 @@ static lu_mem traversetable (global_State *g, Table *h) { else /* not weak */ traversestrongtable(g, h); return sizeof(Table) + sizeof(TValue) * h->sizearray + - sizeof(Node) * sizenode(h); + sizeof(Node) * cast(size_t, sizenode(h)); } @@ -924,7 +924,7 @@ static void setpause (global_State *g, l_mem estimate) { ** object inside the list (instead of to the header), so that the real ** sweep do not need to skip objects created between "now" and the start ** of the real sweep. -** Returns how many objects it sweeped. +** Returns how many objects it swept. */ static int entersweep (lua_State *L) { global_State *g = G(L); diff --git a/src/liolib.c b/src/liolib.c index 4814aa2c..3f80db19 100644 --- a/src/liolib.c +++ b/src/liolib.c @@ -1,5 +1,5 @@ /* -** $Id: liolib.c,v 2.108 2011/11/25 12:50:03 roberto Exp $ +** $Id: liolib.c,v 2.111 2013/03/21 13:57:27 roberto Exp $ ** Standard I/O (and system) library ** See Copyright Notice in lua.h */ @@ -29,6 +29,20 @@ #include "lualib.h" +#if !defined(lua_checkmode) + +/* +** Check whether 'mode' matches '[rwa]%+?b?'. +** Change this macro to accept other modes for 'fopen' besides +** the standard ones. +*/ +#define lua_checkmode(mode) \ + (*mode != '\0' && strchr("rwa", *(mode++)) != NULL && \ + (*mode != '+' || ++mode) && /* skip if char is '+' */ \ + (*mode != 'b' || ++mode) && /* skip if char is 'b' */ \ + (*mode == '\0')) + +#endif /* ** {====================================================== @@ -212,14 +226,8 @@ static int io_open (lua_State *L) { const char *filename = luaL_checkstring(L, 1); const char *mode = luaL_optstring(L, 2, "r"); LStream *p = newfile(L); - int i = 0; - /* check whether 'mode' matches '[rwa]%+?b?' */ - if (!(mode[i] != '\0' && strchr("rwa", mode[i++]) != NULL && - (mode[i] != '+' || ++i) && /* skip if char is '+' */ - (mode[i] != 'b' || ++i) && /* skip if char is 'b' */ - (mode[i] == '\0'))) - return luaL_error(L, "invalid mode " LUA_QS - " (should match " LUA_QL("[rwa]%%+?b?") ")", mode); + const char *md = mode; /* to traverse/check mode */ + luaL_argcheck(L, lua_checkmode(md), 2, "invalid mode"); p->f = fopen(filename, mode); return (p->f == NULL) ? luaL_fileresult(L, 0, filename) : 1; } @@ -1,5 +1,5 @@ /* -** $Id: llex.c,v 2.62 2012/12/05 19:57:00 roberto Exp $ +** $Id: llex.c,v 2.63 2013/03/16 21:10:18 roberto Exp $ ** Lexical Analyzer ** See Copyright Notice in lua.h */ @@ -313,7 +313,7 @@ static int readhexaesc (LexState *ls) { int c[3], i; /* keep input for error message */ int r = 0; /* result accumulator */ c[0] = 'x'; /* for error message */ - for (i = 1; i < 3; i++) { /* read two hexa digits */ + for (i = 1; i < 3; i++) { /* read two hexadecimal digits */ c[i] = next(ls); if (!lisxdigit(c[i])) escerror(ls, c, i + 1, "hexadecimal digit expected"); @@ -1,5 +1,5 @@ /* -** $Id: lua.h,v 1.284 2013/02/19 18:39:04 roberto Exp $ +** $Id: lua.h,v 1.285 2013/03/15 13:04:22 roberto Exp $ ** Lua - A Scripting Language ** Lua.org, PUC-Rio, Brazil (http://www.lua.org) ** See Copyright Notice at the end of this file @@ -119,6 +119,11 @@ typedef LUA_UNSIGNED lua_Unsigned; #endif +/* +** RCS ident string +*/ +extern const char lua_ident[]; + /* ** state manipulation diff --git a/src/luaconf.h b/src/luaconf.h index 46eeb2dd..df802c95 100644 --- a/src/luaconf.h +++ b/src/luaconf.h @@ -1,5 +1,5 @@ /* -** $Id: luaconf.h,v 1.175 2013/01/29 16:00:40 roberto Exp $ +** $Id: luaconf.h,v 1.176 2013/03/16 21:10:18 roberto Exp $ ** Configuration file for Lua ** See Copyright Notice in lua.h */ @@ -44,7 +44,7 @@ #define LUA_USE_POSIX #define LUA_USE_DLOPEN /* needs an extra library: -ldl */ #define LUA_USE_READLINE /* needs some extra libraries */ -#define LUA_USE_STRTODHEX /* assume 'strtod' handles hexa formats */ +#define LUA_USE_STRTODHEX /* assume 'strtod' handles hex formats */ #define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */ #define LUA_USE_LONGLONG /* assume support for long long */ #endif @@ -53,7 +53,7 @@ #define LUA_USE_POSIX #define LUA_USE_DLOPEN /* does not need -ldl */ #define LUA_USE_READLINE /* needs an extra library: -lreadline */ -#define LUA_USE_STRTODHEX /* assume 'strtod' handles hexa formats */ +#define LUA_USE_STRTODHEX /* assume 'strtod' handles hex formats */ #define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */ #define LUA_USE_LONGLONG /* assume support for long long */ #endif @@ -1,5 +1,5 @@ /* -** $Id: lvm.c,v 2.154 2012/08/16 17:34:28 roberto Exp $ +** $Id: lvm.c,v 2.155 2013/03/16 21:10:18 roberto Exp $ ** Lua virtual machine ** See Copyright Notice in lua.h */ @@ -83,7 +83,7 @@ static void traceexec (lua_State *L) { if (counthook) L->hookcount = 1; /* undo decrement to zero */ ci->u.l.savedpc--; /* undo increment (resume will increment it again) */ - ci->callstatus |= CIST_HOOKYIELD; /* mark that it yieled */ + ci->callstatus |= CIST_HOOKYIELD; /* mark that it yielded */ ci->func = L->top - 1; /* protect stack below results */ luaD_throw(L, LUA_YIELD); } |