aboutsummaryrefslogtreecommitdiffstats
path: root/epan/wslua/lua_bitop.c
diff options
context:
space:
mode:
authorStig Bjørlykke <stig@bjorlykke.org>2013-03-15 15:15:00 +0000
committerStig Bjørlykke <stig@bjorlykke.org>2013-03-15 15:15:00 +0000
commit187a884cead3af81f25f3b62711f051e86035091 (patch)
tree641549a9512e8b204310fd888857626371e311d6 /epan/wslua/lua_bitop.c
parente2e3f5863a05f0a08cc3043e05fc6646c43b5015 (diff)
Update Lua BitOp to version 1.0.2
svn path=/trunk/; revision=48316
Diffstat (limited to 'epan/wslua/lua_bitop.c')
-rw-r--r--epan/wslua/lua_bitop.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/epan/wslua/lua_bitop.c b/epan/wslua/lua_bitop.c
index 36804e2836..5db24d5e02 100644
--- a/epan/wslua/lua_bitop.c
+++ b/epan/wslua/lua_bitop.c
@@ -1,10 +1,8 @@
/*
-** Lua BitOp -- a bit operations library for Lua 5.1.
+** Lua BitOp -- a bit operations library for Lua 5.1/5.2.
** http://bitop.luajit.org/
**
-** Copyright (C) 2008-2009 Mike Pall. All rights reserved.
-**
-** $Id$
+** Copyright (C) 2008-2012 Mike Pall. All rights reserved.
**
** Permission is hereby granted, free of charge, to any person obtaining
** a copy of this software and associated documentation files (the
@@ -28,7 +26,7 @@
** [ MIT license: http://www.opensource.org/licenses/mit-license.php ]
*/
-#define LUA_BITOP_VERSION "1.0.1"
+#define LUA_BITOP_VERSION "1.0.2"
#define LUA_LIB
#include <lua.h>
@@ -60,7 +58,11 @@ static UBits barg(lua_State *L, int idx)
{
BitNum bn;
UBits b;
+#if LUA_VERSION_NUM < 502
bn.n = lua_tonumber(L, idx);
+#else
+ bn.n = luaL_checknumber(L, idx);
+#endif
#if defined(LUA_NUMBER_DOUBLE)
bn.n += 6755399441055744.0; /* 2^52+2^51 */
#ifdef SWAPPED_DOUBLE
@@ -80,8 +82,11 @@ static UBits barg(lua_State *L, int idx)
#else
#error "Unknown number type, check LUA_NUMBER_* in luaconf.h"
#endif
- if (b == 0 && !lua_isnumber(L, idx))
- luaL_error(L, "bad argument %d (number expected, got %s)", idx, lua_typename(L, lua_type(L, idx)));
+#if LUA_VERSION_NUM < 502
+ if (b == 0 && !lua_isnumber(L, idx)) {
+ luaL_typerror(L, idx, "number");
+ }
+#endif
return b;
}
@@ -174,14 +179,11 @@ LUALIB_API int luaopen_bit(lua_State *L)
msg = "arithmetic right-shift broken";
luaL_error(L, "bit library self-test failed (%s)", msg);
}
-
-#if LUA_VERSION_NUM >= 502
- luaL_newlib(L, bit_funcs);
- lua_setglobal(L, "bit");
-#else
+#if LUA_VERSION_NUM < 502
luaL_register(L, "bit", bit_funcs);
+#else
+ luaL_newlib(L, bit_funcs);
#endif
-
return 1;
}