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 | For installation instructions, license details, and | 4 | For installation instructions, license details, and |
| 5 | further information about Lua, see doc/readme.html. | 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 | <p> | 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 | with the following code: | 429 | with the following code: |
| 430 | 430 | ||
| 431 | <pre> | 431 | <pre> |
| 432 | rawget(getmetatable(obj) or {}, event_name) | 432 | rawget(getmetatable(obj) or {}, "__" .. event_name) |
| 433 | </pre> | 433 | </pre> |
| 434 | 434 | ||
| 435 | <p> | 435 | <p> |
| @@ -761,12 +761,12 @@ When a marked object becomes garbage, · 325 unmodified lines | |||
| 761 | it is not collected immediately by the garbage collector. | 761 | it is not collected immediately by the garbage collector. |
| 762 | Instead, Lua puts it in a list. | 762 | Instead, Lua puts it in a list. |
| 763 | After the collection, | 763 | After the collection, |
| 764 | Lua goes through that list: | 764 | Lua goes through that list. |
| 765 | For each object in the list, | 765 | For each object in the list, |
| 766 | it checks the object's <code>__gc</code> metamethod; | 766 | it checks the object's <code>__gc</code> metamethod: |
| 767 | if it is a function, | 767 | If it is a function, |
| 768 | Lua calls it with the object as its single argument. | 768 | Lua calls it with the object as its single argument; |
| 769 | If the metamethod is not a function, | 769 | if the metamethod is not a function, |
| 770 | Lua simply ignores it. | 770 | Lua simply ignores it. |
| 771 | 771 | ||
| 772 | 772 | ||
| @@ -2217,6 +2217,11 @@ is equivalent to · 1444 unmodified lines | |||
| 2217 | end | 2217 | end |
| 2218 | </pre> | 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 | <p> | 2225 | <p> |
| 2221 | If the last field in the list has the form <code>exp</code> | 2226 | If the last field in the list has the form <code>exp</code> |
| 2222 | and the expression is a function call or a vararg expression, | 2227 | and the expression is a function call or a vararg expression, |
| @@ -2785,7 +2790,7 @@ never returning · 562 unmodified lines | |||
| 2785 | <p> | 2790 | <p> |
| 2786 | The panic function runs as if it were a message handler (see <a href="#2.3">§2.3</a>); | 2791 | The panic function runs as if it were a message handler (see <a href="#2.3">§2.3</a>); |
| 2787 | in particular, the error message is at the top of the stack. | 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 | To push anything on the stack, | 2794 | To push anything on the stack, |
| 2790 | the panic function must first check the available space (see <a href="#4.2">§4.2</a>). | 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 | </pre><p> | 2867 | </pre><p> |
| 2863 | Now we want to allow | 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 | First, we can rewrite our function like here: | 2870 | First, we can rewrite our function like here: |
| 2866 | 2871 | ||
| 2867 | <pre> | 2872 | <pre> |
| @@ -2880,7 +2885,7 @@ the new function <code>k</code> is a · 12 unmodified lines | |||
| 2880 | which should do all the work that the original function | 2885 | which should do all the work that the original function |
| 2881 | was doing after calling <a href="#lua_pcall"><code>lua_pcall</code></a>. | 2886 | was doing after calling <a href="#lua_pcall"><code>lua_pcall</code></a>. |
| 2882 | Now, we must inform Lua that it must call <code>k</code> if the Lua code | 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 | (errors or yielding), | 2889 | (errors or yielding), |
| 2885 | so we rewrite the code as here, | 2890 | so we rewrite the code as here, |
| 2886 | replacing <a href="#lua_pcall"><code>lua_pcall</code></a> by <a href="#lua_pcallk"><code>lua_pcallk</code></a>: | 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 | <pre>int lua_pcallk (lua_State *L, | 4184 | <pre>int lua_pcallk (lua_State *L, |
| 4180 | int nargs, | 4185 | int nargs, |
| 4181 | int nresults, | 4186 | int nresults, |
| 4182 | int errfunc, | 4187 | int msgh, |
| 4183 | lua_KContext ctx, | 4188 | lua_KContext ctx, |
| 4184 | lua_KFunction k);</pre> | 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 | <HR> | 10779 | <HR> |
| 10775 | <SMALL CLASS="footer"> | 10780 | <SMALL CLASS="footer"> |
| 10776 | Last update: | 10781 | Last update: |
| 10777 | Fri Jan 2 11:29:40 BRST 2015 | 10782 | Tue Jan 6 10:10:50 BRST 2015 |
| 10778 | </SMALL> | 10783 | </SMALL> |
| 10779 | <!-- | 10784 | <!-- |
| 10780 | Last change: revised for Lua 5.3.0 (final) | 10785 | Last change: revised for Lua 5.3.0 (final) |
| @@ -6,7 +6,7 @@ · 5 unmodified lines | |||
| 6 | # Your platform. See PLATS for possible values. | 6 | # Your platform. See PLATS for possible values. |
| 7 | PLAT= none | 7 | PLAT= none |
| 8 | 8 | ||
| 9 | CC= gcc -std=c99 | 9 | CC= gcc -std=gnu99 |
| 10 | CFLAGS= -O2 -Wall -Wextra -DLUA_COMPAT_5_2 $(SYSCFLAGS) $(MYCFLAGS) | 10 | CFLAGS= -O2 -Wall -Wextra -DLUA_COMPAT_5_2 $(SYSCFLAGS) $(MYCFLAGS) |
| 11 | LDFLAGS= $(SYSLDFLAGS) $(MYLDFLAGS) | 11 | LDFLAGS= $(SYSLDFLAGS) $(MYLDFLAGS) |
| 12 | LIBS= -lm $(SYSLIBS) $(MYLIBS) | 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 | ** Initialization of libraries for lua.c and other clients | 3 | ** Initialization of libraries for lua.c and other clients |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -8,9 +8,6 @@ · 2 unmodified lines | |||
| 8 | #define linit_c | 8 | #define linit_c |
| 9 | #define LUA_LIB | 9 | #define LUA_LIB |
| 10 | 10 | ||
| 11 | #include "lprefix.h" | ||
| 12 | |||
| 13 | |||
| 14 | /* | 11 | /* |
| 15 | ** If you embed Lua in your program and need to open the standard | 12 | ** If you embed Lua in your program and need to open the standard |
| 16 | ** libraries, call luaL_openlibs in your program. If you need a | 13 | ** libraries, call luaL_openlibs in your program. If you need a |
| @@ -27,6 +24,11 @@ · 10 unmodified lines | |||
| 27 | ** lua_pop(L, 1); // remove _PRELOAD table | 24 | ** lua_pop(L, 1); // remove _PRELOAD table |
| 28 | */ | 25 | */ |
| 29 | 26 | ||
| 27 | #include "lprefix.h" | ||
| 28 | |||
| 29 | |||
| 30 | #include <stddef.h> | ||
| 31 | |||
| 30 | #include "lua.h" | 32 | #include "lua.h" |
| 31 | 33 | ||
| 32 | #include "lualib.h" | 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 | ** Dynamic library loader for Lua | 3 | ** Dynamic library loader for Lua |
| 4 | ** See Copyright Notice in lua.h | 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 | #include <dlfcn.h> | 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 | static void lsys_unloadlib (void *lib) { | 150 | static void lsys_unloadlib (void *lib) { |
| 139 | dlclose(lib); | 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 | static lua_CFunction lsys_sym (lua_State *L, void *lib, const char *sym) { | 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 | if (f == NULL) lua_pushstring(L, dlerror()); | 164 | if (f == NULL) lua_pushstring(L, dlerror()); |
| 153 | return f; | 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 | ** Type definitions for Lua objects | 3 | ** Type definitions for Lua objects |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -473,7 +473,7 @@ typedef union TKey { · 467 unmodified lines | |||
| 473 | 473 | ||
| 474 | 474 | ||
| 475 | /* copy a value into a key without messing up field 'next' */ | 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 | { TKey *k_=(key); const TValue *io_=(obj); \ | 477 | { TKey *k_=(key); const TValue *io_=(obj); \ |
| 478 | k_->nk.value_ = io_->value_; k_->nk.tt_ = io_->tt_; \ | 478 | k_->nk.value_ = io_->value_; k_->nk.tt_ = io_->tt_; \ |
| 479 | (void)L; checkliveness(G(L),io_); } | 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 | ** Opcodes for Lua virtual machine | 3 | ** Opcodes for Lua virtual machine |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -10,6 +10,8 @@ · 4 unmodified lines | |||
| 10 | #include "lprefix.h" | 10 | #include "lprefix.h" |
| 11 | 11 | ||
| 12 | 12 | ||
| 13 | #include <stddef.h> | ||
| 14 | |||
| 13 | #include "lopcodes.h" | 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 | ** Lua tables (hash) | 3 | ** Lua tables (hash) |
| 4 | ** See Copyright Notice in lua.h | 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 | mp = f; | 484 | mp = f; |
| 485 | } | 485 | } |
| 486 | } | 486 | } |
| 487 | setkey(L, &mp->i_key, key); | 487 | setnodekey(L, &mp->i_key, key); |
| 488 | luaC_barrierback(L, t, key); | 488 | luaC_barrierback(L, t, key); |
| 489 | lua_assert(ttisnil(gval(mp))); | 489 | lua_assert(ttisnil(gval(mp))); |
| 490 | return gval(mp); | 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 | ** Lua compiler (saves bytecodes to files; also lists bytecodes) | 3 | ** Lua compiler (saves bytecodes to files; also lists bytecodes) |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -50,14 +50,14 @@ static void cannot(const char* what) · 44 unmodified lines | |||
| 50 | static void usage(const char* message) | 50 | static void usage(const char* message) |
| 51 | { | 51 | { |
| 52 | if (*message=='-') | 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 | else | 54 | else |
| 55 | fprintf(stderr,"%s: %s\n",progname,message); | 55 | fprintf(stderr,"%s: %s\n",progname,message); |
| 56 | fprintf(stderr, | 56 | fprintf(stderr, |
| 57 | "usage: %s [options] [filenames]\n" | 57 | "usage: %s [options] [filenames]\n" |
| 58 | "Available options are:\n" | 58 | "Available options are:\n" |
| 59 | " -l list (use -l -l for full listing)\n" | 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 | " -p parse only\n" | 61 | " -p parse only\n" |
| 62 | " -s strip debug information\n" | 62 | " -s strip debug information\n" |
| 63 | " -v show version information\n" | 63 | " -v show version information\n" |
| @@ -92,7 +92,7 @@ static int doargs(int argc, char* argv[]) · 28 unmodified lines | |||
| 92 | { | 92 | { |
| 93 | output=argv[++i]; | 93 | output=argv[++i]; |
| 94 | if (output==NULL || *output==0 || (*output=='-' && output[1]!=0)) | 94 | if (output==NULL || *output==0 || (*output=='-' && output[1]!=0)) |
| 95 | usage(LUA_QL("-o") " needs argument"); | 95 | usage("'-o' needs argument"); |
| 96 | if (IS("-")) output=NULL; | 96 | if (IS("-")) output=NULL; |
| 97 | } | 97 | } |
| 98 | else if (IS("-p")) /* parse only */ | 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 | ** print bytecodes | 210 | ** print bytecodes |
| 211 | ** See Copyright Notice in lua.h | 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 | printf(bvalue(o) ? "true" : "false"); | 263 | printf(bvalue(o) ? "true" : "false"); |
| 264 | break; | 264 | break; |
| 265 | case LUA_TNUMFLT: | 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 | break; | 271 | break; |
| 272 | } | ||
| 268 | case LUA_TNUMINT: | 273 | case LUA_TNUMINT: |
| 269 | printf(LUA_INTEGER_FMT,ivalue(o)); | 274 | printf(LUA_INTEGER_FMT,ivalue(o)); |
| 270 | break; | 275 | break; |