|
From: stephan b. <sg...@us...> - 2004-05-31 19:56:12
|
Update of /cvsroot/qub/eshell/lib/eshell In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15538/lib/eshell Modified Files: eshell.cpp eshell.h object_pool.h Log Message: libreadline_cpp support is now optional. Index: eshell.cpp =================================================================== RCS file: /cvsroot/qub/eshell/lib/eshell/eshell.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- eshell.cpp 31 May 2004 15:18:25 -0000 1.3 +++ eshell.cpp 31 May 2004 19:56:03 -0000 1.4 @@ -33,8 +33,10 @@ #include <s11n.net/t5x/environment.hpp> -#include <s11n.net/readline/Readline.hpp> -#include <s11n.net/readline/Readline_s11n.hpp> +#if HAVE_LIBREADLINECPP +# include <s11n.net/readline/Readline.hpp> +# include <s11n.net/readline/Readline_s11n.hpp> +#endif #define ESHELLDEBUG if( env().get_bool( "debug", false ) ) CERR [...106 lines suppressed...] +#if HAVE_LIBREADLINECPP s11n::serialize_subnode( node, "readline", readline() ); +#endif return s11nlite::save( node, filename ); } @@ -578,11 +594,12 @@ s11n::map::deserialize_streamable_map( session(), "aliases", aliases().map() ); s11n::map::deserialize_streamable_map( session(), "environment", env().get_map() ); +#if HAVE_LIBREADLINECPP if( (node = s11nlite::find_child( session(), "readline" )) ) { s11nlite::deserialize( *node, readline() ); } - +#endif return true; } Index: eshell.h =================================================================== RCS file: /cvsroot/qub/eshell/lib/eshell/eshell.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- eshell.h 31 May 2004 15:18:25 -0000 1.2 +++ eshell.h 31 May 2004 19:56:03 -0000 1.3 @@ -261,6 +261,25 @@ void map_commander( const std::string & key, command_handler ); /** + Reads a line of input and returns it. The exact mechanism + used to read the input depends on whether or not this lib + was build with libreadline_cpp support. + + When this function returns, if breakout is true then this + is a signal to the client that no more input should be + read. This is normally triggered by Ctrl-D, but that + depends on the exact input method used by this library. + + Note that $var expansion are done on prompt, so it may + container environment variables. + + No other processing is done: the exact input value is + passed back to the client without eshell dispatching it or + setting any error codes. + */ + std::string read_line( const std::string & prompt, bool & breakout ); + + /** Accepts input from the command line until the user taps Ctrl-D or types one of quit/exit/logout. It dispatch()es each input line after doing alias and $environment_var Index: object_pool.h =================================================================== RCS file: /cvsroot/qub/eshell/lib/eshell/object_pool.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- object_pool.h 31 May 2004 15:18:25 -0000 1.2 +++ object_pool.h 31 May 2004 19:56:03 -0000 1.3 @@ -135,13 +135,15 @@ { if( 0 == key ) { - typename object_map::iterator it; - do - { // look until we find an empty spot: - it = m_hashish.find( key = next_key() ); - } while( m_hashish.end() != it ); - // ^^^ Will cause an endless loop once you have max(key_type) objects in the map. - // Since that number is in the billions, that's not really a bug just yet. + key = next_key(); +// typename object_map::iterator it, +// eit = m_hashish.end(); +// do +// { // look until we find an empty spot: +// it = m_hashish.find( key = next_key() ); +// } while( eit != it ); +// // ^^^ Will cause an endless loop once you have max(key_type) objects in the map. +// // Since that number is in the billions, that's not really a bug just yet. } m_hashish[key] = obj; m_reverse[obj] = key; @@ -188,10 +190,10 @@ } /** - Relinquishes control of this object. - Returns NULL if it did not have the given child, otherwise - a pointer to that object. The caller becomes - the owner of that object. + Relinquishes control of this object. Returns 0 if + it did not have the given child, otherwise a + pointer to that object. The caller becomes the + owner of that object. This would be called release_object(), but that is easily misunderstood as freeing up resources, something @@ -200,7 +202,7 @@ value_type * relinquish_object( const key_type key ) { typename object_map::iterator it = m_hashish.find( key ); - if( m_hashish.end() == it ) return NULL; + if( m_hashish.end() == it ) return 0; value_type * v = (*it).second; m_hashish.erase( it ); if( v ) |