# HG changeset patch # User John W. Eaton # Date 1296713081 18000 # Node ID 3dd1b0b36f13df4b339ed5efeae169008fc366ec # Parent 044ca61e6750e38e575e6281c4a8291e4b2f4c7d require readline to provide working history control diff -r 044ca61e6750 -r 3dd1b0b36f13 liboctave/ChangeLog --- a/liboctave/ChangeLog Wed Feb 02 21:31:33 2011 -0800 +++ b/liboctave/ChangeLog Thu Feb 03 01:04:41 2011 -0500 @@ -1,3 +1,13 @@ +2011-02-03 John W. Eaton + + * cmd-hist.cc (gnu_history::do_process_histcontrol): + Rename from command_history::do_process_histcontrol. + (gnu_history::do_histcontrol): Rename from + command_history::do_histcontrol. + * cmd-hist.h (command_history::do_histcontrol): Provide dummy version. + * cmd-hist.cc (command_history::do_process_histcontrol): Likewise. + Bug #32325. + 2011-02-02 John W. Eaton * Range.cc (Range::Range (double, double, octave_idx_type)): diff -r 044ca61e6750 -r 3dd1b0b36f13 liboctave/cmd-hist.cc --- a/liboctave/cmd-hist.cc Wed Feb 02 21:31:33 2011 -0800 +++ b/liboctave/cmd-hist.cc Thu Feb 03 01:04:41 2011 -0500 @@ -60,6 +60,10 @@ ~gnu_history (void) { } + void do_process_histcontrol (const std::string&); + + std::string do_histcontrol (void) const; + void do_add (const std::string&); void do_remove (int); @@ -108,6 +112,76 @@ }; void +gnu_history::do_process_histcontrol (const std::string& control_arg) +{ + history_control = 0; + + size_t len = control_arg.length (); + size_t beg = 0; + + while (beg < len) + { + if (control_arg[beg] == ':') + beg++; + else + { + size_t end = control_arg.find (":", beg); + + if (end == std::string::npos) + end = len; + + std::string tmp = control_arg.substr (beg, end-beg); + + if (tmp == "erasedups") + history_control |= HC_ERASEDUPS; + else if (tmp == "ignoreboth") + history_control |= HC_IGNDUPS|HC_IGNSPACE; + else if (tmp == "ignoredups") + history_control |= HC_IGNDUPS; + else if (tmp == "ignorespace") + history_control |= HC_IGNSPACE; + else + (*current_liboctave_warning_handler) + ("unknown histcontrol directive %s", tmp.c_str ()); + + if (end != std::string::npos) + beg = end + 1; + } + } +} + +std::string +gnu_history::do_histcontrol (void) const +{ + // FIXME -- instead of reconstructing this value, should we just save + // the string we were given when constructing the command_history + // object? + + std::string retval; + + if (history_control & HC_IGNSPACE) + retval.append ("ignorespace"); + + if (history_control & HC_IGNDUPS) + { + if (retval.length() > 0) + retval.append (":"); + + retval.append ("ignoredups"); + } + + if (history_control & HC_ERASEDUPS) + { + if (retval.length() > 0) + retval.append (":"); + + retval.append ("erasedups"); + } + + return retval; +} + +void gnu_history::do_add (const std::string& s) { if (! do_ignoring_entries ()) @@ -654,6 +728,13 @@ } void +command_history::do_process_histcontrol (const std::string&) +{ + (*current_liboctave_warning_handler) + ("readline is not linked, so history control is not available"); +} + +void command_history::do_initialize (bool read_history_file, const std::string& f_arg, int sz, const std::string & control_arg) @@ -680,77 +761,6 @@ xfile = f; } -void -command_history::do_process_histcontrol (const std::string& control_arg) -{ - history_control = 0; - - size_t len = control_arg.length (); - size_t beg = 0; - - while (beg < len) - { - if (control_arg[beg] == ':') - beg++; - else - { - size_t end = control_arg.find (":", beg); - - if (end == std::string::npos) - end = len; - - std::string tmp = control_arg.substr (beg, end-beg); - - if (tmp == "erasedups") - history_control |= HC_ERASEDUPS; - else if (tmp == "ignoreboth") - history_control |= HC_IGNDUPS|HC_IGNSPACE; - else if (tmp == "ignoredups") - history_control |= HC_IGNDUPS; - else if (tmp == "ignorespace") - history_control |= HC_IGNSPACE; - else - (*current_liboctave_warning_handler) - ("unknown histcontrol directive %s", tmp.c_str ()); - - if (end != std::string::npos) - beg = end + 1; - } - } -} - -std::string -command_history::do_histcontrol (void) const -{ - // FIXME -- instead of reconstructing this value, should we just save - // the string we were given when constructing the command_history - // object? - - std::string retval; - - if (history_control & HC_IGNSPACE) - retval.append ("ignorespace"); - - if (history_control & HC_IGNDUPS) - { - if (retval.length() > 0) - retval.append (":"); - - retval.append ("ignoredups"); - } - - if (history_control & HC_ERASEDUPS) - { - if (retval.length() > 0) - retval.append (":"); - - retval.append ("erasedups"); - } - - return retval; -} - - std::string command_history::do_file (void) { diff -r 044ca61e6750 -r 3dd1b0b36f13 liboctave/cmd-hist.h --- a/liboctave/cmd-hist.h Wed Feb 02 21:31:33 2011 -0800 +++ b/liboctave/cmd-hist.h Thu Feb 03 01:04:41 2011 -0500 @@ -138,7 +138,7 @@ virtual void do_process_histcontrol (const std::string&); - virtual std::string do_histcontrol (void) const; + virtual std::string do_histcontrol (void) const { return std::string (); } virtual void do_initialize (bool, const std::string&, int, const std::string&);