Skip to content

Commit 13b448e

Browse files
authored
Merge pull request #1153 from mmd-osm/patch/issue_1151
luaL_traceback is not supported in Lua 5.1, except for LuaJIT
2 parents 4eb7332 + f32a445 commit 13b448e

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

.travis.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,18 @@ matrix:
7272
CXXFLAGS="-pedantic -Wextra -Werror"
7373
CC=gcc-5 CXX=g++-5 CPPVERSION=11
7474

75+
- os: linux
76+
dist: bionic
77+
compiler: gcc-7
78+
env: T="bionic_gcc7_pg12"
79+
PG_VERSIONS=12
80+
POSTGIS_VERSION=3
81+
LUA_VERSION=5.1
82+
BUILD_TYPE="Debug" LUAJIT_OPTION="OFF"
83+
CXXFLAGS="-pedantic -Wextra -Werror"
84+
CC=gcc-7 CXX=g++-7 CPPVERSION=11
85+
86+
7587
- os: linux
7688
dist: bionic
7789
compiler: gcc-8

src/lua-utils.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "config.h"
12
#include "lua-utils.hpp"
23
#include "format.hpp"
34

@@ -136,6 +137,17 @@ bool luaX_get_table_bool(lua_State *lua_state, char const *key, int table_index,
136137
"{} must contain a '{}' boolean field"_format(error_msg, key)};
137138
}
138139

140+
141+
// Lua 5.1 doesn't support luaL_traceback, unless LuaJIT is used
142+
#if LUA_VERSION_NUM < 502 && !defined(HAVE_LUAJIT)
143+
144+
int luaX_pcall(lua_State *lua_state, int narg, int nres)
145+
{
146+
return lua_pcall(lua_state, narg, nres, 0);
147+
}
148+
149+
#else
150+
139151
static int pcall_error_traceback_handler(lua_State *lua_state)
140152
{
141153
assert(lua_state);
@@ -166,3 +178,5 @@ int luaX_pcall(lua_State *lua_state, int narg, int nres)
166178
lua_remove(lua_state, base); // remove message handler from the stack
167179
return status;
168180
}
181+
182+
#endif

0 commit comments

Comments
 (0)