# HG changeset patch # User jwe # Date 846627039 0 # Node ID a628e881be66044d187a7206fb1ae249e44eb55e # Parent 3be97fe02051f7c622bca0faddac416174a0eead [project @ 1996-10-29 22:08:28 by jwe] diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,16 @@ +Tue Oct 29 15:54:27 1996 John W. Eaton + + * ov-range.cc (octave_range::index): New Function. + (octave_range::all, octave_range::any, octave_range::is_true): + Make these functions work. + + * ov.cc (octave_value::try_assignment_with_conversion): Remove + left over debugging print statements. + +Mon Oct 28 10:49:03 1996 John W. Eaton + + * strftime.c: Add missing #endif for previous change. + Sun Oct 27 14:06:44 1996 John W. Eaton * oct-hist.cc (do_history): Rewite option parsing to avoid diff --git a/src/load-save.cc b/src/load-save.cc --- a/src/load-save.cc +++ b/src/load-save.cc @@ -1149,11 +1149,13 @@ } // LEN includes the terminating character, and the file is also - // supposed to include it. + // supposed to include it, but apparently not all files do. Either + // way, I think this should work. - name = new char [len]; + name = new char [len+1]; if (! is.read (name, len)) goto data_read_error; + name[len] = '\0'; dlen = nr * nc; if (dlen < 0) diff --git a/src/ov-range.cc b/src/ov-range.cc --- a/src/ov-range.cc +++ b/src/ov-range.cc @@ -78,6 +78,24 @@ return retval; } +octave_value +octave_range::index (const octave_value_list& idx) const +{ + // XXX FIXME XXX -- this doesn't solve the problem of + // + // a = 1:5; a(1, 1, 1) + // + // and similar constructions. Hmm... + + // XXX FIXME XXX -- using this constructor avoids possibly narrowing + // the range to a scalar value. Need a better solution to this + // problem. + + octave_value tmp (new octave_matrix (range.matrix_value ())); + + return tmp.index (idx); +} + double octave_range::double_value (bool) const { @@ -96,24 +114,42 @@ octave_value octave_range::all (void) const { - octave_value retval; - error ("octave_range::all(): not implemented"); - return retval; + // XXX FIXME XXX -- this is a potential waste of memory. + + Matrix m = range.matrix_value (); + + return m.all (); } octave_value octave_range::any (void) const { - octave_value retval; - error ("octave_range::any(): not implemented"); - return retval; + return (double) (range.base () != 0.0 || range.nelem () > 1); } bool octave_range::is_true (void) const { bool retval = false; - error ("octave_range::is_true(): not implemented"); + + if (range.nelem () == 0) + { + int flag = Vpropagate_empty_matrices; + + if (flag < 0) + warning ("empty range used in conditional expression"); + else if (flag == 0) + error ("empty range used in conditional expression"); + } + else + { + // XXX FIXME XXX -- this is a potential waste of memory. + + Matrix m ((range.matrix_value () . all ()) . all ()); + + retval = (m.rows () == 1 && m.columns () == 1 && m (0, 0) != 0.0); + } + return retval; } diff --git a/src/ov-range.h b/src/ov-range.h --- a/src/ov-range.h +++ b/src/ov-range.h @@ -89,6 +89,8 @@ octave_value *try_narrowing_conversion (void); + octave_value index (const octave_value_list& idx) const; + idx_vector index_vector (void) const { return idx_vector (range); } int rows (void) const { return (columns () > 0); } diff --git a/src/ov.cc b/src/ov.cc --- a/src/ov.cc +++ b/src/ov.cc @@ -634,9 +634,6 @@ rep->count = 1; } - cerr << type_name () << "\n"; - cerr << tmp_rhs.type_name () << "\n"; - if (cf_this || cf_rhs) { assignment_ok = try_assignment (idx, tmp_rhs); diff --git a/src/strftime.c b/src/strftime.c --- a/src/strftime.c +++ b/src/strftime.c @@ -90,6 +90,7 @@ #else #include #endif +#endif #ifndef STDC_HEADERS time_t mktime ();