# HG changeset patch # User jwe # Date 1183059762 0 # Node ID a6c8000f113ec4cc84f7eb1ffe17b12c367b953f # Parent 6373d320a9572ab47c95c67ac3e2f97f3ec3ce5c [project @ 2007-06-28 19:42:42 by jwe] diff -r 6373d320a957 -r a6c8000f113e src/ChangeLog --- a/src/ChangeLog Thu Jun 28 15:40:21 2007 +0000 +++ b/src/ChangeLog Thu Jun 28 19:42:42 2007 +0000 @@ -1,5 +1,11 @@ 2007-06-28 John W. Eaton + * ov-cell.cc (octave_cell::subsasgn): Given x = {}, convert to + struct for assignments like x(1).f = val; + + * oct-stream.cc (octave_scan_1): New function + (octave_scan): Use it. Handle fmt.width. + * graphics.h (axes::axes_properties::visible): New data member. * graphics.cc (axes::axes_properties::axes_properties, axes::axes_properties::set, axes::axes_properties::get, diff -r 6373d320a957 -r a6c8000f113e src/oct-stream.cc --- a/src/oct-stream.cc Thu Jun 28 15:40:21 2007 +0000 +++ b/src/oct-stream.cc Thu Jun 28 19:42:42 2007 +0000 @@ -1047,12 +1047,9 @@ #define OCTAVE_SCAN(is, fmt, arg) octave_scan (is, fmt, arg) -// FIXME -- this needs to be fixed to handle formats which -// specify a maximum width. - template std::istream& -octave_scan (std::istream& is, const scanf_format_elt& fmt, T* valptr) +octave_scan_1 (std::istream& is, const scanf_format_elt& fmt, T* valptr) { T& ref = *valptr; @@ -1108,6 +1105,30 @@ return is; } +template +std::istream& +octave_scan (std::istream& is, const scanf_format_elt& fmt, T* valptr) +{ + if (fmt.width) + { + // Limit input to fmt.width characters by reading into a + // temporary stringstream buffer. + + std::string tmp; + + is.width (fmt.width); + is >> tmp; + + std::istringstream ss (tmp); + + octave_scan_1 (ss, fmt, valptr); + } + else + octave_scan_1 (is, fmt, valptr); + + return is; +} + // Note that this specialization is only used for reading characters, not // character strings. See BEGIN_S_CONVERSION for details. diff -r 6373d320a957 -r a6c8000f113e src/ov-cell.cc --- a/src/ov-cell.cc Thu Jun 28 15:40:21 2007 +0000 +++ b/src/ov-cell.cc Thu Jun 28 19:42:42 2007 +0000 @@ -137,20 +137,34 @@ { case '(': { - octave_value tmp = do_index_op (idx.front (), true); + if (is_empty () && type[1] == '.') + { + // Allow conversion of empty cell array to some other + // type in cases like + // + // x = []; x(i).f = rhs - if (! tmp.is_defined ()) - tmp = octave_value::empty_conv (type.substr (1), rhs); + octave_value tmp = octave_value::empty_conv (type, rhs); - if (! error_state) + return tmp.subsasgn (type, idx, rhs); + } + else { - std::list next_idx (idx); + octave_value tmp = do_index_op (idx.front (), true); - next_idx.erase (next_idx.begin ()); + if (! tmp.is_defined ()) + tmp = octave_value::empty_conv (type.substr (1), rhs); - tmp.make_unique (); + if (! error_state) + { + std::list next_idx (idx); - t_rhs = tmp.subsasgn (type.substr (1), next_idx, rhs); + next_idx.erase (next_idx.begin ()); + + tmp.make_unique (); + + t_rhs = tmp.subsasgn (type.substr (1), next_idx, rhs); + } } } break;