[Saga-devel] saga SVN commit 3265: /trunk/tools/shell/
amerzky at cct.lsu.edu
amerzky at cct.lsu.edu
Tue Jan 13 17:13:04 CST 2009
User: amerzky
Date: 2009/01/13 05:13 PM
Modified:
/trunk/tools/shell/
saga-shell.cpp, saga-shell.hpp
Log:
clean bailout on stdin error
A
File Changes:
Directory: /trunk/tools/shell/
==============================
File [modified]: saga-shell.cpp
Delta lines: +26 -9
===================================================================
--- trunk/tools/shell/saga-shell.cpp 2009-01-12 17:58:17 UTC (rev 3264)
+++ trunk/tools/shell/saga-shell.cpp 2009-01-13 23:12:52 UTC (rev 3265)
@@ -252,6 +252,7 @@
if ( input == "exit" ||
input == "quit" )
{
+ std::cout << std::endl;
return;
}
}
@@ -682,34 +683,50 @@
std::string shell::get_input (std::string prompt)
{
- std::string input;
if ( prompt == "" )
{
prompt = prompt_;
}
+
#if SAGA_HAVE_READLINE == 1
- static std::string last = "";
- input = ::readline (prompt.c_str ());
- if ( input != "" &&
- input != last )
+ char* line = ::readline (prompt.c_str ());
+
+ input_ = "quit";
+
+ if ( NULL != line )
{
- add_history (input.c_str ());
+ input_ = line;
}
- last = input;
+ if ( input_ != "" &&
+ input_ != "quit" &&
+ input_ != last_input_ )
+ {
+ add_history (input_.c_str ());
+ }
+
#else
+
std::cout << prompt << std::flush;
- std::getline (std::cin, input);
+ std::getline (std::cin, input_);
+
+ if ( ! std::cin.good () )
+ {
+ return "quit";
+ }
+
+
#endif
- return (input);
+ last_input_ = input_;
+ return (input_);
}
File [modified]: saga-shell.hpp
Delta lines: +2 -0
===================================================================
--- trunk/tools/shell/saga-shell.hpp 2009-01-12 17:58:17 UTC (rev 3264)
+++ trunk/tools/shell/saga-shell.hpp 2009-01-13 23:12:52 UTC (rev 3265)
@@ -73,6 +73,8 @@
// prompt
std::string prompt_;
+ std::string input_;
+ std::string last_input_;
// the commands
// - namespace related
More information about the saga-devel
mailing list