Mercurial > hg > octave-nkf
diff liboctave/util/cmd-hist.cc @ 16021:26cba49d7641
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.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 08 Feb 2013 15:46:45 -0800 |
parents | 231d8d3b8225 |
children | 3d1205d5771e |
line wrap: on
line diff
--- a/liboctave/util/cmd-hist.cc +++ b/liboctave/util/cmd-hist.cc @@ -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); } }