summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2009-07-19 16:10:10 +0000
committerJo-Philipp Wich <jow@openwrt.org>2009-07-19 16:10:10 +0000
commit1738eddc7d259b2e6ddeb793f18b8fba83c961f7 (patch)
treed87364f8fa81dcebc625d368f3fab435aaf74e0d
parent306b2d865a0f93faf389b86f6fee5041d3c881b2 (diff)
libs/lmo: ensure integer return value in lmo.hash(), fix module open function
-rw-r--r--libs/lmo/src/lmo_lualib.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/libs/lmo/src/lmo_lualib.c b/libs/lmo/src/lmo_lualib.c
index 8d869aa49c..30e91b3805 100644
--- a/libs/lmo/src/lmo_lualib.c
+++ b/libs/lmo/src/lmo_lualib.c
@@ -49,7 +49,7 @@ static int lmo_L_open(lua_State *L) {
static int lmo_L_hash(lua_State *L) {
const char *data = luaL_checkstring(L, 1);
uint32_t hash = sfh_hash(data, strlen(data));
- lua_pushnumber(L, hash);
+ lua_pushinteger(L, (lua_Integer)hash);
return 1;
}
@@ -140,17 +140,13 @@ static const luaL_reg R[] = {
};
LUALIB_API int luaopen_lmo(lua_State *L) {
- luaL_newmetatable(L, LMO_LUALIB_META);
- luaL_register(L, NULL, R);
- lua_pushvalue(L, -1);
- lua_setfield(L, -2, "__index");
- lua_setglobal(L, LMO_LUALIB_META);
-
luaL_newmetatable(L, LMO_ARCHIVE_META);
luaL_register(L, NULL, M);
lua_pushvalue(L, -1);
lua_setfield(L, -2, "__index");
lua_setglobal(L, LMO_ARCHIVE_META);
+ luaL_register(L, LMO_LUALIB_META, R);
+
return 1;
}