Makeclass cleaned up
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
|
||||
#include <string.h>
|
||||
#include "luaconsole.hpp"
|
||||
#include "util.hpp"
|
||||
|
||||
|
||||
static bool is_single_letter(const std::string &s) {
|
||||
return ((s.size() == 1) && (s[0] >= 'a') && (s[0] <= 'z'));
|
||||
}
|
||||
|
||||
LuaConsole::LuaConsole() {
|
||||
lua_state_ = lua_open();
|
||||
@@ -52,14 +58,16 @@ void LuaConsole::add(std::string line) {
|
||||
// Try to interpret it as a special command.
|
||||
if (lines_ == 1) {
|
||||
split_words();
|
||||
if ((words_.size() >= 1)&&(words_[0].size() == 1)) {
|
||||
action_ = DO_COMMAND;
|
||||
return;
|
||||
if (words_.size() >= 1) {
|
||||
if (is_single_letter(words_[0]) || (util::validinteger(words_[0]))) {
|
||||
action_ = DO_COMMAND;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
words_.clear();
|
||||
|
||||
// Strip the leading punctuation from lua commands.
|
||||
// Translate lua expression with leading '=' to 'return'
|
||||
std::string partial;
|
||||
if (raw_input_[0] == '=') {
|
||||
partial = std::string("return ") + raw_input_.substr(1);
|
||||
@@ -67,7 +75,7 @@ void LuaConsole::add(std::string line) {
|
||||
partial = raw_input_;
|
||||
}
|
||||
|
||||
// Analyze lua expressions.
|
||||
// Try to parse the lua expression
|
||||
int top = lua_gettop(lua_state_);
|
||||
int status = luaL_loadbuffer(lua_state_, partial.c_str(), partial.size(), "=stdin");
|
||||
if (status == LUA_ERRSYNTAX)
|
||||
|
||||
Reference in New Issue
Block a user