summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLua Team <team@lua.org>2006-01-24 12:00:00 +0000
committerrepogen <>2006-01-24 12:00:00 +0000
commitb487a3dce43e449acf3852ec56345e2860cfeab7 (patch)
tree5aa380efa69c039aafa812cf9edeb432bf27a885
parent4f266285f998d0d14c4e83cc29772f0de1a7fbba (diff)
downloadlua-github-5.1-rc2.tar.gz
Lua 5.1-rc25.1-rc2
-rw-r--r--HISTORY3
-rw-r--r--INSTALL4
-rw-r--r--MANIFEST2
-rw-r--r--Makefile13
-rw-r--r--README4
-rw-r--r--doc/manual.html34
-rw-r--r--etc/lua.pc7
-rw-r--r--src/Makefile14
-rw-r--r--src/lauxlib.c28
-rw-r--r--src/lbaselib.c4
-rw-r--r--src/liolib.c9
-rw-r--r--src/llex.c10
-rw-r--r--src/lobject.h5
-rw-r--r--src/ltable.c4
-rw-r--r--src/luaconf.h5
-rw-r--r--src/lvm.c8
16 files changed, 95 insertions, 59 deletions
diff --git a/HISTORY b/HISTORY
index fc603c96..122f6563 100644
--- a/HISTORY
+++ b/HISTORY
@@ -1,4 +1,4 @@
-This is Lua 5.1.
+HISTORY for Lua 5.1
* Changes from version 5.0 to 5.1
-------------------------------
@@ -14,6 +14,7 @@ This is Lua 5.1.
API:
+ new functions: lua_createtable, lua_get(set)field, lua_push(to)integer.
+ user supplies memory allocator (lua_open becomes lua_newstate).
+ + luaopen_* functionst be called through Lua.
Implementation:
+ new configuration scheme via luaconf.h.
+ incremental garbage collection.
diff --git a/INSTALL b/INSTALL
index bd3b540c..293b44ea 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,4 +1,4 @@
-This is Lua 5.1.
+INSTALL for Lua 5.1
* Building Lua
------------
@@ -8,7 +8,7 @@ This is Lua 5.1.
Building Lua on Unix systems should be very easy. First do "make" and
see if your platform is listed. If so, just do "make xxx", where xxx
is your platform name. The platforms currently supported are:
- ansi bsd generic linux macosx mingw posix
+ ansi bsd generic linux macosx mingw posix solaris
See below for customization instructions and for instructions on how
to build with other Windows compilers.
diff --git a/MANIFEST b/MANIFEST
index 964df73c..a554dc12 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -1,4 +1,4 @@
-MANIFEST contents of Lua 5.1 distribution on Wed Jan 11 22:50:45 BRST 2006
+MANIFEST contents of Lua 5.1 distribution on Tue Jan 24 16:12:03 BRST 2006
lua-5.1
lua-5.1/COPYRIGHT
lua-5.1/doc
diff --git a/Makefile b/Makefile
index 9e627259..db9bb3d9 100644
--- a/Makefile
+++ b/Makefile
@@ -16,6 +16,8 @@ INSTALL_BIN= $(INSTALL_TOP)/bin
INSTALL_INC= $(INSTALL_TOP)/include
INSTALL_LIB= $(INSTALL_TOP)/lib
INSTALL_MAN= $(INSTALL_TOP)/man/man1
+INSTALL_LMOD= $(INSTALL_TOP)/share/lua/$V
+INSTALL_CMOD= $(INSTALL_TOP)/lib/lua/$V
# How to install. You may prefer "install" instead of "cp" if you have it.
# To remove debug information from binaries, use "install -s" in INSTALL_EXEC.
@@ -28,7 +30,7 @@ INSTALL_DATA= cp
# == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE =========
# Convenience platforms targets.
-PLATS= ansi bsd generic linux macosx mingw posix
+PLATS= ansi bsd generic linux macosx mingw posix solaris
# What to install.
TO_BIN= lua luac
@@ -39,7 +41,7 @@ TO_MAN= lua.1 luac.1
# Lua version. Currently used only for messages.
V= 5.1
-all: $(PLAT)
+all: $(PLAT)
$(PLATS) clean:
cd src; $(MAKE) $@
@@ -47,8 +49,8 @@ $(PLATS) clean:
test: all
src/lua test/hello.lua
-install: all
- cd src; mkdir -p $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN)
+install:
+ cd src; mkdir -p $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN) $(INSTALL_LMOD) $(INSTALL_CMOD)
cd src; $(INSTALL_EXEC) $(TO_BIN) $(INSTALL_BIN)
cd src; $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC)
cd src; $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB)
@@ -77,6 +79,9 @@ echo:
@echo "INSTALL_MAN = $(INSTALL_MAN)"
@echo "INSTALL_EXEC = $(INSTALL_EXEC)"
@echo "INSTALL_DATA = $(INSTALL_DATA)"
+ @echo "INSTALL_LMOD = $(INSTALL_LMOD)"
+ @echo "INSTALL_CMOD = $(INSTALL_CMOD)"
+ @echo "INSTALL_CMOD = $(INSTALL_CMOD)"
@echo ""
@echo "See also src/luaconf.h ."
@echo ""
diff --git a/README b/README
index 51dfeede..f082d404 100644
--- a/README
+++ b/README
@@ -1,4 +1,6 @@
-This is Lua 5.1.
+README for Lua 5.1
+
+See INSTALL for installation instructions.
See HISTORY for a summary of changes since the last released version.
* What is Lua?
diff --git a/doc/manual.html b/doc/manual.html
index df42a932..9a115e74 100644
--- a/doc/manual.html
+++ b/doc/manual.html
@@ -1174,7 +1174,7 @@ while all of them share the same <code>x</code>.
<p>Because Lua is an embedded extension language,
all Lua actions start from C code in the host program
-calling a function from the Lua library (see <a href="#lua_pcall"></a>).
+calling a function from the Lua library (see <a href="#lua_pcall"><code>lua_pcall</code></a>).
Whenever an error occurs during Lua compilation or execution,
control returns to C,
which can take appropriate measures
@@ -1509,11 +1509,11 @@ called when Lua calls a value.
<pre>
function function_event (func, ...)
if type(func) == "function" then
- return func(unpack(arg)) -- primitive call
+ return func(...) -- primitive call
else
local h = metatable(func).__call
if h then
- return h(func, unpack(arg))
+ return h(func, ...)
else
error("...")
end
@@ -1553,7 +1553,7 @@ all accesses to global variables within that function (see <a href="#variables">
They are used as the default environment for other Lua functions
created by that function.
-<p>You can change the environment of a Lua function of the
+<p>You can change the environment of a Lua function or the
running thread calling <a href="#pdf-setfenv"><code>setfenv</code></a>.
You can get the environment of a Lua function or the running thread
calling <a href="#pdf-getfenv"><code>getfenv</code></a>.
@@ -1565,8 +1565,8 @@ use the C API.
<p>Lua performs automatic memory management.
That means that
-you do not have to worry about allocating memory for new objects
-not about freeing it when the objects are no longer needed.
+you do not have to worry neither about allocating memory for new objects
+nor about freeing it when the objects are no longer needed.
Lua manages memory automatically by running
a <em>garbage collector</em> from time to time
to collect all <em>dead objects</em>
@@ -2821,7 +2821,7 @@ onto the stack.
Lua makes (or reuses) an internal copy of the given string,
so the memory at <code>s</code> can be freed or reused immediately after
the function returns.
-The string cannot embedded zeros;
+The string cannot contain embedded zeros;
it is assumed to end at the first zero.
<p><a name="lua_pushthread"></a>
@@ -3609,7 +3609,7 @@ or when it jumps back in the code (even to the same line).
<p>Sets the value of a local variable of a given activation record.
Parameters <code>ar</code> and <code>n</code> are as in <a href="#lua_getlocal"><code>lua_getlocal</code></a>
-(see <a href="#lua_getlocal"></a>).
+(see <a href="#lua_getlocal"><code>lua_getlocal</code></a>).
<a href="#lua_setlocal"><code>lua_setlocal</code></a> assigns the value at the top of the stack
to the variable and returns its name.
It also pops the value from the stack.
@@ -3627,7 +3627,7 @@ the number of active local variables.
<p>Sets the value of a closure's upvalue.
Parameters <code>funcindex</code> and <code>n</code> are as in <a href="#lua_getupvalue"><code>lua_getupvalue</code></a>
-(see <a href="#lua_getupvalue"></a>).
+(see <a href="#lua_getupvalue"><code>lua_getupvalue</code></a>).
It assigns the value at the top of the stack
to the upvalue and returns its name.
It also pops the value from the stack.
@@ -3995,9 +3995,9 @@ in the registry (see <a href="#luaL_newmetatable"><code>luaL_newmetatable</code>
</pre>
-<p>Creates a copy of string <code>s</code> by replacing any occurrence
+<p>Creates a copy of string <code>s</code> by replacing
any occurrence of the string <code>p</code>
-wth the string <code>r</code>.
+with the string <code>r</code>.
Pushes the resulting string on the stack and returns it.
<p><a name="luaL_loadbuffer"></a>
@@ -5302,6 +5302,8 @@ of table <code>t</code>.
<p>Returns the largest positive numerical index of the given table,
or zero if the table has no positive numerical indices.
+(To do its job this function does a linear traversal of
+the whole table.)
<p><a name="pdf-table.remove"></a><hr /><h3><code>table.remove (table [, pos])</code></h3>
@@ -6076,7 +6078,15 @@ use <code>collectgarbage("count")</code> instead.
<p><h3>Changes in the API</h3>
<ul>
-<li>
+
+<p><li>
+The <code>luaopen_*</code> functions (to open libraries)
+cannot be called directly,
+like a regular C function.
+They must be called through Lua,
+like a Lua function.
+
+<p><li>
Function <code>lua_open</code> was replaced by <a href="#lua_newstate"><code>lua_newstate</code></a> to
allow the user to set a memory allocation function.
You can use <a href="#luaL_newstate"><code>luaL_newstate</code></a> from the standard library to
diff --git a/etc/lua.pc b/etc/lua.pc
index c476f7e4..f0d6e2ff 100644
--- a/etc/lua.pc
+++ b/etc/lua.pc
@@ -1,13 +1,16 @@
# lua.pc -- pkg-config data for Lua
# vars from install Makefile
-# grep ^INSTALL_...= ../Makefile
+# grep '^INSTALL_.*=' ../Makefile
INSTALL_TOP= /usr/local
INSTALL_BIN= $(INSTALL_TOP)/bin
INSTALL_INC= $(INSTALL_TOP)/include
INSTALL_LIB= $(INSTALL_TOP)/lib
INSTALL_MAN= $(INSTALL_TOP)/man/man1
-# grep ^V= ../Makefile
+INSTALL_LMOD= $(INSTALL_TOP)/share/lua/$V
+INSTALL_CMOD= $(INSTALL_TOP)/lib/lua/$V
+
+# grep '^V=' ../Makefile
V= 5.1
prefix=${INSTALL_TOP}
diff --git a/src/Makefile b/src/Makefile
index b042d9ab..13d0d497 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,5 +1,5 @@
# makefile for building Lua
-# see INSTALL for installation instructions
+# see ../INSTALL for installation instructions
# see ../Makefile and luaconf.h for further customization
# == CHANGE THE SETTINGS BELOW TO SUIT YOUR ENVIRONMENT =======================
@@ -20,7 +20,7 @@ MYLIBS=
# == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE =========
-PLATS= ansi bsd generic linux macosx mingw posix
+PLATS= ansi bsd generic linux macosx mingw posix solaris
LUA_A= liblua.a
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:
@echo "MYLDFLAGS = $(MYLDFLAGS)"
@echo "MYLIBS = $(MYLIBS)"
-# convenience targets for usual platforms
+# convenience targets for popular platforms
none:
@echo "Please choose a platform: $(PLATS)"
@@ -93,15 +93,21 @@ linux:
macosx:
$(MAKE) all MYCFLAGS=-DLUA_USE_MACOSX
+# use this on Mac OS X 10.4
+# $(MAKE) all MYCFLAGS="-DLUA_USE_MACOSX -DLUA_USE_READLINE" MYLIBS="-lreadline"
mingw:
$(MAKE) "LUA_A=lua51.dll" "LUA_T=lua.exe" \
- "AR=gcc -shared -o" "RANLIB=strip --strip-unneeded" \
+ "AR=$(CC) -shared -o" "RANLIB=strip --strip-unneeded" \
"MYCFLAGS=-DLUA_BUILD_AS_DLL" "MYLIBS=" "MYLDFLAGS=-s" lua.exe
posix:
$(MAKE) all MYCFLAGS=-DLUA_USE_POSIX
+solaris:
+ $(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl"
+
+
# DO NOT DELETE
lapi.o: lapi.c lua.h luaconf.h lapi.h lobject.h llimits.h ldebug.h \
diff --git a/src/lauxlib.c b/src/lauxlib.c
index d3b54ee4..317a48d1 100644
--- a/src/lauxlib.c
+++ b/src/lauxlib.c
@@ -1,5 +1,5 @@
/*
-** $Id: lauxlib.c,v 1.157 2005/12/29 15:32:11 roberto Exp $
+** $Id: lauxlib.c,v 1.158 2006/01/16 12:42:21 roberto Exp $
** Auxiliary functions for building Lua libraries
** See Copyright Notice in lua.h
*/
@@ -295,23 +295,33 @@ static void getsizes (lua_State *L) {
LUALIB_API void luaL_setn (lua_State *L, int t, int n) {
t = abs_index(L, t);
- getsizes(L);
- lua_pushvalue(L, t);
- lua_pushinteger(L, n);
- lua_rawset(L, -3); /* sizes[t] = n */
- lua_pop(L, 1); /* remove `sizes' */
+ lua_pushliteral(L, "n");
+ lua_rawget(L, t);
+ if (checkint(L, 1) >= 0) { /* is there a numeric field `n'? */
+ lua_pushliteral(L, "n"); /* use it */
+ lua_pushinteger(L, n);
+ lua_rawset(L, t);
+ }
+ else { /* use `sizes' */
+ getsizes(L);
+ lua_pushvalue(L, t);
+ lua_pushinteger(L, n);
+ lua_rawset(L, -3); /* sizes[t] = n */
+ lua_pop(L, 1); /* remove `sizes' */
+ }
}
LUALIB_API int luaL_getn (lua_State *L, int t) {
int n;
t = abs_index(L, t);
- getsizes(L); /* try sizes[t] */
+ lua_pushliteral(L, "n"); /* try t.n */
+ lua_rawget(L, t);
+ if ((n = checkint(L, 1)) >= 0) return n;
+ getsizes(L); /* else try sizes[t] */
lua_pushvalue(L, t);
lua_rawget(L, -2);
if ((n = checkint(L, 2)) >= 0) return n;
- lua_getfield(L, t, "n"); /* else try t.n */
- if ((n = checkint(L, 1)) >= 0) return n;
return (int)lua_objlen(L, t);
}
diff --git a/src/lbaselib.c b/src/lbaselib.c
index 1778e775..1d922a81 100644
--- a/src/lbaselib.c
+++ b/src/lbaselib.c
@@ -1,5 +1,5 @@
/*
-** $Id: lbaselib.c,v 1.188 2005/12/29 15:32:11 roberto Exp $
+** $Id: lbaselib.c,v 1.189 2006/01/18 11:49:12 roberto Exp $
** Basic library
** See Copyright Notice in lua.h
*/
@@ -201,7 +201,7 @@ static int luaB_collectgarbage (lua_State *L) {
switch (optsnum[o]) {
case LUA_GCCOUNT: {
int b = lua_gc(L, LUA_GCCOUNTB, 0);
- lua_pushnumber(L, ((lua_Number)res*1024 + b)/1024);
+ lua_pushnumber(L, res + ((lua_Number)b/1024));
return 1;
}
case LUA_GCSTEP: {
diff --git a/src/liolib.c b/src/liolib.c
index f0a7602a..fd7894c9 100644
--- a/src/liolib.c
+++ b/src/liolib.c
@@ -1,5 +1,5 @@
/*
-** $Id: liolib.c,v 2.70 2005/12/29 15:32:11 roberto Exp $
+** $Id: liolib.c,v 2.71 2006/01/17 13:54:02 roberto Exp $
** Standard I/O (and system) library
** See Copyright Notice in lua.h
*/
@@ -28,6 +28,7 @@ static const char *const fnames[] = {"input", "output"};
static int pushresult (lua_State *L, int i, const char *filename) {
+ int en = errno; /* calls to Lua API may change this value */
if (i) {
lua_pushboolean(L, 1);
return 1;
@@ -35,10 +36,10 @@ static int pushresult (lua_State *L, int i, const char *filename) {
else {
lua_pushnil(L);
if (filename)
- lua_pushfstring(L, "%s: %s", filename, strerror(errno));
+ lua_pushfstring(L, "%s: %s", filename, strerror(en));
else
- lua_pushfstring(L, "%s", strerror(errno));
- lua_pushinteger(L, errno);
+ lua_pushfstring(L, "%s", strerror(en));
+ lua_pushinteger(L, en);
return 3;
}
}
diff --git a/src/llex.c b/src/llex.c
index 2792ea9e..9918b2f4 100644
--- a/src/llex.c
+++ b/src/llex.c
@@ -1,5 +1,5 @@
/*
-** $Id: llex.c,v 2.17 2005/12/22 16:19:56 roberto Exp $
+** $Id: llex.c,v 2.18 2006/01/23 20:06:19 roberto Exp $
** Lexical Analyzer
** See Copyright Notice in lua.h
*/
@@ -193,12 +193,10 @@ static void read_numeral (LexState *ls, SemInfo *seminfo) {
do {
save_and_next(ls);
} while (isdigit(ls->current) || ls->current == '.');
- if (check_next(ls, "Ee")) { /* `E'? */
+ if (check_next(ls, "Ee")) /* `E'? */
check_next(ls, "+-"); /* optional exponent sign */
- while (isdigit(ls->current)) {
- save_and_next(ls);
- }
- }
+ while (isalnum(ls->current) || ls->current == '_')
+ save_and_next(ls);
save(ls, '\0');
buffreplace(ls, '.', ls->decpoint); /* follow locale for decimal point */
if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) /* format error? */
diff --git a/src/lobject.h b/src/lobject.h
index 928bedc7..8ce4405b 100644
--- a/src/lobject.h
+++ b/src/lobject.h
@@ -1,5 +1,5 @@
/*
-** $Id: lobject.h,v 2.19 2006/01/10 12:51:53 roberto Exp $
+** $Id: lobject.h,v 2.20 2006/01/18 11:37:34 roberto Exp $
** Type definitions for Lua objects
** See Copyright Notice in lua.h
*/
@@ -119,9 +119,6 @@ typedef struct lua_TValue {
#define setnvalue(obj,x) \
{ TValue *i_o=(obj); i_o->value.n=(x); i_o->tt=LUA_TNUMBER; }
-#define chgnvalue(obj,x) \
- check_exp(ttype(obj)==LUA_TNUMBER, (obj)->value.n=(x))
-
#define setpvalue(obj,x) \
{ TValue *i_o=(obj); i_o->value.p=(x); i_o->tt=LUA_TLIGHTUSERDATA; }
diff --git a/src/ltable.c b/src/ltable.c
index 029cd506..bc91cacd 100644
--- a/src/ltable.c
+++ b/src/ltable.c
@@ -1,5 +1,5 @@
/*
-** $Id: ltable.c,v 2.31 2006/01/10 13:13:06 roberto Exp $
+** $Id: ltable.c,v 2.32 2006/01/18 11:49:02 roberto Exp $
** Lua tables (hash)
** See Copyright Notice in lua.h
*/
@@ -122,7 +122,7 @@ static int arrayindex (const TValue *key) {
lua_Number n = nvalue(key);
int k;
lua_number2int(k, n);
- if (luai_numeq(cast_num(k), nvalue(key)))
+ if (luai_numeq(cast_num(k), n))
return k;
}
return -1; /* `key' did not match some condition */
diff --git a/src/luaconf.h b/src/luaconf.h
index 37492955..56705985 100644
--- a/src/luaconf.h
+++ b/src/luaconf.h
@@ -1,5 +1,5 @@
/*
-** $Id: luaconf.h,v 1.77 2005/12/27 17:12:00 roberto Exp $
+** $Id: luaconf.h,v 1.79 2006/01/23 19:51:43 roberto Exp $
** Configuration file for Lua
** See Copyright Notice in lua.h
*/
@@ -488,6 +488,7 @@
** ===================================================================
*/
+#define LUA_NUMBER_DOUBLE
#define LUA_NUMBER double
/*
@@ -702,7 +703,7 @@ union luai_Cast { double l_d; long l_l; };
/*
@@ LUA_INTFRMLEN is the length modifier for integer conversions
-@* in 'string.fomat'.
+@* in 'string.format'.
@@ LUA_INTFRM_T is the integer type correspoding to the previous length
@* modifier.
** CHANGE them if your system supports long long or does not support long.
diff --git a/src/lvm.c b/src/lvm.c
index ef41fddd..6f4c0291 100644
--- a/src/lvm.c
+++ b/src/lvm.c
@@ -1,5 +1,5 @@
/*
-** $Id: lvm.c,v 2.61 2006/01/10 12:50:00 roberto Exp $
+** $Id: lvm.c,v 2.62 2006/01/23 19:51:43 roberto Exp $
** Lua virtual machine
** See Copyright Notice in lua.h
*/
@@ -95,7 +95,8 @@ static void callTMres (lua_State *L, StkId res, const TValue *f,
-static void callTM (lua_State *L, const TValue *f, const TValue *p1, const TValue *p2, const TValue *p3) {
+static void callTM (lua_State *L, const TValue *f, const TValue *p1,
+ const TValue *p2, const TValue *p3) {
setobj2s(L, L->top, f); /* push function */
setobj2s(L, L->top+1, p1); /* 1st argument */
setobj2s(L, L->top+2, p2); /* 2nd argument */
@@ -649,7 +650,8 @@ void luaV_execute (lua_State *L, int nexeccalls) {
lua_Number step = nvalue(ra+2);
lua_Number idx = luai_numadd(nvalue(ra), step); /* increment index */
lua_Number limit = nvalue(ra+1);
- if (step > 0 ? luai_numle(idx, limit) : luai_numle(limit, idx)) {
+ if (luai_numlt(0, step) ? luai_numle(idx, limit)
+ : luai_numle(limit, idx)) {
dojump(L, pc, GETARG_sBx(i)); /* jump back */
setnvalue(ra, idx); /* update internal index... */
setnvalue(ra+3, idx); /* ...and external index */