History

Lua 5.3.0

Lua Team committed 11 years ago

Commit dcf74891 parent 48416b89 files · +57 −31Browse files

Unified · Split

9 files
  1. README +1 −1
  2. doc/manual.html +17 −12
  3. src/Makefile +1 −1
  4. src/linit.c +6 −4
  5. src/loadlib.c +14 −2
  6. src/lobject.h +2 −2
  7. src/lopcodes.c +3 −1
  8. src/ltable.c +2 −2
  9. src/luac.c +11 −6
README+1−1
@@ -1,5 +1,5 @@
1 1
2This is Lua 5.3.0, released on 02 Jan 2015.2This is Lua 5.3.0, released on 06 Jan 2015.
3 3
4For installation instructions, license details, and4For installation instructions, license details, and
5further information about Lua, see doc/readme.html.5further information about Lua, see doc/readme.html.
doc/manual.html+17−12
@@ -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
429with the following code:429with 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
761it is not collected immediately by the garbage collector.761it is not collected immediately by the garbage collector.
762Instead, Lua puts it in a list.762Instead, Lua puts it in a list.
763After the collection,763After the collection,
764Lua goes through that list:764Lua goes through that list.
765For each object in the list,765For each object in the list,
766it checks the object's <code>__gc</code> metamethod;766it checks the object's <code>__gc</code> metamethod:
767if it is a function,767If it is a function,
768Lua calls it with the object as its single argument.768Lua calls it with the object as its single argument;
769If the metamethod is not a function,769if the metamethod is not a function,
770Lua simply ignores it.770Lua simply ignores it.
771 771
772 772
@@ -2217,6 +2217,11 @@ is equivalent to · 1444 unmodified lines
2217 end2217 end
2218</pre>2218</pre>
2219 2219
2220<p>
2221The 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>
2221If the last field in the list has the form <code>exp</code>2226If the last field in the list has the form <code>exp</code>
2222and the expression is a function call or a vararg expression,2227and the expression is a function call or a vararg expression,
@@ -2785,7 +2790,7 @@ never returning · 562 unmodified lines
2785<p>2790<p>
2786The panic function runs as if it were a message handler (see <a href="#2.3">&sect;2.3</a>);2791The panic function runs as if it were a message handler (see <a href="#2.3">&sect;2.3</a>);
2787in particular, the error message is at the top of the stack.2792in particular, the error message is at the top of the stack.
2788However, there is no guarantees about stack space.2793However, there is no guarantee about stack space.
2789To push anything on the stack,2794To push anything on the stack,
2790the panic function must first check the available space (see <a href="#4.2">&sect;4.2</a>).2795the panic function must first check the available space (see <a href="#4.2">&sect;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>
2863Now we want to allow2868Now we want to allow
2864the Lua code being ran by <a href="#lua_pcall"><code>lua_pcall</code></a> to yield.2869the Lua code being run by <a href="#lua_pcall"><code>lua_pcall</code></a> to yield.
2865First, we can rewrite our function like here:2870First, 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
2880which should do all the work that the original function2885which should do all the work that the original function
2881was doing after calling <a href="#lua_pcall"><code>lua_pcall</code></a>.2886was doing after calling <a href="#lua_pcall"><code>lua_pcall</code></a>.
2882Now, we must inform Lua that it must call <code>k</code> if the Lua code2887Now, we must inform Lua that it must call <code>k</code> if the Lua code
2883begin running by <a href="#lua_pcall"><code>lua_pcall</code></a> gets interrupted in some way2888being executed by <a href="#lua_pcall"><code>lua_pcall</code></a> gets interrupted in some way
2884(errors or yielding),2889(errors or yielding),
2885so we rewrite the code as here,2890so we rewrite the code as here,
2886replacing <a href="#lua_pcall"><code>lua_pcall</code></a> by <a href="#lua_pcallk"><code>lua_pcallk</code></a>:2891replacing <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">&sect;3.1</a>.) · 6588 unmodified lines
10774<HR>10779<HR>
10775<SMALL CLASS="footer">10780<SMALL CLASS="footer">
10776Last update:10781Last update:
10777Fri Jan 2 11:29:40 BRST 201510782Tue Jan 6 10:10:50 BRST 2015
10778</SMALL>10783</SMALL>
10779<!--10784<!--
10780Last change: revised for Lua 5.3.0 (final)10785Last change: revised for Lua 5.3.0 (final)
src/Makefile+1−1
@@ -6,7 +6,7 @@ · 5 unmodified lines
6# Your platform. See PLATS for possible values.6# Your platform. See PLATS for possible values.
7PLAT= none7PLAT= none
8 8
9CC= gcc -std=c999CC= gcc -std=gnu99
10CFLAGS= -O2 -Wall -Wextra -DLUA_COMPAT_5_2 $(SYSCFLAGS) $(MYCFLAGS)10CFLAGS= -O2 -Wall -Wextra -DLUA_COMPAT_5_2 $(SYSCFLAGS) $(MYCFLAGS)
11LDFLAGS= $(SYSLDFLAGS) $(MYLDFLAGS)11LDFLAGS= $(SYSLDFLAGS) $(MYLDFLAGS)
12LIBS= -lm $(SYSLIBS) $(MYLIBS)12LIBS= -lm $(SYSLIBS) $(MYLIBS)
src/linit.c+6−4
@@ -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 clients3** Initialization of libraries for lua.c and other clients
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
@@ -8,9 +8,6 @@ · 2 unmodified lines
8#define linit_c8#define linit_c
9#define LUA_LIB9#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 standard12** If you embed Lua in your program and need to open the standard
16** libraries, call luaL_openlibs in your program. If you need a13** 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 table24** 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"
src/loadlib.c+14−2
@@ -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 Lua3** Dynamic library loader for Lua
4** See Copyright Notice in lua.h4** 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
138static void lsys_unloadlib (void *lib) {150static 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
150static lua_CFunction lsys_sym (lua_State *L, void *lib, const char *sym) {162static 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}
src/lobject.h+2−2
@@ -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 objects3** Type definitions for Lua objects
4** See Copyright Notice in lua.h4** 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_); }
src/lopcodes.c+3−1
@@ -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 machine3** Opcodes for Lua virtual machine
4** See Copyright Notice in lua.h4** 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
src/ltable.c+2−2
@@ -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.h4** 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);
src/luac.c+11−6
@@ -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.h4** See Copyright Notice in lua.h
5*/5*/
@@ -50,14 +50,14 @@ static void cannot(const char* what) · 44 unmodified lines
50static void usage(const char* message)50static 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 else54 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 bytecodes210** print bytecodes
211** See Copyright Notice in lua.h211** 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;