summaryrefslogtreecommitdiff
path: root/src
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 /src
parent4f266285f998d0d14c4e83cc29772f0de1a7fbba (diff)
downloadlua-github-b487a3dce43e449acf3852ec56345e2860cfeab7.tar.gz
Lua 5.1-rc25.1-rc2
Diffstat (limited to 'src')
-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
9 files changed, 51 insertions, 36 deletions
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 */