Unified · Split
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | |
| 2 | −This is Lua 5.3.0, released on 02 Jan 2015. | |
| 2 | +This is Lua 5.3.0, released on 06 Jan 2015. | |
| 3 | 3 | |
| 4 | 4 | For installation instructions, license details, and |
| 5 | 5 | further information about Lua, see doc/readme.html. |
| @@ -33,7 +33,7 @@ Freely available under the terms of the · 32 unmodified lines | ||
| 33 | 33 | <!-- ====================================================================== --> |
| 34 | 34 | <p> |
| 35 | 35 | |
| 36 | −<!-- $Id: manual.of,v 1.143 2015/01/02 13:07:38 roberto Exp $ --> | |
| 36 | +<!-- $Id: manual.of,v 1.146 2015/01/06 11:23:01 roberto Exp $ --> | |
| 37 | 37 | |
| 38 | 38 | |
| 39 | 39 | |
| @@ -429,7 +429,7 @@ You can emulate how Lua queries a metamethod for an object <code>obj</code> · 389 unmodified lines | ||
| 429 | 429 | with the following code: |
| 430 | 430 | |
| 431 | 431 | <pre> |
| 432 | − rawget(getmetatable(obj) or {}, event_name) | |
| 432 | + rawget(getmetatable(obj) or {}, "__" .. event_name) | |
| 433 | 433 | </pre> |
| 434 | 434 | |
| 435 | 435 | <p> |
| @@ -761,12 +761,12 @@ When a marked object becomes garbage, · 325 unmodified lines | ||
| 761 | 761 | it is not collected immediately by the garbage collector. |
| 762 | 762 | Instead, Lua puts it in a list. |
| 763 | 763 | After the collection, |
| 764 | −Lua goes through that list: | |
| 764 | +Lua goes through that list. | |
| 765 | 765 | For each object in the list, |
| 766 | −it checks the object's <code>__gc</code> metamethod; | |
| 767 | −if it is a function, | |
| 768 | −Lua calls it with the object as its single argument. | |
| 769 | −If the metamethod is not a function, | |
| 766 | +it checks the object's <code>__gc</code> metamethod: | |
| 767 | +If it is a function, | |
| 768 | +Lua calls it with the object as its single argument; | |
| 769 | +if the metamethod is not a function, | |
| 770 | 770 | Lua simply ignores it. |
| 771 | 771 | |
| 772 | 772 | |
| @@ -2217,6 +2217,11 @@ is equivalent to · 1444 unmodified lines | ||
| 2217 | 2217 | end |
| 2218 | 2218 | </pre> |
| 2219 | 2219 | |
| 2220 | +<p> | |
| 2221 | +The order of the assignments in a constructor is undefined. | |
| 2222 | +(This order would be relevant only when there are repeated keys.) | |
| 2223 | + | |
| 2224 | + | |
| 2220 | 2225 | <p> |
| 2221 | 2226 | If the last field in the list has the form <code>exp</code> |
| 2222 | 2227 | and the expression is a function call or a vararg expression, |
| @@ -2785,7 +2790,7 @@ never returning · 562 unmodified lines | ||
| 2785 | 2790 | <p> |
| 2786 | 2791 | The panic function runs as if it were a message handler (see <a href="#2.3">§2.3</a>); |
| 2787 | 2792 | in particular, the error message is at the top of the stack. |
| 2788 | −However, there is no guarantees about stack space. | |
| 2793 | +However, there is no guarantee about stack space. | |
| 2789 | 2794 | To push anything on the stack, |
| 2790 | 2795 | the panic function must first check the available space (see <a href="#4.2">§4.2</a>). |
| 2791 | 2796 | |
| @@ -2861,7 +2866,7 @@ As an illustration, consider the following function: · 69 unmodified lines | ||
| 2861 | 2866 | } |
| 2862 | 2867 | </pre><p> |
| 2863 | 2868 | Now we want to allow |
| 2864 | −the Lua code being ran by <a href="#lua_pcall"><code>lua_pcall</code></a> to yield. | |
| 2869 | +the Lua code being run by <a href="#lua_pcall"><code>lua_pcall</code></a> to yield. | |
| 2865 | 2870 | First, we can rewrite our function like here: |
| 2866 | 2871 | |
| 2867 | 2872 | <pre> |
| @@ -2880,7 +2885,7 @@ the new function <code>k</code> is a · 12 unmodified lines | ||
| 2880 | 2885 | which should do all the work that the original function |
| 2881 | 2886 | was doing after calling <a href="#lua_pcall"><code>lua_pcall</code></a>. |
| 2882 | 2887 | Now, we must inform Lua that it must call <code>k</code> if the Lua code |
| 2883 | −begin running by <a href="#lua_pcall"><code>lua_pcall</code></a> gets interrupted in some way | |
| 2888 | +being executed by <a href="#lua_pcall"><code>lua_pcall</code></a> gets interrupted in some way | |
| 2884 | 2889 | (errors or yielding), |
| 2885 | 2890 | so we rewrite the code as here, |
| 2886 | 2891 | replacing <a href="#lua_pcall"><code>lua_pcall</code></a> by <a href="#lua_pcallk"><code>lua_pcallk</code></a>: |
| @@ -4179,7 +4184,7 @@ error while running a <code>__gc</code> metamethod. · 1292 unmodified lines | ||
| 4179 | 4184 | <pre>int lua_pcallk (lua_State *L, |
| 4180 | 4185 | int nargs, |
| 4181 | 4186 | int nresults, |
| 4182 | − int errfunc, | |
| 4187 | + int msgh, | |
| 4183 | 4188 | lua_KContext ctx, |
| 4184 | 4189 | lua_KFunction k);</pre> |
| 4185 | 4190 | |
| @@ -10774,7 +10779,7 @@ and LiteralString, see <a href="#3.1">§3.1</a>.) · 6588 unmodified lines | ||
| 10774 | 10779 | <HR> |
| 10775 | 10780 | <SMALL CLASS="footer"> |
| 10776 | 10781 | Last update: |
| 10777 | −Fri Jan 2 11:29:40 BRST 2015 | |
| 10782 | +Tue Jan 6 10:10:50 BRST 2015 | |
| 10778 | 10783 | </SMALL> |
| 10779 | 10784 | <!-- |
| 10780 | 10785 | Last change: revised for Lua 5.3.0 (final) |
| @@ -6,7 +6,7 @@ · 5 unmodified lines | ||
| 6 | 6 | # Your platform. See PLATS for possible values. |
| 7 | 7 | PLAT= none |
| 8 | 8 | |
| 9 | −CC= gcc -std=c99 | |
| 9 | +CC= gcc -std=gnu99 | |
| 10 | 10 | CFLAGS= -O2 -Wall -Wextra -DLUA_COMPAT_5_2 $(SYSCFLAGS) $(MYCFLAGS) |
| 11 | 11 | LDFLAGS= $(SYSLDFLAGS) $(MYLDFLAGS) |
| 12 | 12 | LIBS= -lm $(SYSLIBS) $(MYLIBS) |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | /* |
| 2 | −** $Id: linit.c,v 1.37 2014/12/09 15:00:17 roberto Exp $ | |
| 2 | +** $Id: linit.c,v 1.38 2015/01/05 13:48:33 roberto Exp $ | |
| 3 | 3 | ** Initialization of libraries for lua.c and other clients |
| 4 | 4 | ** See Copyright Notice in lua.h |
| 5 | 5 | */ |
| @@ -8,9 +8,6 @@ · 2 unmodified lines | ||
| 8 | 8 | #define linit_c |
| 9 | 9 | #define LUA_LIB |
| 10 | 10 | |
| 11 | −#include "lprefix.h" | |
| 12 | − | |
| 13 | − | |
| 14 | 11 | /* |
| 15 | 12 | ** If you embed Lua in your program and need to open the standard |
| 16 | 13 | ** libraries, call luaL_openlibs in your program. If you need a |
| @@ -27,6 +24,11 @@ · 10 unmodified lines | ||
| 27 | 24 | ** lua_pop(L, 1); // remove _PRELOAD table |
| 28 | 25 | */ |
| 29 | 26 | |
| 27 | +#include "lprefix.h" | |
| 28 | + | |
| 29 | + | |
| 30 | +#include <stddef.h> | |
| 31 | + | |
| 30 | 32 | #include "lua.h" |
| 31 | 33 | |
| 32 | 34 | #include "lualib.h" |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | /* |
| 2 | −** $Id: loadlib.c,v 1.123 2014/11/12 13:31:51 roberto Exp $ | |
| 2 | +** $Id: loadlib.c,v 1.124 2015/01/05 13:51:39 roberto Exp $ | |
| 3 | 3 | ** Dynamic library loader for Lua |
| 4 | 4 | ** See Copyright Notice in lua.h |
| 5 | 5 | ** |
| @@ -135,6 +135,18 @@ static lua_CFunction lsys_sym (lua_State *L, void *lib, const char *sym); · 129 unmodified lines | ||
| 135 | 135 | |
| 136 | 136 | #include <dlfcn.h> |
| 137 | 137 | |
| 138 | +/* | |
| 139 | +** Macro to covert pointer to void* to pointer to function. This cast | |
| 140 | +** is undefined according to ISO C, but POSIX assumes that it must work. | |
| 141 | +** (The '__extension__' in gnu compilers is only to avoid warnings.) | |
| 142 | +*/ | |
| 143 | +#if defined(__GNUC__) | |
| 144 | +#define cast_func(p) (__extension__ (lua_CFunction)(p)) | |
| 145 | +#else | |
| 146 | +#define cast_func(p) ((lua_CFunction)(p)) | |
| 147 | +#endif | |
| 148 | + | |
| 149 | + | |
| 138 | 150 | static void lsys_unloadlib (void *lib) { |
| 139 | 151 | dlclose(lib); |
| 140 | 152 | } |
| @@ -148,7 +160,7 @@ static void *lsys_load (lua_State *L, const char *path, int seeglb) { · 7 unmodified lines | ||
| 148 | 160 | |
| 149 | 161 | |
| 150 | 162 | static lua_CFunction lsys_sym (lua_State *L, void *lib, const char *sym) { |
| 151 | − lua_CFunction f = (lua_CFunction)dlsym(lib, sym); | |
| 163 | + lua_CFunction f = cast_func(dlsym(lib, sym)); | |
| 152 | 164 | if (f == NULL) lua_pushstring(L, dlerror()); |
| 153 | 165 | return f; |
| 154 | 166 | } |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | /* |
| 2 | −** $Id: lobject.h,v 2.105 2014/12/19 13:36:32 roberto Exp $ | |
| 2 | +** $Id: lobject.h,v 2.106 2015/01/05 13:52:37 roberto Exp $ | |
| 3 | 3 | ** Type definitions for Lua objects |
| 4 | 4 | ** See Copyright Notice in lua.h |
| 5 | 5 | */ |
| @@ -473,7 +473,7 @@ typedef union TKey { · 467 unmodified lines | ||
| 473 | 473 | |
| 474 | 474 | |
| 475 | 475 | /* copy a value into a key without messing up field 'next' */ |
| 476 | −#define setkey(L,key,obj) \ | |
| 476 | +#define setnodekey(L,key,obj) \ | |
| 477 | 477 | { TKey *k_=(key); const TValue *io_=(obj); \ |
| 478 | 478 | k_->nk.value_ = io_->value_; k_->nk.tt_ = io_->tt_; \ |
| 479 | 479 | (void)L; checkliveness(G(L),io_); } |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | /* |
| 2 | −** $Id: lopcodes.c,v 1.54 2014/11/02 19:19:04 roberto Exp $ | |
| 2 | +** $Id: lopcodes.c,v 1.55 2015/01/05 13:48:33 roberto Exp $ | |
| 3 | 3 | ** Opcodes for Lua virtual machine |
| 4 | 4 | ** See Copyright Notice in lua.h |
| 5 | 5 | */ |
| @@ -10,6 +10,8 @@ · 4 unmodified lines | ||
| 10 | 10 | #include "lprefix.h" |
| 11 | 11 | |
| 12 | 12 | |
| 13 | +#include <stddef.h> | |
| 14 | + | |
| 13 | 15 | #include "lopcodes.h" |
| 14 | 16 | |
| 15 | 17 | |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | /* |
| 2 | −** $Id: ltable.c,v 2.99 2014/11/02 19:19:04 roberto Exp $ | |
| 2 | +** $Id: ltable.c,v 2.100 2015/01/05 13:52:37 roberto Exp $ | |
| 3 | 3 | ** Lua tables (hash) |
| 4 | 4 | ** See Copyright Notice in lua.h |
| 5 | 5 | */ |
| @@ -484,7 +484,7 @@ TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key) { · 478 unmodified lines | ||
| 484 | 484 | mp = f; |
| 485 | 485 | } |
| 486 | 486 | } |
| 487 | − setkey(L, &mp->i_key, key); | |
| 487 | + setnodekey(L, &mp->i_key, key); | |
| 488 | 488 | luaC_barrierback(L, t, key); |
| 489 | 489 | lua_assert(ttisnil(gval(mp))); |
| 490 | 490 | return gval(mp); |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | /* |
| 2 | −** $Id: luac.c,v 1.71 2014/11/26 12:08:59 lhf Exp $ | |
| 2 | +** $Id: luac.c,v 1.72 2015/01/06 03:09:13 lhf Exp $ | |
| 3 | 3 | ** Lua compiler (saves bytecodes to files; also lists bytecodes) |
| 4 | 4 | ** See Copyright Notice in lua.h |
| 5 | 5 | */ |
| @@ -50,14 +50,14 @@ static void cannot(const char* what) · 44 unmodified lines | ||
| 50 | 50 | static void usage(const char* message) |
| 51 | 51 | { |
| 52 | 52 | if (*message=='-') |
| 53 | − fprintf(stderr,"%s: unrecognized option " LUA_QS "\n",progname,message); | |
| 53 | + fprintf(stderr,"%s: unrecognized option '%s'\n",progname,message); | |
| 54 | 54 | else |
| 55 | 55 | fprintf(stderr,"%s: %s\n",progname,message); |
| 56 | 56 | fprintf(stderr, |
| 57 | 57 | "usage: %s [options] [filenames]\n" |
| 58 | 58 | "Available options are:\n" |
| 59 | 59 | " -l list (use -l -l for full listing)\n" |
| 60 | − " -o name output to file " LUA_QL("name") " (default is \"%s\")\n" | |
| 60 | + " -o name output to file 'name' (default is \"%s\")\n" | |
| 61 | 61 | " -p parse only\n" |
| 62 | 62 | " -s strip debug information\n" |
| 63 | 63 | " -v show version information\n" |
| @@ -92,7 +92,7 @@ static int doargs(int argc, char* argv[]) · 28 unmodified lines | ||
| 92 | 92 | { |
| 93 | 93 | output=argv[++i]; |
| 94 | 94 | if (output==NULL || *output==0 || (*output=='-' && output[1]!=0)) |
| 95 | − usage(LUA_QL("-o") " needs argument"); | |
| 95 | + usage("'-o' needs argument"); | |
| 96 | 96 | if (IS("-")) output=NULL; |
| 97 | 97 | } |
| 98 | 98 | else if (IS("-p")) /* parse only */ |
| @@ -206,7 +206,7 @@ int main(int argc, char* argv[]) · 107 unmodified lines | ||
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | /* |
| 209 | −** $Id: print.c,v 1.74 2014/07/21 01:41:45 lhf Exp $ | |
| 209 | +** $Id: print.c,v 1.76 2015/01/05 16:12:50 lhf Exp $ | |
| 210 | 210 | ** print bytecodes |
| 211 | 211 | ** See Copyright Notice in lua.h |
| 212 | 212 | */ |
| @@ -263,8 +263,13 @@ static void PrintConstant(const Proto* f, int i) · 50 unmodified lines | ||
| 263 | 263 | printf(bvalue(o) ? "true" : "false"); |
| 264 | 264 | break; |
| 265 | 265 | case LUA_TNUMFLT: |
| 266 | − printf(LUA_NUMBER_FMT,fltvalue(o)); | |
| 266 | + { | |
| 267 | + char buff[100]; | |
| 268 | + sprintf(buff,LUA_NUMBER_FMT,fltvalue(o)); | |
| 269 | + printf("%s",buff); | |
| 270 | + if (buff[strspn(buff,"-0123456789")]=='\0') printf(".0"); | |
| 267 | 271 | break; |
| 272 | + } | |
| 268 | 273 | case LUA_TNUMINT: |
| 269 | 274 | printf(LUA_INTEGER_FMT,ivalue(o)); |
| 270 | 275 | break; |