# HG changeset patch # User Rik # Date 1360367205 28800 # Node ID 26cba49d764169c40551d49ba242343cbba975d5 # Parent 1e35b64ac31ade05453c03bacb9df73ab05b387e Prevent extra newline in history list when --no-line-editing option used. * liboctave/util/cmd-hist.cc(gnu_history::do_add): Strip newline before adding line to history list. diff -r 1e35b64ac31a -r 26cba49d7641 liboctave/util/cmd-hist.cc --- a/liboctave/util/cmd-hist.cc Fri Feb 08 18:27:35 2013 -0500 +++ b/liboctave/util/cmd-hist.cc Fri Feb 08 15:46:45 2013 -0800 @@ -192,8 +192,14 @@ if (s.empty () || (s.length () == 1 && (s[0] == '\r' || s[0] == '\n'))) return; + + // Strip newline before adding to list + std::string stmp = s; + int stmp_len = stmp.length (); + if (stmp[stmp_len - 1] == '\n') + stmp.resize (stmp_len - 1); - lines_this_session += ::octave_add_history (s.c_str (), history_control); + lines_this_session += ::octave_add_history (stmp.c_str (), history_control); } }