Mercurial > hg > octave-nkf
changeset 5805:5bfb24f90bdd
[project @ 2006-05-10 21:15:37 by jwe]
author | jwe |
---|---|
date | Wed, 10 May 2006 21:15:37 +0000 |
parents | 296cefb48d7e |
children | b2a802aa0cda |
files | src/Cell.cc src/Cell.h src/ChangeLog src/ov-cell.cc |
diffstat | 4 files changed, 18 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/Cell.cc +++ b/src/Cell.cc @@ -31,7 +31,7 @@ #include "error.h" #include "gripes.h" -Cell::Cell (const string_vector& sv) +Cell::Cell (const string_vector& sv, bool trim) : ArrayN<octave_value> () { octave_idx_type n = sv.length (); @@ -41,7 +41,18 @@ resize (dim_vector (n, 1)); for (octave_idx_type i = 0; i < n; i++) - elem(i,0) = sv[i]; + { + std::string s = sv[i]; + + if (trim) + { + size_t n = s.find_last_not_of (' '); + + s = (n == NPOS) ? "" : s.substr (0, n+1); + } + + elem(i,0) = s; + } } }
--- a/src/Cell.h +++ b/src/Cell.h @@ -65,7 +65,7 @@ Cell (const Array<octave_value>& c, octave_idx_type nr, octave_idx_type nc) : ArrayN<octave_value> (c, dim_vector (nr, nc)) { } - Cell (const string_vector& sv); + Cell (const string_vector& sv, bool trim = false); Cell (const Cell& c) : ArrayN<octave_value> (c) { }
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,8 @@ 2006-05-10 John W. Eaton <jwe@octave.org> + * ov-cell.cc (Fcellstr): Trim trailing blanks. + * Cell.h (Cell::Cell (const string_vector&)): New arg, TRIM. + * oct-hist.cc (initialize_history, Fhistory_size): Also call command_history::set_size here.