diff options
author | Lua Team <team@lua.org> | 2011-11-30 12:00:00 +0000 |
---|---|---|
committer | repogen <> | 2011-11-30 12:00:00 +0000 |
commit | ed0f7cc8d3f96dce4dac98bc395506f0513a332c (patch) | |
tree | 74d1d70594793be2284559b22c68cc0355007379 | |
parent | ac1beaea25f1fec341e1edb168c63ac7131a6bdd (diff) | |
download | lua-github-ed0f7cc8d3f96dce4dac98bc395506f0513a332c.tar.gz |
Lua 5.2.0-rc45.2.0-rc4
-rw-r--r-- | README | 2 | ||||
-rw-r--r-- | doc/manual.html | 18 | ||||
-rw-r--r-- | src/lapi.c | 8 | ||||
-rw-r--r-- | src/lauxlib.c | 9 | ||||
-rw-r--r-- | src/lbaselib.c | 13 | ||||
-rw-r--r-- | src/ldebug.c | 6 | ||||
-rw-r--r-- | src/llex.c | 8 | ||||
-rw-r--r-- | src/llex.h | 4 | ||||
-rw-r--r-- | src/lmem.c | 5 | ||||
-rw-r--r-- | src/lmem.h | 6 | ||||
-rw-r--r-- | src/loadlib.c | 10 | ||||
-rw-r--r-- | src/lobject.c | 5 | ||||
-rw-r--r-- | src/loslib.c | 4 | ||||
-rw-r--r-- | src/lparser.c | 12 | ||||
-rw-r--r-- | src/lstrlib.c | 19 | ||||
-rw-r--r-- | src/ltable.c | 10 | ||||
-rw-r--r-- | src/luaconf.h | 4 |
17 files changed, 68 insertions, 75 deletions
@@ -1,5 +1,5 @@ -This is Lua 5.2, released on 29 Nov 2011. +This is Lua 5.2, released on 30 Nov 2011. For installation instructions, license details, and further information about Lua, see doc/readme.html. diff --git a/doc/manual.html b/doc/manual.html index 90bb0fc8..5ce261ed 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -33,7 +33,7 @@ Freely available under the terms of the <!-- ====================================================================== --> <p> -<!-- $Id: manual.of,v 1.90 2011/11/29 17:14:45 roberto Exp $ --> +<!-- $Id: manual.of,v 1.91 2011/11/30 18:26:32 roberto Exp $ --> @@ -2026,7 +2026,7 @@ The string concatenation operator in Lua is denoted by two dots ('<code>..</code>'). If both operands are strings or numbers, then they are converted to strings according to the rules mentioned in <a href="#3.4.2">§3.4.2</a>. -Otherwise, the "concat" metamethod is called (see <a href="#2.4">§2.4</a>). +Otherwise, the <code>__concat</code> metamethod is called (see <a href="#2.4">§2.4</a>). @@ -3703,7 +3703,7 @@ which is used for error messages and in debug information (see <a href="#4.9">&s <p> -id{lua_load} automatically detects whether the chunk is text or binary +<code>lua_load</code> automatically detects whether the chunk is text or binary and loads it accordingly (see program <code>luac</code>). The string <code>mode</code> works as in function <a href="#pdf-load"><code>load</code></a>, with the addition that @@ -6957,7 +6957,7 @@ A return of an empty string, <b>nil</b>, or no value signals the end of the chun <p> -If there are no errors, +If there are no syntactic errors, returns the compiled chunk as a function; otherwise, returns <b>nil</b> plus the error message. @@ -7847,9 +7847,11 @@ Options <code>G</code>, and <code>g</code> all expect a number as argument. Options <code>c</code>, <code>d</code>, <code>i</code>, <code>o</code>, <code>u</code>, <code>X</code>, and <code>x</code> -expect an integer as argument; -the range of that integer may be limited by +also expect a number, +but the range of that number may be limited by the underlying C implementation. +For options <code>o</code>, <code>u</code>, <code>X</code>, and <code>x</code>, +the number cannot be negative. Option <code>q</code> expects a string; option <code>s</code> expects a string without embedded zeros. If the argument to option <code>s</code> is not a string, @@ -9247,7 +9249,7 @@ or <b>nil</b> on end of file. <p> -<hr><h3><a name="pdf-file:seek"><code>file:seek ([whence] [, offset])</code></a></h3> +<hr><h3><a name="pdf-file:seek"><code>file:seek ([whence [, offset]])</code></a></h3> <p> @@ -10380,7 +10382,7 @@ Here is the complete syntax of Lua in extended BNF. <HR> <SMALL CLASS="footer"> Last update: -Tue Nov 29 15:37:33 BRST 2011 +Wed Nov 30 18:23:56 BRST 2011 </SMALL> <!-- Last change: revised for Lua 5.2.0 @@ -1,5 +1,5 @@ /* -** $Id: lapi.c,v 2.158 2011/11/29 15:55:08 roberto Exp $ +** $Id: lapi.c,v 2.159 2011/11/30 12:32:05 roberto Exp $ ** Lua API ** See Copyright Notice in lua.h */ @@ -1209,7 +1209,7 @@ static const char *aux_upvalue (StkId fi, int n, TValue **val, LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) { const char *name; - TValue *val = NULL; /* initialized to avoid warnings */ + TValue *val = NULL; /* to avoid warnings */ lua_lock(L); name = aux_upvalue(index2addr(L, funcindex), n, &val, NULL); if (name) { @@ -1223,8 +1223,8 @@ LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) { LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) { const char *name; - TValue *val = NULL; /* initialized to avoid warnings */ - GCObject *owner = NULL; /* initialized to avoid warnings */ + TValue *val = NULL; /* to avoid warnings */ + GCObject *owner = NULL; /* to avoid warnings */ StkId fi; lua_lock(L); fi = index2addr(L, funcindex); diff --git a/src/lauxlib.c b/src/lauxlib.c index 15730b69..5339bc54 100644 --- a/src/lauxlib.c +++ b/src/lauxlib.c @@ -1,5 +1,5 @@ /* -** $Id: lauxlib.c,v 1.237 2011/11/29 15:55:08 roberto Exp $ +** $Id: lauxlib.c,v 1.238 2011/11/30 12:58:57 roberto Exp $ ** Auxiliary functions for building Lua libraries ** See Copyright Notice in lua.h */ @@ -567,7 +567,7 @@ typedef struct LoadF { static const char *getF (lua_State *L, void *ud, size_t *size) { LoadF *lf = (LoadF *)ud; - (void)L; + (void)L; /* not used */ if (lf->n > 0) { /* are there pre-read characters to be read? */ *size = lf->n; /* return them (chars already in buffer) */ lf->n = 0; /* no more pre-read characters */ @@ -668,7 +668,7 @@ typedef struct LoadS { static const char *getS (lua_State *L, void *ud, size_t *size) { LoadS *ls = (LoadS *)ud; - (void)L; + (void)L; /* not used */ if (ls->size == 0) return NULL; *size = ls->size; ls->size = 0; @@ -915,8 +915,7 @@ LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p, static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) { - (void)ud; - (void)osize; + (void)ud; (void)osize; /* not used */ if (nsize == 0) { free(ptr); return NULL; diff --git a/src/lbaselib.c b/src/lbaselib.c index 5db05e21..1dfae301 100644 --- a/src/lbaselib.c +++ b/src/lbaselib.c @@ -1,5 +1,5 @@ /* -** $Id: lbaselib.c,v 1.271 2011/11/29 15:55:08 roberto Exp $ +** $Id: lbaselib.c,v 1.273 2011/11/30 13:03:24 roberto Exp $ ** Basic library ** See Copyright Notice in lua.h */ @@ -288,7 +288,6 @@ static int luaB_loadfile (lua_State *L) { ** reserved slot inside the stack. */ static const char *generic_reader (lua_State *L, void *ud, size_t *size) { - const char *s; (void)(ud); /* not used */ luaL_checkstack(L, 2, "too many nested functions"); lua_pushvalue(L, 1); /* get function */ @@ -297,14 +296,10 @@ static const char *generic_reader (lua_State *L, void *ud, size_t *size) { *size = 0; return NULL; } - else if ((s = lua_tostring(L, -1)) != NULL) { - lua_replace(L, RESERVEDSLOT); /* save string in reserved slot */ - return lua_tolstring(L, RESERVEDSLOT, size); - } - else { + else if (!lua_isstring(L, -1)) luaL_error(L, "reader function must return a string"); - return NULL; /* to avoid warnings */ - } + lua_replace(L, RESERVEDSLOT); /* save string in reserved slot */ + return lua_tolstring(L, RESERVEDSLOT, size); } diff --git a/src/ldebug.c b/src/ldebug.c index 786dcd04..31b7ae40 100644 --- a/src/ldebug.c +++ b/src/ldebug.c @@ -1,5 +1,5 @@ /* -** $Id: ldebug.c,v 2.87 2011/10/07 20:45:19 roberto Exp $ +** $Id: ldebug.c,v 2.88 2011/11/30 12:43:51 roberto Exp $ ** Debug Interface ** See Copyright Notice in lua.h */ @@ -494,7 +494,7 @@ static const char *getupvalname (CallInfo *ci, const TValue *o, } -void luaG_typeerror (lua_State *L, const TValue *o, const char *op) { +l_noret luaG_typeerror (lua_State *L, const TValue *o, const char *op) { CallInfo *ci = L->ci; const char *name = NULL; const char *t = objtypename(o); @@ -513,7 +513,7 @@ void luaG_typeerror (lua_State *L, const TValue *o, const char *op) { } -void luaG_concaterror (lua_State *L, StkId p1, StkId p2) { +l_noret luaG_concaterror (lua_State *L, StkId p1, StkId p2) { if (ttisstring(p1) || ttisnumber(p1)) p1 = p2; lua_assert(!ttisstring(p1) && !ttisnumber(p2)); luaG_typeerror(L, p1, "concatenate"); @@ -1,5 +1,5 @@ /* -** $Id: llex.c,v 2.58 2011/08/15 19:41:58 roberto Exp $ +** $Id: llex.c,v 2.59 2011/11/30 12:43:51 roberto Exp $ ** Lexical Analyzer ** See Copyright Notice in lua.h */ @@ -46,7 +46,7 @@ static const char *const luaX_tokens [] = { #define save_and_next(ls) (save(ls, ls->current), next(ls)) -static void lexerror (LexState *ls, const char *msg, int token); +static l_noret lexerror (LexState *ls, const char *msg, int token); static void save (LexState *ls, int c) { @@ -101,7 +101,7 @@ static const char *txtToken (LexState *ls, int token) { } -static void lexerror (LexState *ls, const char *msg, int token) { +static l_noret lexerror (LexState *ls, const char *msg, int token) { char buff[LUA_IDSIZE]; luaO_chunkid(buff, getstr(ls->source), LUA_IDSIZE); msg = luaO_pushfstring(ls->L, "%s:%d: %s", buff, ls->linenumber, msg); @@ -111,7 +111,7 @@ static void lexerror (LexState *ls, const char *msg, int token) { } -void luaX_syntaxerror (LexState *ls, const char *msg) { +l_noret luaX_syntaxerror (LexState *ls, const char *msg) { lexerror(ls, msg, ls->t.token); } @@ -1,5 +1,5 @@ /* -** $Id: llex.h,v 1.71 2011/06/20 16:52:48 roberto Exp $ +** $Id: llex.h,v 1.72 2011/11/30 12:43:51 roberto Exp $ ** Lexical Analyzer ** See Copyright Notice in lua.h */ @@ -71,7 +71,7 @@ LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l); LUAI_FUNC void luaX_next (LexState *ls); LUAI_FUNC int luaX_lookahead (LexState *ls); -LUAI_FUNC void luaX_syntaxerror (LexState *ls, const char *s); +LUAI_FUNC l_noret luaX_syntaxerror (LexState *ls, const char *s); LUAI_FUNC const char *luaX_token2str (LexState *ls, int token); @@ -1,5 +1,5 @@ /* -** $Id: lmem.c,v 1.82 2011/09/20 19:25:23 roberto Exp $ +** $Id: lmem.c,v 1.83 2011/11/30 12:42:49 roberto Exp $ ** Interface to Memory Manager ** See Copyright Notice in lua.h */ @@ -63,9 +63,8 @@ void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems, } -void *luaM_toobig (lua_State *L) { +l_noret luaM_toobig (lua_State *L) { luaG_runerror(L, "memory allocation error: block too big"); - return NULL; /* to avoid warnings */ } @@ -1,5 +1,5 @@ /* -** $Id: lmem.h,v 1.36 2010/04/08 17:16:46 roberto Exp $ +** $Id: lmem.h,v 1.37 2011/11/30 12:42:49 roberto Exp $ ** Interface to Memory Manager ** See Copyright Notice in lua.h */ @@ -17,7 +17,7 @@ #define luaM_reallocv(L,b,on,n,e) \ ((cast(size_t, (n)+1) <= MAX_SIZET/(e)) ? /* +1 to avoid warnings */ \ luaM_realloc_(L, (b), (on)*(e), (n)*(e)) : \ - luaM_toobig(L)) + (luaM_toobig(L), NULL)) #define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) #define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) @@ -37,7 +37,7 @@ #define luaM_reallocvector(L, v,oldn,n,t) \ ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) -LUAI_FUNC void *luaM_toobig (lua_State *L); +LUAI_FUNC l_noret luaM_toobig (lua_State *L); /* not to be called directly */ LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, diff --git a/src/loadlib.c b/src/loadlib.c index 158fb0e3..b9d76ca8 100644 --- a/src/loadlib.c +++ b/src/loadlib.c @@ -1,5 +1,5 @@ /* -** $Id: loadlib.c,v 1.106 2011/11/28 17:27:51 roberto Exp $ +** $Id: loadlib.c,v 1.107 2011/11/30 12:58:57 roberto Exp $ ** Dynamic library loader for Lua ** See Copyright Notice in lua.h ** @@ -197,7 +197,7 @@ static void ll_unloadlib (void *lib) { static void *ll_load (lua_State *L, const char *path, int seeglb) { HMODULE lib = LoadLibraryExA(path, NULL, LUA_LLE_FLAGS); - (void)(seeglb); /* symbols are 'global' by default */ + (void)(seeglb); /* not used: symbols are 'global' by default */ if (lib == NULL) pusherror(L); return lib; } @@ -227,19 +227,19 @@ static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { static void ll_unloadlib (void *lib) { - (void)(lib); /* to avoid warnings */ + (void)(lib); /* not used */ } static void *ll_load (lua_State *L, const char *path, int seeglb) { - (void)(path); (void)(seeglb); /* to avoid warnings */ + (void)(path); (void)(seeglb); /* not used */ lua_pushliteral(L, DLMSG); return NULL; } static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { - (void)(lib); (void)(sym); /* to avoid warnings */ + (void)(lib); (void)(sym); /* not used */ lua_pushliteral(L, DLMSG); return NULL; } diff --git a/src/lobject.c b/src/lobject.c index 148d4bce..cf0f7544 100644 --- a/src/lobject.c +++ b/src/lobject.c @@ -1,5 +1,5 @@ /* -** $Id: lobject.c,v 2.53 2011/07/27 12:13:08 roberto Exp $ +** $Id: lobject.c,v 2.55 2011/11/30 19:30:16 roberto Exp $ ** Some generic functions over Lua objects ** See Copyright Notice in lua.h */ @@ -33,7 +33,7 @@ LUAI_DDEF const TValue luaO_nilobject_ = {NILCONSTANT}; ** (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if ** eeeee != 0 and (xxx) otherwise. */ -int luaO_int2fb (lu_int32 x) { +int luaO_int2fb (unsigned int x) { int e = 0; /* exponent */ if (x < 8) return x; while (x >= 0x10) { @@ -221,7 +221,6 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) { luaG_runerror(L, "invalid option " LUA_QL("%%%c") " to " LUA_QL("lua_pushfstring"), *(e + 1)); - break; } } n += 2; diff --git a/src/loslib.c b/src/loslib.c index 69d33e3a..881667da 100644 --- a/src/loslib.c +++ b/src/loslib.c @@ -1,5 +1,5 @@ /* -** $Id: loslib.c,v 1.37 2011/11/29 17:15:42 roberto Exp $ +** $Id: loslib.c,v 1.38 2011/11/30 12:35:05 roberto Exp $ ** Standard Operating System library ** See Copyright Notice in lua.h */ @@ -62,7 +62,7 @@ ** By default, Lua uses gmtime/localtime, except when POSIX is available, ** where it uses gmtime_r/localtime_r */ -#if defined(lUA_USE_GMTIME_R) +#if defined(LUA_USE_GMTIME_R) #define l_gmtime(t,r) gmtime_r(t,r) #define l_localtime(t,r) localtime_r(t,r) diff --git a/src/lparser.c b/src/lparser.c index a53a9312..c294a373 100644 --- a/src/lparser.c +++ b/src/lparser.c @@ -1,5 +1,5 @@ /* -** $Id: lparser.c,v 2.122 2011/10/31 17:46:04 roberto Exp $ +** $Id: lparser.c,v 2.123 2011/11/30 12:43:51 roberto Exp $ ** Lua Parser ** See Copyright Notice in lua.h */ @@ -68,19 +68,19 @@ static void anchor_token (LexState *ls) { /* semantic error */ -static void semerror (LexState *ls, const char *msg) { +static l_noret semerror (LexState *ls, const char *msg) { ls->t.token = 0; /* remove 'near to' from final message */ luaX_syntaxerror(ls, msg); } -static void error_expected (LexState *ls, int token) { +static l_noret error_expected (LexState *ls, int token) { luaX_syntaxerror(ls, luaO_pushfstring(ls->L, "%s expected", luaX_token2str(ls, token))); } -static void errorlimit (FuncState *fs, int limit, const char *what) { +static l_noret errorlimit (FuncState *fs, int limit, const char *what) { lua_State *L = fs->ls->L; const char *msg; int line = fs->f->linedefined; @@ -460,7 +460,7 @@ static void breaklabel (LexState *ls) { ** generates an error for an undefined 'goto'; choose appropriate ** message when label name is a reserved word (which can only be 'break') */ -static void undefgoto (LexState *ls, Labeldesc *gt) { +static l_noret undefgoto (LexState *ls, Labeldesc *gt) { const char *msg = (gt->name->tsv.reserved > 0) ? "<%s> at line %d not inside a loop" : "no visible label " LUA_QS " for <goto> at line %d"; @@ -852,7 +852,6 @@ static void funcargs (LexState *ls, expdesc *f, int line) { } default: { luaX_syntaxerror(ls, "function arguments expected"); - return; } } lua_assert(f->k == VNONRELOC); @@ -897,7 +896,6 @@ static void prefixexp (LexState *ls, expdesc *v) { } default: { luaX_syntaxerror(ls, "unexpected symbol"); - return; } } } diff --git a/src/lstrlib.c b/src/lstrlib.c index 84193ebd..f5d61fd8 100644 --- a/src/lstrlib.c +++ b/src/lstrlib.c @@ -1,5 +1,5 @@ /* -** $Id: lstrlib.c,v 1.172 2011/10/25 12:01:20 roberto Exp $ +** $Id: lstrlib.c,v 1.173 2011/11/30 18:24:56 roberto Exp $ ** Standard library for string operations and pattern-matching ** See Copyright Notice in lua.h */ @@ -756,6 +756,9 @@ static int str_gsub (lua_State *L) { #endif #endif /* } */ +#define MAX_UINTFRM ((lua_Number)(~(unsigned LUA_INTFRM_T)0)) +#define MAX_INTFRM ((lua_Number)((~(unsigned LUA_INTFRM_T)0)/2)) +#define MIN_INTFRM (-(lua_Number)((~(unsigned LUA_INTFRM_T)0)/2) - 1) /* ** LUA_FLTFRMLEN is the length modifier for float conversions in @@ -867,20 +870,18 @@ static int str_format (lua_State *L) { } case 'd': case 'i': { lua_Number n = luaL_checknumber(L, arg); - LUA_INTFRM_T r = (LUA_INTFRM_T)n; - luaL_argcheck(L, (lua_Number)r == n, arg, - "not an integer in proper range"); + luaL_argcheck(L, (MIN_INTFRM - 1) < n && n < (MAX_INTFRM + 1), arg, + "not a number in proper range"); addlenmod(form, LUA_INTFRMLEN); - nb = sprintf(buff, form, r); + nb = sprintf(buff, form, (LUA_INTFRM_T)n); break; } case 'o': case 'u': case 'x': case 'X': { lua_Number n = luaL_checknumber(L, arg); - unsigned LUA_INTFRM_T r = (unsigned LUA_INTFRM_T)n; - luaL_argcheck(L, (lua_Number)r == n, arg, - "not a non-negative integer in proper range"); + luaL_argcheck(L, 0 <= n && n < (MAX_UINTFRM + 1), arg, + "not a non-negative number in proper range"); addlenmod(form, LUA_INTFRMLEN); - nb = sprintf(buff, form, r); + nb = sprintf(buff, form, (unsigned LUA_INTFRM_T)n); break; } case 'e': case 'E': case 'f': diff --git a/src/ltable.c b/src/ltable.c index b4aa26c0..9581add9 100644 --- a/src/ltable.c +++ b/src/ltable.c @@ -1,5 +1,5 @@ /* -** $Id: ltable.c,v 2.66 2011/11/28 17:25:48 roberto Exp $ +** $Id: ltable.c,v 2.67 2011/11/30 12:41:45 roberto Exp $ ** Lua tables (hash) ** See Copyright Notice in lua.h */ @@ -141,7 +141,7 @@ static int findindex (lua_State *L, Table *t, StkId key) { return i-1; /* yes; that's the index (corrected to C) */ else { Node *n = mainposition(t, key); - do { /* check whether `key' is somewhere in the chain */ + for (;;) { /* check whether `key' is somewhere in the chain */ /* key may be dead already, but it is ok to use it in `next' */ if (luaV_rawequalobj(gkey(n), key) || (ttisdeadkey(gkey(n)) && iscollectable(key) && @@ -151,9 +151,9 @@ static int findindex (lua_State *L, Table *t, StkId key) { return i + t->sizearray; } else n = gnext(n); - } while (n); - luaG_runerror(L, "invalid key to " LUA_QL("next")); /* key not found */ - return 0; /* to avoid warnings */ + if (n == NULL) + luaG_runerror(L, "invalid key to " LUA_QL("next")); /* key not found */ + } } } diff --git a/src/luaconf.h b/src/luaconf.h index 5417bc61..5b38be6d 100644 --- a/src/luaconf.h +++ b/src/luaconf.h @@ -1,5 +1,5 @@ /* -** $Id: luaconf.h,v 1.168 2011/11/29 17:15:42 roberto Exp $ +** $Id: luaconf.h,v 1.169 2011/11/30 12:35:05 roberto Exp $ ** Configuration file for Lua ** See Copyright Notice in lua.h */ @@ -70,7 +70,7 @@ #define LUA_USE_ISATTY #define LUA_USE_POPEN #define LUA_USE_ULONGJMP -#define lUA_USE_GMTIME_R +#define LUA_USE_GMTIME_R #endif |