aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-03-18 15:27:08 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-03-18 15:27:08 -0300
commit282d67d8fcd3b06e21d27f3acb8f9efdd992c937 (patch)
tree916818b041a6e81dcbca30a504b12890be3eee97
parent114d10cbc599e848bd28f5b454ec4f8f823dce37 (diff)
downloadlua-282d67d8fcd3b06e21d27f3acb8f9efdd992c937.tar.gz
lua-282d67d8fcd3b06e21d27f3acb8f9efdd992c937.tar.bz2
lua-282d67d8fcd3b06e21d27f3acb8f9efdd992c937.zip
bitlib has been deprecated
-rw-r--r--lbitlib.c23
-rw-r--r--luaconf.h7
2 files changed, 28 insertions, 2 deletions
diff --git a/lbitlib.c b/lbitlib.c
index bca7ba43..d492a15e 100644
--- a/lbitlib.c
+++ b/lbitlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbitlib.c,v 1.22 2013/07/09 18:31:01 roberto Exp roberto $ 2** $Id: lbitlib.c,v 1.23 2014/02/26 12:38:18 roberto Exp roberto $
3** Standard library for bitwise operations 3** Standard library for bitwise operations
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -13,6 +13,9 @@
13#include "lualib.h" 13#include "lualib.h"
14 14
15 15
16#if defined(LUA_COMPAT_BITLIB) /* { */
17
18
16/* number of bits to consider in a number */ 19/* number of bits to consider in a number */
17#if !defined(LUA_NBITS) 20#if !defined(LUA_NBITS)
18#define LUA_NBITS 32 21#define LUA_NBITS 32
@@ -213,3 +216,21 @@ LUAMOD_API int luaopen_bit32 (lua_State *L) {
213 return 1; 216 return 1;
214} 217}
215 218
219
220#else /* }{ */
221
222static int b_err (lua_State *L) {
223 return luaL_error(L, "library 'bit32' is deprecated");
224}
225
226
227LUAMOD_API int luaopen_bit32 (lua_State *L) {
228 lua_createtable(L, 0, 1); /* new table to represent the module */
229 lua_pushvalue(L, -1);
230 lua_setmetatable(L, -2); /* set it as its own metatable */
231 lua_pushcfunction(L, b_err);
232 lua_setfield(L, -2, "__index"); /* metatable.__index = b_errret */
233 return 1;
234}
235
236#endif /* } */
diff --git a/luaconf.h b/luaconf.h
index 075ab1f2..66759701 100644
--- a/luaconf.h
+++ b/luaconf.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: luaconf.h,v 1.190 2014/02/26 15:27:56 roberto Exp roberto $ 2** $Id: luaconf.h,v 1.191 2014/03/06 16:15:18 roberto Exp roberto $
3** Configuration file for Lua 3** Configuration file for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -248,6 +248,11 @@
248#if defined(LUA_COMPAT_ALL) /* { */ 248#if defined(LUA_COMPAT_ALL) /* { */
249 249
250/* 250/*
251@@ LUA_COMPAT_BITLIB controls the presence of library 'bit32'.
252*/
253#define LUA_COMPAT_BITLIB
254
255/*
251@@ LUA_COMPAT_UNPACK controls the presence of global 'unpack'. 256@@ LUA_COMPAT_UNPACK controls the presence of global 'unpack'.
252** You can replace it with 'table.unpack'. 257** You can replace it with 'table.unpack'.
253*/ 258*/