Roberto Ierusalimschy пре 15 година
родитељ
комит
93695db903
2 измењених фајлова са 16 додато и 6 уклоњено
  1. 7 2
      ltablib.c
  2. 9 4
      luaconf.h

+ 7 - 2
ltablib.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: ltablib.c,v 1.47 2009/06/17 17:53:50 roberto Exp roberto $
+** $Id: ltablib.c,v 1.48 2009/11/24 12:05:44 roberto Exp roberto $
 ** Library for Table Manipulation
 ** Library for Table Manipulation
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -63,6 +63,7 @@ static int foreach (lua_State *L) {
 }
 }
 
 
 
 
+#if defined(LUA_COMPAT_MAXN)
 static int maxn (lua_State *L) {
 static int maxn (lua_State *L) {
   lua_Number max = 0;
   lua_Number max = 0;
   luaL_checktype(L, 1, LUA_TTABLE);
   luaL_checktype(L, 1, LUA_TTABLE);
@@ -77,7 +78,11 @@ static int maxn (lua_State *L) {
   lua_pushnumber(L, max);
   lua_pushnumber(L, max);
   return 1;
   return 1;
 }
 }
-
+#else
+static int maxn (lua_State *L) {
+  return luaL_error(L, "function 'maxn' is deprecated");
+}
+#endif
 
 
 static int getn (lua_State *L) {
 static int getn (lua_State *L) {
   lua_pushinteger(L, aux_getn(L, 1));
   lua_pushinteger(L, aux_getn(L, 1));

+ 9 - 4
luaconf.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: luaconf.h,v 1.117 2009/11/26 11:39:20 roberto Exp roberto $
+** $Id: luaconf.h,v 1.118 2009/11/26 16:49:28 roberto Exp roberto $
 ** Configuration file for Lua
 ** Configuration file for Lua
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -336,9 +336,8 @@
 
 
 /*
 /*
 @@ LUA_COMPAT_FENV controls the presence of functions 'setfenv/getfenv'.
 @@ LUA_COMPAT_FENV controls the presence of functions 'setfenv/getfenv'.
-** CHANGE it (undefine it) if as soon as you rewrite your code to
-** avoid using those functions. (You can replace them with lexical
-** environments, 'loadin', or the debug library.)
+** CHANGE it (define it) if you need these functions.  (You can replace
+** them with lexical environments, 'loadin', or the debug library.)
 */
 */
 /* #define LUA_COMPAT_FENV */
 /* #define LUA_COMPAT_FENV */
 
 
@@ -349,6 +348,12 @@
 */
 */
 #define LUA_COMPAT_LOG10
 #define LUA_COMPAT_LOG10
 
 
+/*
+@@ LUA_COMPAT_MAXN defines the function 'maxn' in the table library.
+** CHANGE it (define it) if you need that function.
+*/
+/* #define LUA_COMPAT_MAXN */
+
 /*
 /*
 @@ LUA_COMPAT_API includes some macros and functions that supply some
 @@ LUA_COMPAT_API includes some macros and functions that supply some
 @* compatibility with previous versions.
 @* compatibility with previous versions.