X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/2447e531132913a88707e5d457fb2946fa3b0478..b23692f3038296c94d25c84c55ed4c1bb49619cf:/Console.cpp diff --git a/Console.cpp b/Console.cpp index 494e179..76ad553 100644 --- a/Console.cpp +++ b/Console.cpp @@ -394,6 +394,7 @@ static int CYConsoleKeyReturn(int count, int key) { if (memchr(rl_line_buffer, '\n', rl_end) == NULL) return rl_newline(count, key); + insert: char *before(CYmemrchr(rl_line_buffer, '\n', rl_point)); if (before == NULL) before = rl_line_buffer; @@ -440,8 +441,8 @@ static int CYConsoleKeyReturn(int count, int key) { if (done) return rl_newline(count, key); - rl_insert(count, '\n'); - return 0; + // XXX: this was the most obvious fix, but is seriously dumb + goto insert; } static int CYConsoleKeyUp(int count, int key) { @@ -646,6 +647,7 @@ static void Console(CYOptions &options) { free(line); if (command.empty()) continue; + history += command; if (command[0] == '?') { std::string data(command.substr(1)); @@ -671,14 +673,13 @@ static void Console(CYOptions &options) { *out_ << "lower == " << (lower ? "true" : "false") << std::endl; } - history += command; continue; } std::string code; if (bypass) code = command; - else { + else try { std::istringstream stream(command); CYPool pool; @@ -707,7 +708,6 @@ static void Console(CYOptions &options) { std::cerr << " | "; std::cerr << error->message_ << std::endl; - history += command; break; } @@ -722,10 +722,12 @@ static void Console(CYOptions &options) { Setup(out, driver, options, lower); out << *driver.script_; code = str.str(); + } catch (const CYException &error) { + CYPool pool; + std::cout << error.PoolCString(pool) << std::endl; + continue; } - history += command; - if (debug) { std::cout << "cy= "; CYLexerHighlight(code.c_str(), code.size(), std::cout); @@ -1098,6 +1100,7 @@ int Main(int argc, char * const argv[], char const * const envp[]) { if (failed || !driver.errors_.empty()) { for (CYDriver::Errors::const_iterator i(driver.errors_.begin()); i != driver.errors_.end(); ++i) std::cerr << i->location_.begin << ": " << i->message_ << std::endl; + return 1; } else if (driver.script_ != NULL) { std::stringbuf str; CYOutput out(str, options);