summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2007-06-21 10:52:27 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2007-06-21 10:52:27 -0300
commit8d3dd04137348b604ec9ebee87df84c8ef5fdced (patch)
tree291dcb423b3f288145196334d8121dacfe1fa3fa
parent791d8d858502f34204e0460c73e5eb6d340bcd92 (diff)
downloadlua-github-8d3dd04137348b604ec9ebee87df84c8ef5fdced.tar.gz
clearing some old compatibility code
-rw-r--r--lauxlib.c90
-rw-r--r--lauxlib.h14
-rw-r--r--lbaselib.c4
-rw-r--r--lmathlib.c6
-rw-r--r--loadlib.c6
-rw-r--r--ltests.c12
-rw-r--r--luaconf.h30
7 files changed, 13 insertions, 149 deletions
diff --git a/lauxlib.c b/lauxlib.c
index b12ff3e8..c645c32c 100644
--- a/lauxlib.c
+++ b/lauxlib.c
@@ -1,5 +1,5 @@
/*
-** $Id: lauxlib.c,v 1.166 2007/04/19 20:21:53 roberto Exp roberto $
+** $Id: lauxlib.c,v 1.167 2007/05/15 18:46:12 roberto Exp roberto $
** Auxiliary functions for building Lua libraries
** See Copyright Notice in lua.h
*/
@@ -257,12 +257,6 @@ LUALIB_API const char *luaL_tostring (lua_State *L, int idx) {
}
-LUALIB_API void luaL_register (lua_State *L, const char *libname,
- const luaL_Reg *l) {
- luaI_openlib(L, libname, l, 0);
-}
-
-
static int libsize (const luaL_Reg *l) {
int size = 0;
for (; l->name; l++) size++;
@@ -270,8 +264,8 @@ static int libsize (const luaL_Reg *l) {
}
-LUALIB_API void luaI_openlib (lua_State *L, const char *libname,
- const luaL_Reg *l, int nup) {
+LUALIB_API void luaL_register (lua_State *L, const char *libname,
+ const luaL_Reg *l) {
if (libname) {
int size = libsize(l);
/* check whether lib already exists */
@@ -286,88 +280,14 @@ LUALIB_API void luaI_openlib (lua_State *L, const char *libname,
lua_setfield(L, -3, libname); /* _LOADED[libname] = new table */
}
lua_remove(L, -2); /* remove _LOADED table */
- lua_insert(L, -(nup+1)); /* move library table to below upvalues */
}
for (; l->name; l++) {
- int i;
- for (i=0; i<nup; i++) /* copy upvalues to the top */
- lua_pushvalue(L, -nup);
- lua_pushcclosure(L, l->func, nup);
- lua_setfield(L, -(nup+2), l->name);
- }
- lua_pop(L, nup); /* remove upvalues */
-}
-
-
-
-/*
-** {======================================================
-** getn-setn: size for arrays
-** =======================================================
-*/
-
-#if defined(LUA_COMPAT_GETN)
-
-static int checkint (lua_State *L, int topop) {
- int n = (lua_type(L, -1) == LUA_TNUMBER) ? lua_tointeger(L, -1) : -1;
- lua_pop(L, topop);
- return n;
-}
-
-
-static void getsizes (lua_State *L) {
- lua_getfield(L, LUA_REGISTRYINDEX, "LUA_SIZES");
- if (lua_isnil(L, -1)) { /* no `size' table? */
- lua_pop(L, 1); /* remove nil */
- lua_newtable(L); /* create it */
- lua_pushvalue(L, -1); /* `size' will be its own metatable */
- lua_setmetatable(L, -2);
- lua_pushliteral(L, "kv");
- lua_setfield(L, -2, "__mode"); /* metatable(N).__mode = "kv" */
- lua_pushvalue(L, -1);
- lua_setfield(L, LUA_REGISTRYINDEX, "LUA_SIZES"); /* store in register */
- }
-}
-
-
-LUALIB_API void luaL_setn (lua_State *L, int t, int n) {
- t = abs_index(L, t);
- 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' */
+ lua_pushcfunction(L, l->func);
+ lua_setfield(L, -2, l->name);
}
}
-LUALIB_API int luaL_getn (lua_State *L, int t) {
- int n;
- t = abs_index(L, 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;
- return (int)lua_objlen(L, t);
-}
-
-#endif
-
-/* }====================================================== */
-
-
-
LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p,
const char *r) {
const char *wild;
diff --git a/lauxlib.h b/lauxlib.h
index 1d44c54d..efcd5e3a 100644
--- a/lauxlib.h
+++ b/lauxlib.h
@@ -1,5 +1,5 @@
/*
-** $Id: lauxlib.h,v 1.89 2007/02/07 17:51:21 roberto Exp roberto $
+** $Id: lauxlib.h,v 1.90 2007/05/15 18:46:12 roberto Exp roberto $
** Auxiliary functions for building Lua libraries
** See Copyright Notice in lua.h
*/
@@ -15,18 +15,6 @@
#include "lua.h"
-#if defined(LUA_COMPAT_GETN)
-LUALIB_API int (luaL_getn) (lua_State *L, int t);
-LUALIB_API void (luaL_setn) (lua_State *L, int t, int n);
-#else
-#define luaL_getn(L,i) ((int)lua_objlen(L, i))
-#define luaL_setn(L,i,j) ((void)0) /* no op! */
-#endif
-
-#if defined(LUA_COMPAT_OPENLIB)
-#define luaI_openlib luaL_openlib
-#endif
-
/* extra error code for `luaL_load' */
#define LUA_ERRFILE (LUA_ERRERR+1)
diff --git a/lbaselib.c b/lbaselib.c
index 5f7e6658..c48487da 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -1,5 +1,5 @@
/*
-** $Id: lbaselib.c,v 1.196 2007/02/07 17:51:21 roberto Exp roberto $
+** $Id: lbaselib.c,v 1.197 2007/02/09 12:40:21 roberto Exp roberto $
** Basic library
** See Copyright Notice in lua.h
*/
@@ -343,7 +343,7 @@ static int luaB_unpack (lua_State *L) {
int i, e, n;
luaL_checktype(L, 1, LUA_TTABLE);
i = luaL_optint(L, 2, 1);
- e = luaL_opt(L, luaL_checkint, 3, luaL_getn(L, 1));
+ e = luaL_opt(L, luaL_checkint, 3, (int)lua_objlen(L, 1));
n = e - i + 1; /* number of elements */
if (n <= 0) return 0; /* empty range */
luaL_checkstack(L, n, "table too big to unpack");
diff --git a/lmathlib.c b/lmathlib.c
index 3d920715..be26b5dd 100644
--- a/lmathlib.c
+++ b/lmathlib.c
@@ -1,5 +1,5 @@
/*
-** $Id: lmathlib.c,v 1.68 2006/08/07 19:01:56 roberto Exp roberto $
+** $Id: lmathlib.c,v 1.69 2007/03/27 12:37:00 roberto Exp roberto $
** Standard mathematical library
** See Copyright Notice in lua.h
*/
@@ -258,10 +258,6 @@ LUALIB_API int luaopen_math (lua_State *L) {
lua_setfield(L, -2, "pi");
lua_pushnumber(L, HUGE_VAL);
lua_setfield(L, -2, "huge");
-#if defined(LUA_COMPAT_MOD)
- lua_getfield(L, -1, "fmod");
- lua_setfield(L, -2, "mod");
-#endif
return 1;
}
diff --git a/loadlib.c b/loadlib.c
index 5aa0e68c..16d5c4f4 100644
--- a/loadlib.c
+++ b/loadlib.c
@@ -1,5 +1,5 @@
/*
-** $Id: loadlib.c,v 1.56 2006/10/10 17:40:17 roberto Exp roberto $
+** $Id: loadlib.c,v 1.57 2007/03/26 15:57:35 roberto Exp roberto $
** Dynamic library loader for Lua
** See Copyright Notice in lua.h
**
@@ -628,10 +628,6 @@ LUALIB_API int luaopen_package (lua_State *L) {
lua_setfield(L, -2, "__gc");
/* create `package' table */
luaL_register(L, LUA_LOADLIBNAME, pk_funcs);
-#if defined(LUA_COMPAT_LOADLIB)
- lua_getfield(L, -1, "loadlib");
- lua_setfield(L, LUA_GLOBALSINDEX, "loadlib");
-#endif
lua_pushvalue(L, -1);
lua_replace(L, LUA_ENVIRONINDEX);
/* create `loaders' table */
diff --git a/ltests.c b/ltests.c
index 08141411..c642ff1a 100644
--- a/ltests.c
+++ b/ltests.c
@@ -1,5 +1,5 @@
/*
-** $Id: ltests.c,v 2.41 2007/04/10 12:17:52 roberto Exp roberto $
+** $Id: ltests.c,v 2.42 2007/04/17 13:19:53 roberto Exp roberto $
** Internal Module for Debugging of the Lua Implementation
** See Copyright Notice in lua.h
*/
@@ -996,16 +996,8 @@ static int testC (lua_State *L) {
}
else if EQ("getn") {
int i = getindex;
- lua_pushinteger(L1, luaL_getn(L1, i));
+ lua_pushinteger(L1, lua_objlen(L1, i));
}
-#ifndef luaL_setn
- else if EQ("setn") {
- int i = getindex;
- int n = cast_int(lua_tonumber(L1, -1));
- luaL_setn(L1, i, n);
- lua_pop(L1, 1);
- }
-#endif
else if EQ("throw") {
#if defined(__cplusplus)
static struct X { int x; } x;
diff --git a/luaconf.h b/luaconf.h
index 8e5479ab..49a0e30a 100644
--- a/luaconf.h
+++ b/luaconf.h
@@ -1,5 +1,5 @@
/*
-** $Id: luaconf.h,v 1.87 2007/02/07 17:46:20 roberto Exp roberto $
+** $Id: luaconf.h,v 1.88 2007/05/03 20:49:29 roberto Exp roberto $
** Configuration file for Lua
** See Copyright Notice in lua.h
*/
@@ -321,20 +321,6 @@
/*
-@@ LUA_COMPAT_GETN controls compatibility with old getn behavior.
-** CHANGE it (define it) if you want exact compatibility with the
-** behavior of setn/getn in Lua 5.0.
-*/
-#undef LUA_COMPAT_GETN
-
-/*
-@@ LUA_COMPAT_LOADLIB controls compatibility about global loadlib.
-** CHANGE it to undefined as soon as you do not need a global 'loadlib'
-** function (the function is still available as 'package.loadlib').
-*/
-#undef LUA_COMPAT_LOADLIB
-
-/*
@@ LUA_COMPAT_VARARG controls compatibility with old vararg feature.
** CHANGE it to undefined as soon as your programs use only '...' to
** access vararg parameters (instead of the old 'arg' table).
@@ -342,26 +328,12 @@
#define LUA_COMPAT_VARARG
/*
-@@ LUA_COMPAT_MOD controls compatibility with old math.mod function.
-** CHANGE it to undefined as soon as your programs use 'math.fmod' or
-** the new '%' operator instead of 'math.mod'.
-*/
-#define LUA_COMPAT_MOD
-
-/*
@@ LUA_COMPAT_GFIND controls compatibility with old 'string.gfind' name.
** CHANGE it to undefined as soon as you rename 'string.gfind' to
** 'string.gmatch'.
*/
#define LUA_COMPAT_GFIND
-/*
-@@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib'
-@* behavior.
-** CHANGE it to undefined as soon as you replace to 'luaL_register'
-** your uses of 'luaL_openlib'
-*/
-#define LUA_COMPAT_OPENLIB