History

Lua 5.1-rc2

Lua Team committed 20 years ago

Commit 2fee0d61 parent 53d3c3216 files · +95 −59Browse files

Unified · Split

16 files
  1. HISTORY +2 −1
  2. INSTALL +2 −2
  3. MANIFEST +1 −1
  4. Makefile +9 −4
  5. README +3 −1
  6. doc/manual.html +22 −12
  7. etc/lua.pc +5 −2
  8. src/Makefile +10 −4
  9. src/lauxlib.c +19 −9
  10. src/lbaselib.c +2 −2
  11. src/liolib.c +5 −4
  12. src/llex.c +4 −6
  13. src/lobject.h +1 −4
  14. src/ltable.c +2 −2
  15. src/luaconf.h +3 −2
  16. src/lvm.c +5 −3
HISTORY+2−1
@@ -1,4 +1,4 @@
1−This is Lua 5.1.
1+HISTORY for Lua 5.1
22
33 * Changes from version 5.0 to 5.1
44 -------------------------------
@@ -14,6 +14,7 @@ This is Lua 5.1. · 9 unmodified lines
1414 API:
1515 + new functions: lua_createtable, lua_get(set)field, lua_push(to)integer.
1616 + user supplies memory allocator (lua_open becomes lua_newstate).
17+ + luaopen_* functionst be called through Lua.
1718 Implementation:
1819 + new configuration scheme via luaconf.h.
1920 + incremental garbage collection.
INSTALL+2−2
@@ -1,4 +1,4 @@
1−This is Lua 5.1.
1+INSTALL for Lua 5.1
22
33 * Building Lua
44 ------------
@@ -8,7 +8,7 @@ This is Lua 5.1. · 3 unmodified lines
88 Building Lua on Unix systems should be very easy. First do "make" and
99 see if your platform is listed. If so, just do "make xxx", where xxx
1010 is your platform name. The platforms currently supported are:
11− ansi bsd generic linux macosx mingw posix
11+ ansi bsd generic linux macosx mingw posix solaris
1212
1313 See below for customization instructions and for instructions on how
1414 to build with other Windows compilers.
MANIFEST+1−1
@@ -1,4 +1,4 @@
1−MANIFEST contents of Lua 5.1 distribution on Wed Jan 11 22:50:45 BRST 2006
1+MANIFEST contents of Lua 5.1 distribution on Tue Jan 24 16:12:03 BRST 2006
22 lua-5.1
33 lua-5.1/COPYRIGHT
44 lua-5.1/doc
Makefile+9−4
@@ -16,6 +16,8 @@ INSTALL_BIN= $(INSTALL_TOP)/bin · 15 unmodified lines
1616 INSTALL_INC= $(INSTALL_TOP)/include
1717 INSTALL_LIB= $(INSTALL_TOP)/lib
1818 INSTALL_MAN= $(INSTALL_TOP)/man/man1
19+INSTALL_LMOD= $(INSTALL_TOP)/share/lua/$V
20+INSTALL_CMOD= $(INSTALL_TOP)/lib/lua/$V
1921
2022 # How to install. You may prefer "install" instead of "cp" if you have it.
2123 # To remove debug information from binaries, use "install -s" in INSTALL_EXEC.
@@ -28,7 +30,7 @@ INSTALL_DATA= cp · 6 unmodified lines
2830 # == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE =========
2931
3032 # Convenience platforms targets.
31−PLATS= ansi bsd generic linux macosx mingw posix
33+PLATS= ansi bsd generic linux macosx mingw posix solaris
3234
3335 # What to install.
3436 TO_BIN= lua luac
@@ -39,7 +41,7 @@ TO_MAN= lua.1 luac.1 · 4 unmodified lines
3941 # Lua version. Currently used only for messages.
4042 V= 5.1
4143
42−all: $(PLAT)
44+all: $(PLAT)
4345
4446 $(PLATS) clean:
4547 cd src; $(MAKE) $@
@@ -47,8 +49,8 @@ $(PLATS) clean: · 1 unmodified line
4749 test: all
4850 src/lua test/hello.lua
4951
50−install: all
51− cd src; mkdir -p $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN)
52+install:
53+ cd src; mkdir -p $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN) $(INSTALL_LMOD) $(INSTALL_CMOD)
5254 cd src; $(INSTALL_EXEC) $(TO_BIN) $(INSTALL_BIN)
5355 cd src; $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC)
5456 cd src; $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB)
@@ -77,6 +79,9 @@ echo: · 22 unmodified lines
7779 @echo "INSTALL_MAN = $(INSTALL_MAN)"
7880 @echo "INSTALL_EXEC = $(INSTALL_EXEC)"
7981 @echo "INSTALL_DATA = $(INSTALL_DATA)"
82+ @echo "INSTALL_LMOD = $(INSTALL_LMOD)"
83+ @echo "INSTALL_CMOD = $(INSTALL_CMOD)"
84+ @echo "INSTALL_CMOD = $(INSTALL_CMOD)"
8085 @echo ""
8186 @echo "See also src/luaconf.h ."
8287 @echo ""
README+3−1
@@ -1,4 +1,6 @@
1−This is Lua 5.1.
1+README for Lua 5.1
2+
3+See INSTALL for installation instructions.
24 See HISTORY for a summary of changes since the last released version.
35
46 * What is Lua?
doc/manual.html+22−12
@@ -1174,7 +1174,7 @@ while all of them share the same <code>x</code>. · 1173 unmodified lines
11741174
11751175 <p>Because Lua is an embedded extension language,
11761176 all Lua actions start from C code in the host program
1177−calling a function from the Lua library (see <a href="#lua_pcall"></a>).
1177+calling a function from the Lua library (see <a href="#lua_pcall"><code>lua_pcall</code></a>).
11781178 Whenever an error occurs during Lua compilation or execution,
11791179 control returns to C,
11801180 which can take appropriate measures
@@ -1509,11 +1509,11 @@ called when Lua calls a value. · 328 unmodified lines
15091509 <pre>
15101510 function function_event (func, ...)
15111511 if type(func) == "function" then
1512− return func(unpack(arg)) -- primitive call
1512+ return func(...) -- primitive call
15131513 else
15141514 local h = metatable(func).__call
15151515 if h then
1516− return h(func, unpack(arg))
1516+ return h(func, ...)
15171517 else
15181518 error("...")
15191519 end
@@ -1553,7 +1553,7 @@ all accesses to global variables within that function (see <a href="#variables"> · 33 unmodified lines
15531553 They are used as the default environment for other Lua functions
15541554 created by that function.
15551555
1556−<p>You can change the environment of a Lua function of the
1556+<p>You can change the environment of a Lua function or the
15571557 running thread calling <a href="#pdf-setfenv"><code>setfenv</code></a>.
15581558 You can get the environment of a Lua function or the running thread
15591559 calling <a href="#pdf-getfenv"><code>getfenv</code></a>.
@@ -1565,8 +1565,8 @@ use the C API. · 5 unmodified lines
15651565
15661566 <p>Lua performs automatic memory management.
15671567 That means that
1568−you do not have to worry about allocating memory for new objects
1569−not about freeing it when the objects are no longer needed.
1568+you do not have to worry neither about allocating memory for new objects
1569+nor about freeing it when the objects are no longer needed.
15701570 Lua manages memory automatically by running
15711571 a <em>garbage collector</em> from time to time
15721572 to collect all <em>dead objects</em>
@@ -2821,7 +2821,7 @@ onto the stack. · 1248 unmodified lines
28212821 Lua makes (or reuses) an internal copy of the given string,
28222822 so the memory at <code>s</code> can be freed or reused immediately after
28232823 the function returns.
2824−The string cannot embedded zeros;
2824+The string cannot contain embedded zeros;
28252825 it is assumed to end at the first zero.
28262826
28272827 <p><a name="lua_pushthread"></a>
@@ -3609,7 +3609,7 @@ or when it jumps back in the code (even to the same line). · 781 unmodified lines
36093609
36103610 <p>Sets the value of a local variable of a given activation record.
36113611 Parameters <code>ar</code> and <code>n</code> are as in <a href="#lua_getlocal"><code>lua_getlocal</code></a>
3612−(see <a href="#lua_getlocal"></a>).
3612+(see <a href="#lua_getlocal"><code>lua_getlocal</code></a>).
36133613 <a href="#lua_setlocal"><code>lua_setlocal</code></a> assigns the value at the top of the stack
36143614 to the variable and returns its name.
36153615 It also pops the value from the stack.
@@ -3627,7 +3627,7 @@ the number of active local variables. · 11 unmodified lines
36273627
36283628 <p>Sets the value of a closure's upvalue.
36293629 Parameters <code>funcindex</code> and <code>n</code> are as in <a href="#lua_getupvalue"><code>lua_getupvalue</code></a>
3630−(see <a href="#lua_getupvalue"></a>).
3630+(see <a href="#lua_getupvalue"><code>lua_getupvalue</code></a>).
36313631 It assigns the value at the top of the stack
36323632 to the upvalue and returns its name.
36333633 It also pops the value from the stack.
@@ -3995,9 +3995,9 @@ in the registry (see <a href="#luaL_newmetatable"><code>luaL_newmetatable</code> · 361 unmodified lines
39953995 </pre>
39963996
39973997
3998−<p>Creates a copy of string <code>s</code> by replacing any occurrence
3998+<p>Creates a copy of string <code>s</code> by replacing
39993999 any occurrence of the string <code>p</code>
4000−wth the string <code>r</code>.
4000+with the string <code>r</code>.
40014001 Pushes the resulting string on the stack and returns it.
40024002
40034003 <p><a name="luaL_loadbuffer"></a>
@@ -5302,6 +5302,8 @@ of table <code>t</code>. · 1298 unmodified lines
53025302
53035303 <p>Returns the largest positive numerical index of the given table,
53045304 or zero if the table has no positive numerical indices.
5305+(To do its job this function does a linear traversal of
5306+the whole table.)
53055307
53065308 <p><a name="pdf-table.remove"></a><hr /><h3><code>table.remove (table [, pos])</code></h3>
53075309
@@ -6076,7 +6078,15 @@ use <code>collectgarbage("count")</code> instead. · 768 unmodified lines
60766078
60776079 <p><h3>Changes in the API</h3>
60786080 <ul>
6079−<li>
6081+
6082+<p><li>
6083+The <code>luaopen_*</code> functions (to open libraries)
6084+cannot be called directly,
6085+like a regular C function.
6086+They must be called through Lua,
6087+like a Lua function.
6088+
6089+<p><li>
60806090 Function <code>lua_open</code> was replaced by <a href="#lua_newstate"><code>lua_newstate</code></a> to
60816091 allow the user to set a memory allocation function.
60826092 You can use <a href="#luaL_newstate"><code>luaL_newstate</code></a> from the standard library to
etc/lua.pc+5−2
@@ -1,13 +1,16 @@
11 # lua.pc -- pkg-config data for Lua
22
33 # vars from install Makefile
4−# grep ^INSTALL_...= ../Makefile
4+# grep '^INSTALL_.*=' ../Makefile
55 INSTALL_TOP= /usr/local
66 INSTALL_BIN= $(INSTALL_TOP)/bin
77 INSTALL_INC= $(INSTALL_TOP)/include
88 INSTALL_LIB= $(INSTALL_TOP)/lib
99 INSTALL_MAN= $(INSTALL_TOP)/man/man1
10−# grep ^V= ../Makefile
10+INSTALL_LMOD= $(INSTALL_TOP)/share/lua/$V
11+INSTALL_CMOD= $(INSTALL_TOP)/lib/lua/$V
12+
13+# grep '^V=' ../Makefile
1114 V= 5.1
1215
1316 prefix=${INSTALL_TOP}
src/Makefile+10−4
@@ -1,5 +1,5 @@
11 # makefile for building Lua
2−# see INSTALL for installation instructions
2+# see ../INSTALL for installation instructions
33 # see ../Makefile and luaconf.h for further customization
44
55 # == CHANGE THE SETTINGS BELOW TO SUIT YOUR ENVIRONMENT =======================
@@ -20,7 +20,7 @@ MYLIBS= · 14 unmodified lines
2020
2121 # == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE =========
2222
23−PLATS= ansi bsd generic linux macosx mingw posix
23+PLATS= ansi bsd generic linux macosx mingw posix solaris
2424
2525 LUA_A= liblua.a
2626 CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \
@@ -74,7 +74,7 @@ echo: · 47 unmodified lines
7474 @echo "MYLDFLAGS = $(MYLDFLAGS)"
7575 @echo "MYLIBS = $(MYLIBS)"
7676
77−# convenience targets for usual platforms
77+# convenience targets for popular platforms
7878
7979 none:
8080 @echo "Please choose a platform: $(PLATS)"
@@ -93,15 +93,21 @@ linux: · 12 unmodified lines
9393
9494 macosx:
9595 $(MAKE) all MYCFLAGS=-DLUA_USE_MACOSX
96+# use this on Mac OS X 10.4
97+# $(MAKE) all MYCFLAGS="-DLUA_USE_MACOSX -DLUA_USE_READLINE" MYLIBS="-lreadline"
9698
9799 mingw:
98100 $(MAKE) "LUA_A=lua51.dll" "LUA_T=lua.exe" \
99− "AR=gcc -shared -o" "RANLIB=strip --strip-unneeded" \
101+ "AR=$(CC) -shared -o" "RANLIB=strip --strip-unneeded" \
100102 "MYCFLAGS=-DLUA_BUILD_AS_DLL" "MYLIBS=" "MYLDFLAGS=-s" lua.exe
101103
102104 posix:
103105 $(MAKE) all MYCFLAGS=-DLUA_USE_POSIX
104106
107+solaris:
108+ $(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl"
109+
110+
105111 # DO NOT DELETE
106112
107113 lapi.o: lapi.c lua.h luaconf.h lapi.h lobject.h llimits.h ldebug.h \
src/lauxlib.c+19−9
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lauxlib.c,v 1.157 2005/12/29 15:32:11 roberto Exp $
2+** $Id: lauxlib.c,v 1.158 2006/01/16 12:42:21 roberto Exp $
33 ** Auxiliary functions for building Lua libraries
44 ** See Copyright Notice in lua.h
55 */
@@ -295,23 +295,33 @@ static void getsizes (lua_State *L) { · 289 unmodified lines
295295
296296 LUALIB_API void luaL_setn (lua_State *L, int t, int n) {
297297 t = abs_index(L, t);
298− getsizes(L);
299− lua_pushvalue(L, t);
300− lua_pushinteger(L, n);
301− lua_rawset(L, -3); /* sizes[t] = n */
302− lua_pop(L, 1); /* remove `sizes' */
298+ lua_pushliteral(L, "n");
299+ lua_rawget(L, t);
300+ if (checkint(L, 1) >= 0) { /* is there a numeric field `n'? */
301+ lua_pushliteral(L, "n"); /* use it */
302+ lua_pushinteger(L, n);
303+ lua_rawset(L, t);
304+ }
305+ else { /* use `sizes' */
306+ getsizes(L);
307+ lua_pushvalue(L, t);
308+ lua_pushinteger(L, n);
309+ lua_rawset(L, -3); /* sizes[t] = n */
310+ lua_pop(L, 1); /* remove `sizes' */
311+ }
303312 }
304313
305314
306315 LUALIB_API int luaL_getn (lua_State *L, int t) {
307316 int n;
308317 t = abs_index(L, t);
309− getsizes(L); /* try sizes[t] */
318+ lua_pushliteral(L, "n"); /* try t.n */
319+ lua_rawget(L, t);
320+ if ((n = checkint(L, 1)) >= 0) return n;
321+ getsizes(L); /* else try sizes[t] */
310322 lua_pushvalue(L, t);
311323 lua_rawget(L, -2);
312324 if ((n = checkint(L, 2)) >= 0) return n;
313− lua_getfield(L, t, "n"); /* else try t.n */
314− if ((n = checkint(L, 1)) >= 0) return n;
315325 return (int)lua_objlen(L, t);
316326 }
317327
src/lbaselib.c+2−2
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lbaselib.c,v 1.188 2005/12/29 15:32:11 roberto Exp $
2+** $Id: lbaselib.c,v 1.189 2006/01/18 11:49:12 roberto Exp $
33 ** Basic library
44 ** See Copyright Notice in lua.h
55 */
@@ -201,7 +201,7 @@ static int luaB_collectgarbage (lua_State *L) { · 195 unmodified lines
201201 switch (optsnum[o]) {
202202 case LUA_GCCOUNT: {
203203 int b = lua_gc(L, LUA_GCCOUNTB, 0);
204− lua_pushnumber(L, ((lua_Number)res*1024 + b)/1024);
204+ lua_pushnumber(L, res + ((lua_Number)b/1024));
205205 return 1;
206206 }
207207 case LUA_GCSTEP: {
src/liolib.c+5−4
@@ -1,5 +1,5 @@
11 /*
2−** $Id: liolib.c,v 2.70 2005/12/29 15:32:11 roberto Exp $
2+** $Id: liolib.c,v 2.71 2006/01/17 13:54:02 roberto Exp $
33 ** Standard I/O (and system) library
44 ** See Copyright Notice in lua.h
55 */
@@ -28,6 +28,7 @@ static const char *const fnames[] = {"input", "output"}; · 22 unmodified lines
2828
2929
3030 static int pushresult (lua_State *L, int i, const char *filename) {
31+ int en = errno; /* calls to Lua API may change this value */
3132 if (i) {
3233 lua_pushboolean(L, 1);
3334 return 1;
@@ -35,10 +36,10 @@ static int pushresult (lua_State *L, int i, const char *filename) { · 1 unmodified line
3536 else {
3637 lua_pushnil(L);
3738 if (filename)
38− lua_pushfstring(L, "%s: %s", filename, strerror(errno));
39+ lua_pushfstring(L, "%s: %s", filename, strerror(en));
3940 else
40− lua_pushfstring(L, "%s", strerror(errno));
41− lua_pushinteger(L, errno);
41+ lua_pushfstring(L, "%s", strerror(en));
42+ lua_pushinteger(L, en);
4243 return 3;
4344 }
4445 }
src/llex.c+4−6
@@ -1,5 +1,5 @@
11 /*
2−** $Id: llex.c,v 2.17 2005/12/22 16:19:56 roberto Exp $
2+** $Id: llex.c,v 2.18 2006/01/23 20:06:19 roberto Exp $
33 ** Lexical Analyzer
44 ** See Copyright Notice in lua.h
55 */
@@ -193,12 +193,10 @@ static void read_numeral (LexState *ls, SemInfo *seminfo) { · 187 unmodified lines
193193 do {
194194 save_and_next(ls);
195195 } while (isdigit(ls->current) || ls->current == '.');
196− if (check_next(ls, "Ee")) { /* `E'? */
196+ if (check_next(ls, "Ee")) /* `E'? */
197197 check_next(ls, "+-"); /* optional exponent sign */
198− while (isdigit(ls->current)) {
199− save_and_next(ls);
200− }
201− }
198+ while (isalnum(ls->current) || ls->current == '_')
199+ save_and_next(ls);
202200 save(ls, '\0');
203201 buffreplace(ls, '.', ls->decpoint); /* follow locale for decimal point */
204202 if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) /* format error? */
src/lobject.h+1−4
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lobject.h,v 2.19 2006/01/10 12:51:53 roberto Exp $
2+** $Id: lobject.h,v 2.20 2006/01/18 11:37:34 roberto Exp $
33 ** Type definitions for Lua objects
44 ** See Copyright Notice in lua.h
55 */
@@ -119,9 +119,6 @@ typedef struct lua_TValue { · 113 unmodified lines
119119 #define setnvalue(obj,x) \
120120 { TValue *i_o=(obj); i_o->value.n=(x); i_o->tt=LUA_TNUMBER; }
121121
122−#define chgnvalue(obj,x) \
123− check_exp(ttype(obj)==LUA_TNUMBER, (obj)->value.n=(x))
124−
125122 #define setpvalue(obj,x) \
126123 { TValue *i_o=(obj); i_o->value.p=(x); i_o->tt=LUA_TLIGHTUSERDATA; }
127124
src/ltable.c+2−2
@@ -1,5 +1,5 @@
11 /*
2−** $Id: ltable.c,v 2.31 2006/01/10 13:13:06 roberto Exp $
2+** $Id: ltable.c,v 2.32 2006/01/18 11:49:02 roberto Exp $
33 ** Lua tables (hash)
44 ** See Copyright Notice in lua.h
55 */
@@ -122,7 +122,7 @@ static int arrayindex (const TValue *key) { · 116 unmodified lines
122122 lua_Number n = nvalue(key);
123123 int k;
124124 lua_number2int(k, n);
125− if (luai_numeq(cast_num(k), nvalue(key)))
125+ if (luai_numeq(cast_num(k), n))
126126 return k;
127127 }
128128 return -1; /* `key' did not match some condition */
src/luaconf.h+3−2
@@ -1,5 +1,5 @@
11 /*
2−** $Id: luaconf.h,v 1.77 2005/12/27 17:12:00 roberto Exp $
2+** $Id: luaconf.h,v 1.79 2006/01/23 19:51:43 roberto Exp $
33 ** Configuration file for Lua
44 ** See Copyright Notice in lua.h
55 */
@@ -488,6 +488,7 @@ · 482 unmodified lines
488488 ** ===================================================================
489489 */
490490
491+#define LUA_NUMBER_DOUBLE
491492 #define LUA_NUMBER double
492493
493494 /*
@@ -702,7 +703,7 @@ union luai_Cast { double l_d; long l_l; }; · 208 unmodified lines
702703
703704 /*
704705 @@ LUA_INTFRMLEN is the length modifier for integer conversions
705−@* in 'string.fomat'.
706+@* in 'string.format'.
706707 @@ LUA_INTFRM_T is the integer type correspoding to the previous length
707708 @* modifier.
708709 ** CHANGE them if your system supports long long or does not support long.
src/lvm.c+5−3
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lvm.c,v 2.61 2006/01/10 12:50:00 roberto Exp $
2+** $Id: lvm.c,v 2.62 2006/01/23 19:51:43 roberto Exp $
33 ** Lua virtual machine
44 ** See Copyright Notice in lua.h
55 */
@@ -95,7 +95,8 @@ static void callTMres (lua_State *L, StkId res, const TValue *f, · 89 unmodified lines
9595
9696
9797
98−static void callTM (lua_State *L, const TValue *f, const TValue *p1, const TValue *p2, const TValue *p3) {
98+static void callTM (lua_State *L, const TValue *f, const TValue *p1,
99+ const TValue *p2, const TValue *p3) {
99100 setobj2s(L, L->top, f); /* push function */
100101 setobj2s(L, L->top+1, p1); /* 1st argument */
101102 setobj2s(L, L->top+2, p2); /* 2nd argument */
@@ -649,7 +650,8 @@ void luaV_execute (lua_State *L, int nexeccalls) { · 547 unmodified lines
649650 lua_Number step = nvalue(ra+2);
650651 lua_Number idx = luai_numadd(nvalue(ra), step); /* increment index */
651652 lua_Number limit = nvalue(ra+1);
652− if (step > 0 ? luai_numle(idx, limit) : luai_numle(limit, idx)) {
653+ if (luai_numlt(0, step) ? luai_numle(idx, limit)
654+ : luai_numle(limit, idx)) {
653655 dojump(L, pc, GETARG_sBx(i)); /* jump back */
654656 setnvalue(ra, idx); /* update internal index... */
655657 setnvalue(ra+3, idx); /* ...and external index */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t