summaryrefslogtreecommitdiff
path: root/lbitlib.c
diff options
context:
space:
mode:
Diffstat (limited to 'lbitlib.c')
-rw-r--r--lbitlib.c23
1 files changed, 22 insertions, 1 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 /* } */