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 @@
11
2−This is Lua 5.3.0, released on 02 Jan 2015.
2+This is Lua 5.3.0, released on 06 Jan 2015.
33
44 For installation instructions, license details, and
55 further 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
3333 <!-- ====================================================================== -->
3434 <p>
3535
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 $ -->
3737
3838
3939
@@ -429,7 +429,7 @@ You can emulate how Lua queries a metamethod for an object <code>obj</code> · 389 unmodified lines
429429 with the following code:
430430
431431 <pre>
432− rawget(getmetatable(obj) or {}, event_name)
432+ rawget(getmetatable(obj) or {}, "__" .. event_name)
433433 </pre>
434434
435435 <p>
@@ -761,12 +761,12 @@ When a marked object becomes garbage, · 325 unmodified lines
761761 it is not collected immediately by the garbage collector.
762762 Instead, Lua puts it in a list.
763763 After the collection,
764−Lua goes through that list:
764+Lua goes through that list.
765765 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,
770770 Lua simply ignores it.
771771
772772
@@ -2217,6 +2217,11 @@ is equivalent to · 1444 unmodified lines
22172217 end
22182218 </pre>
22192219
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+
22202225 <p>
22212226 If the last field in the list has the form <code>exp</code>
22222227 and the expression is a function call or a vararg expression,
@@ -2785,7 +2790,7 @@ never returning · 562 unmodified lines
27852790 <p>
27862791 The panic function runs as if it were a message handler (see <a href="#2.3">&sect;2.3</a>);
27872792 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.
27892794 To push anything on the stack,
27902795 the panic function must first check the available space (see <a href="#4.2">&sect;4.2</a>).
27912796
@@ -2861,7 +2866,7 @@ As an illustration, consider the following function: · 69 unmodified lines
28612866 }
28622867 </pre><p>
28632868 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.
28652870 First, we can rewrite our function like here:
28662871
28672872 <pre>
@@ -2880,7 +2885,7 @@ the new function <code>k</code> is a · 12 unmodified lines
28802885 which should do all the work that the original function
28812886 was doing after calling <a href="#lua_pcall"><code>lua_pcall</code></a>.
28822887 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
28842889 (errors or yielding),
28852890 so we rewrite the code as here,
28862891 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
41794184 <pre>int lua_pcallk (lua_State *L,
41804185 int nargs,
41814186 int nresults,
4182− int errfunc,
4187+ int msgh,
41834188 lua_KContext ctx,
41844189 lua_KFunction k);</pre>
41854190
@@ -10774,7 +10779,7 @@ and LiteralString, see <a href="#3.1">&sect;3.1</a>.) · 6588 unmodified lines
1077410779 <HR>
1077510780 <SMALL CLASS="footer">
1077610781 Last update:
10777−Fri Jan 2 11:29:40 BRST 2015
10782+Tue Jan 6 10:10:50 BRST 2015
1077810783 </SMALL>
1077910784 <!--
1078010785 Last change: revised for Lua 5.3.0 (final)
src/Makefile+1−1
@@ -6,7 +6,7 @@ · 5 unmodified lines
66 # Your platform. See PLATS for possible values.
77 PLAT= none
88
9−CC= gcc -std=c99
9+CC= gcc -std=gnu99
1010 CFLAGS= -O2 -Wall -Wextra -DLUA_COMPAT_5_2 $(SYSCFLAGS) $(MYCFLAGS)
1111 LDFLAGS= $(SYSLDFLAGS) $(MYLDFLAGS)
1212 LIBS= -lm $(SYSLIBS) $(MYLIBS)
src/linit.c+6−4
@@ -1,5 +1,5 @@
11 /*
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 $
33 ** Initialization of libraries for lua.c and other clients
44 ** See Copyright Notice in lua.h
55 */
@@ -8,9 +8,6 @@ · 2 unmodified lines
88 #define linit_c
99 #define LUA_LIB
1010
11−#include "lprefix.h"
12−
13−
1411 /*
1512 ** If you embed Lua in your program and need to open the standard
1613 ** libraries, call luaL_openlibs in your program. If you need a
@@ -27,6 +24,11 @@ · 10 unmodified lines
2724 ** lua_pop(L, 1); // remove _PRELOAD table
2825 */
2926
27+#include "lprefix.h"
28+
29+
30+#include <stddef.h>
31+
3032 #include "lua.h"
3133
3234 #include "lualib.h"
src/loadlib.c+14−2
@@ -1,5 +1,5 @@
11 /*
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 $
33 ** Dynamic library loader for Lua
44 ** See Copyright Notice in lua.h
55 **
@@ -135,6 +135,18 @@ static lua_CFunction lsys_sym (lua_State *L, void *lib, const char *sym); · 129 unmodified lines
135135
136136 #include <dlfcn.h>
137137
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+
138150 static void lsys_unloadlib (void *lib) {
139151 dlclose(lib);
140152 }
@@ -148,7 +160,7 @@ static void *lsys_load (lua_State *L, const char *path, int seeglb) { · 7 unmodified lines
148160
149161
150162 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));
152164 if (f == NULL) lua_pushstring(L, dlerror());
153165 return f;
154166 }
src/lobject.h+2−2
@@ -1,5 +1,5 @@
11 /*
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 $
33 ** Type definitions for Lua objects
44 ** See Copyright Notice in lua.h
55 */
@@ -473,7 +473,7 @@ typedef union TKey { · 467 unmodified lines
473473
474474
475475 /* copy a value into a key without messing up field 'next' */
476−#define setkey(L,key,obj) \
476+#define setnodekey(L,key,obj) \
477477 { TKey *k_=(key); const TValue *io_=(obj); \
478478 k_->nk.value_ = io_->value_; k_->nk.tt_ = io_->tt_; \
479479 (void)L; checkliveness(G(L),io_); }
src/lopcodes.c+3−1
@@ -1,5 +1,5 @@
11 /*
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 $
33 ** Opcodes for Lua virtual machine
44 ** See Copyright Notice in lua.h
55 */
@@ -10,6 +10,8 @@ · 4 unmodified lines
1010 #include "lprefix.h"
1111
1212
13+#include <stddef.h>
14+
1315 #include "lopcodes.h"
1416
1517
src/ltable.c+2−2
@@ -1,5 +1,5 @@
11 /*
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 $
33 ** Lua tables (hash)
44 ** See Copyright Notice in lua.h
55 */
@@ -484,7 +484,7 @@ TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key) { · 478 unmodified lines
484484 mp = f;
485485 }
486486 }
487− setkey(L, &mp->i_key, key);
487+ setnodekey(L, &mp->i_key, key);
488488 luaC_barrierback(L, t, key);
489489 lua_assert(ttisnil(gval(mp)));
490490 return gval(mp);
src/luac.c+11−6
@@ -1,5 +1,5 @@
11 /*
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 $
33 ** Lua compiler (saves bytecodes to files; also lists bytecodes)
44 ** See Copyright Notice in lua.h
55 */
@@ -50,14 +50,14 @@ static void cannot(const char* what) · 44 unmodified lines
5050 static void usage(const char* message)
5151 {
5252 if (*message=='-')
53− fprintf(stderr,"%s: unrecognized option " LUA_QS "\n",progname,message);
53+ fprintf(stderr,"%s: unrecognized option '%s'\n",progname,message);
5454 else
5555 fprintf(stderr,"%s: %s\n",progname,message);
5656 fprintf(stderr,
5757 "usage: %s [options] [filenames]\n"
5858 "Available options are:\n"
5959 " -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"
6161 " -p parse only\n"
6262 " -s strip debug information\n"
6363 " -v show version information\n"
@@ -92,7 +92,7 @@ static int doargs(int argc, char* argv[]) · 28 unmodified lines
9292 {
9393 output=argv[++i];
9494 if (output==NULL || *output==0 || (*output=='-' && output[1]!=0))
95− usage(LUA_QL("-o") " needs argument");
95+ usage("'-o' needs argument");
9696 if (IS("-")) output=NULL;
9797 }
9898 else if (IS("-p")) /* parse only */
@@ -206,7 +206,7 @@ int main(int argc, char* argv[]) · 107 unmodified lines
206206 }
207207
208208 /*
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 $
210210 ** print bytecodes
211211 ** See Copyright Notice in lua.h
212212 */
@@ -263,8 +263,13 @@ static void PrintConstant(const Proto* f, int i) · 50 unmodified lines
263263 printf(bvalue(o) ? "true" : "false");
264264 break;
265265 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");
267271 break;
272+ }
268273 case LUA_TNUMINT:
269274 printf(LUA_INTEGER_FMT,ivalue(o));
270275 break;