# HG changeset patch # User jwe # Date 1147295737 0 # Node ID 5bfb24f90bdd767fd210de1328fdc90b84026625 # Parent 296cefb48d7ed9c6d357c34a718887e5c106dd97 [project @ 2006-05-10 21:15:37 by jwe] diff --git a/src/Cell.cc b/src/Cell.cc --- 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_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; + } } } diff --git a/src/Cell.h b/src/Cell.h --- a/src/Cell.h +++ b/src/Cell.h @@ -65,7 +65,7 @@ Cell (const Array& c, octave_idx_type nr, octave_idx_type nc) : ArrayN (c, dim_vector (nr, nc)) { } - Cell (const string_vector& sv); + Cell (const string_vector& sv, bool trim = false); Cell (const Cell& c) : ArrayN (c) { } diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,8 @@ 2006-05-10 John W. Eaton + * 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. diff --git a/src/ov-cell.cc b/src/ov-cell.cc --- a/src/ov-cell.cc +++ b/src/ov-cell.cc @@ -1058,7 +1058,7 @@ string_vector s = args(0).all_strings (); if (! error_state) - retval = Cell (s); + retval = Cell (s, true); else error ("cellstr: expecting argument to be a 2-d character array"); }