Index: trunk/FACT++/src/Readline.cc
===================================================================
--- trunk/FACT++/src/Readline.cc	(revision 10307)
+++ trunk/FACT++/src/Readline.cc	(revision 10308)
@@ -169,12 +169,57 @@
 
     // Trim Both leading and trailing spaces
-    const size_t start = str.find_first_not_of(" "); // Find the first character position after excluding leading blank spaces
-    const size_t end   = str.find_last_not_of(" ");  // Find the first character position from reverse af
+    const size_t start = str.find_first_not_of(' '); // Find the first character position after excluding leading blank spaces
+    const size_t end   = str.find_last_not_of(' ');  // Find the first character position from reverse af
 
     // if all spaces or empty return an empty string
     if (string::npos==start || string::npos==end)
-        return "";
+        return string();
 
     return str.substr(start, end-start+1);
+}
+
+// --------------------------------------------------------------------------
+//
+//! This wraps the given readline function such that the output can be
+//! redirected from thr rl_outstream to the given C++ ostream.
+//!
+//! @param ostream
+//!    The stream to which the output should be redirected.
+//!
+//! @param function
+//!    Takes a function of type bool(*)() as argument
+//!
+//! @returns
+//!    The return value of the function
+//
+bool Readline::RedirectionWrapper(ostream &out, bool (*function)())
+{
+    FILE *save = SetStreamOut(tmpfile());
+    const bool rc = function();
+    FILE *file = SetStreamOut(save);
+
+    const bool empty = ftell(file)==0;
+
+    rewind(file);
+
+    if (empty)
+    {
+        out << " <empty>" << endl;
+        fclose(file);
+        return rc;
+    }
+
+    while (1)
+    {
+        const int c = getc(file);
+        if (feof(file))
+            break;
+        out << (char)c;
+    }
+    out << endl;
+
+    fclose(file);
+
+    return rc;
 }
 
@@ -333,5 +378,7 @@
 char *Readline::Compare(const string &str, const string &txt)
 {
-    return str.substr(0, txt.length())==txt ? strndup(str.c_str(), str.length()) : 0;
+    /*return strncmp(str.c_str(), txt.c_str(), txt.length())==0 ? */
+    return strncasecmp(str.c_str(), txt.c_str(), txt.length())==0 ?
+        strndup(str.c_str(), str.length()) : 0;
 }
 
@@ -814,4 +861,7 @@
 {
     HIST_ENTRY **next = history_list();
+
+    if (!next)
+        return true;
 
     for (; *next; next++)
Index: trunk/FACT++/src/Readline.h
===================================================================
--- trunk/FACT++/src/Readline.h	(revision 10307)
+++ trunk/FACT++/src/Readline.h	(revision 10308)
@@ -9,4 +9,5 @@
 public:
     static std::string TrimSpaces(const char *buf);
+    static bool RedirectionWrapper(std::ostream &out, bool (*function)());
 
 protected:
