Mercurial > hg > octave-shane
changeset 12366:3dd1b0b36f13 release-3-4-x
require readline to provide working history control
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 03 Feb 2011 01:04:41 -0500 |
parents | 044ca61e6750 |
children | 4f4eb7da82d5 |
files | liboctave/ChangeLog liboctave/cmd-hist.cc liboctave/cmd-hist.h |
diffstat | 3 files changed, 92 insertions(+), 72 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,13 @@ +2011-02-03 John W. Eaton <jwe@octave.org> + + * 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 <jwe@octave.org> * Range.cc (Range::Range (double, double, octave_idx_type)):
--- a/liboctave/cmd-hist.cc +++ b/liboctave/cmd-hist.cc @@ -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) {
--- a/liboctave/cmd-hist.h +++ b/liboctave/cmd-hist.h @@ -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&);