# HG changeset patch # User Myhailo Danylenko # Date 1457191932 -7200 # Node ID c17f3295f52cd1dfc1413c0ac2bde2cf6e48d77c # Parent d92358eafeade165274eced4ba9393523a8f6b91 lua: Add compatibility with lua 5.3 diff -r d92358eafead -r c17f3295f52c CMakeLists.txt --- a/CMakeLists.txt Sat Mar 05 15:51:12 2016 +0200 +++ b/CMakeLists.txt Sat Mar 05 17:32:12 2016 +0200 @@ -16,27 +16,44 @@ cmake_minimum_required(VERSION 2.6) project(lua-lm C) -set(PROJECT_VERSION "0.9.5") +set(PROJECT_VERSION "0.9.6") ## User options -option(DEBUG "Enable debugging output" OFF) -option(WANT_LUA52 "Force Lua 5.2 usage" OFF) +option(DEBUG "Enable debugging output" OFF) set(TEST_USER "test@jabber.org" CACHE STRING "Testing: Your jabber account name") set(TEST_PASSWORD "greatsecret" CACHE STRING "Testing: Password for your jabber account") set(TEST_TO "test@jabber.org/mcabber" CACHE STRING "Testing: Target jabber entity") set(TEST_FINGERPRINT "00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff" CACHE STRING "Testing: Your jabber server SSL fingerprint") +set(WANT_LUA "AUTO" CACHE STRING "Lua version to use (You'll have to define this with -DWANT_LUA=LUAX.X)") +set_property(CACHE WANT_LUA PROPERTY STRINGS "AUTO" "LUA5.1" "LUA5.2" "LUA5.3") ## Gather information about system find_package(PkgConfig REQUIRED) -if(NOT WANT_LUA52) - find_package(Lua51) -endif() -if(WANT_LUA52 OR NOT LUA51_FOUND) +if(WANT_LUA STREQUAL "LUA5.3") + pkg_check_modules(LUA REQUIRED lua5.3) + set(LUA_VERSION "5.3") +elseif(WANT_LUA STREQUAL "LUA5.2") pkg_check_modules(LUA REQUIRED lua5.2) set(LUA_VERSION "5.2") - set(HAVE_LUA52 "1") +elseif(WANT_LUA STREQUAL "LUA5.1") + find_package(Lua51 REQUIRED) + set(LUA_VERSION "5.1") else() - set(LUA_VERSION "5.1") + pkg_check_modules(LUA lua5.3) + if(LUA_FOUND) + set(LUA_VERSION "5.3") + else() + pkg_check_modules(LUA lua5.2) + if(LUA_FOUND) + set(LUA_VERSION "5.2") + else() + find_package(Lua51 REQUIRED) + set(LUA_VERSION "5.1") + endif() + endif() +endif() +if(LUA_VERSION STREQUAL "5.1") + set(LUA51_COMPATIBILITY TRUE) set(LUA_INCLUDE_DIRS ${LUA_INCLUDE_DIR}) endif() find_program(LUA_EXECUTABLE lua${LUA_VERSION} lua luanoreadline) diff -r d92358eafead -r c17f3295f52c config.h.in --- a/config.h.in Sat Mar 05 15:51:12 2016 +0200 +++ b/config.h.in Sat Mar 05 17:32:12 2016 +0200 @@ -22,9 +22,6 @@ // define this to enable debugging output #cmakedefine DEBUG -// define this, if you are building with liblua 5.2 -#cmakedefine HAVE_LUA52 - // define this, if your loudmouth uses SHA256 fingerprints #cmakedefine HAVE_LM_SHA256_FINGERPRINTS @@ -40,7 +37,10 @@ // define this, if your loudmouth have lm_ssl_set_cipher_list () #cmakedefine HAVE_LM_SSL_SET_CIPHER_LIST -#ifndef HAVE_LUA52 +// building against lua 5.1 +#cmakedefine LUA51_COMPATIBILITY + +#ifdef LUA51_COMPATIBILITY # define lua_rawlen lua_objlen # define luaL_setfuncs(STATE, REGTABLE, IGZERO) luaL_register ( STATE, NULL, REGTABLE ) #endif diff -r d92358eafead -r c17f3295f52c lm_connection.c --- a/lm_connection.c Sat Mar 05 15:51:12 2016 +0200 +++ b/lm_connection.c Sat Mar 05 17:32:12 2016 +0200 @@ -187,7 +187,7 @@ { llm_connection_t *object = luaL_checklm_connection (L, 1); if (lua_gettop (L) > 1) { // Set - lm_connection_set_port (object->connection, luaL_checkint (L, 2)); + lm_connection_set_port (object->connection, luaL_checkinteger (L, 2)); lua_pop (L, 1); } else { // Get lua_pushnumber (L, lm_connection_get_port (object->connection)); @@ -237,7 +237,7 @@ { llm_connection_t *object = luaL_checklm_connection (L, 1); if (lua_gettop (L) > 1) { // Set - lm_connection_set_keep_alive_rate (object->connection, luaL_checkint (L, 2)); + lm_connection_set_keep_alive_rate (object->connection, luaL_checkinteger (L, 2)); lua_pop (L, 1); return 1; } else { // Get diff -r d92358eafead -r c17f3295f52c lm_proxy.c --- a/lm_proxy.c Sat Mar 05 15:51:12 2016 +0200 +++ b/lm_proxy.c Sat Mar 05 17:32:12 2016 +0200 @@ -49,7 +49,7 @@ int type = luaL_checkenum (L, 1, type_lm_proxy); LmProxy *proxy; if (lua_gettop (L) > 0) - proxy = lm_proxy_new_with_server (type, luaL_checkstring (L, 2), luaL_checkint (L, 3)); + proxy = lm_proxy_new_with_server (type, luaL_checkstring (L, 2), luaL_checkinteger (L, 3)); else proxy = lm_proxy_new (type); bless_lm_proxy (L, proxy); @@ -107,7 +107,7 @@ { llm_proxy_t *object = luaL_checklm_proxy (L, 1); if (lua_gettop (L) > 1) { // Set - lm_proxy_set_port (object->proxy, luaL_checkint (L, 2)); + lm_proxy_set_port (object->proxy, luaL_checkinteger (L, 2)); lua_pop (L, 1); } else // Get lua_pushnumber (L, lm_proxy_get_port (object->proxy));