# HG changeset patch # User Andreas Weber # Date 1412501789 -7200 # Node ID 4b6f87c6739fd2465ce7c7805aa09e9764213f19 # Parent e85203f414029260ecddba3e7546abe602e98c8f Fix out_of_range from substr in short_disp for GUI symtab (bug #43351) * ov-base-mat.cc, ov-base-scalar.cc::short_disp: Return single space if the printed string consists only of spaces. diff -r e85203f41402 -r 4b6f87c6739f libinterp/octave-value/ov-base-mat.cc --- a/libinterp/octave-value/ov-base-mat.cc Sun Sep 28 17:30:38 2014 +0200 +++ b/libinterp/octave-value/ov-base-mat.cc Sun Oct 05 11:36:29 2014 +0200 @@ -476,7 +476,10 @@ octave_print_internal (buf, matrix(j*nr+i)); std::string tmp = buf.str (); size_t pos = tmp.find_first_not_of (" "); - os << tmp.substr (pos); + if (pos != std::string::npos) + os << tmp.substr (pos); + else if (! tmp.empty ()) + os << tmp[0]; if (++elts >= max_elts) goto done; diff -r e85203f41402 -r 4b6f87c6739f libinterp/octave-value/ov-base-scalar.cc --- a/libinterp/octave-value/ov-base-scalar.cc Sun Sep 28 17:30:38 2014 +0200 +++ b/libinterp/octave-value/ov-base-scalar.cc Sun Oct 05 11:36:29 2014 +0200 @@ -176,7 +176,10 @@ octave_print_internal (buf, scalar); std::string tmp = buf.str (); size_t pos = tmp.find_first_not_of (" "); - os << tmp.substr (pos); + if (pos != std::string::npos) + os << tmp.substr (pos); + else if (! tmp.empty ()) + os << tmp[0]; } template