Implement C++ pretty-printer
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include "traceback.hpp"
|
||||
#include "textgame.hpp"
|
||||
#include "luaconsole.hpp"
|
||||
#include "print.hpp"
|
||||
|
||||
// Add another error status.
|
||||
|
||||
@@ -54,17 +55,8 @@ void TextGame::do_lua(const std::string &exp) {
|
||||
signal(SIGINT, SIG_DFL);
|
||||
if (status == LUA_OK) {
|
||||
if (lua_gettop(L) > 0) {
|
||||
lua_getglobal(L, "pprint");
|
||||
if (lua_isnil(L, -1)) {
|
||||
lua_pop(L, 1);
|
||||
lua_getglobal(L, "print");
|
||||
}
|
||||
lua_insert(L, 1);
|
||||
if (lua_pcall(L, lua_gettop(L) - 1, 0, 0) != 0) {
|
||||
l_message(
|
||||
lua_pushfstring(L, "error calling 'print' (%s)",
|
||||
lua_tostring(L, -1)));
|
||||
}
|
||||
lfn_pprint_pprint(L);
|
||||
lua_settop(L, 0);
|
||||
}
|
||||
} else {
|
||||
const char *msg = lua_tostring(L, -1);
|
||||
|
||||
Reference in New Issue
Block a user