Mercurial > hg > octave-lyh
changeset 5649:d24b97246b9b
[project @ 2006-03-08 20:31:25 by jwe]
author | jwe |
---|---|
date | Wed, 08 Mar 2006 20:31:26 +0000 |
parents | 69a4f320d95a |
children | c27fea6f72ae |
files | src/ChangeLog src/oct-stream.cc src/oct-stream.h |
diffstat | 3 files changed, 34 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2006-03-08 John W. Eaton <jwe@octave.org> + + * oct-stream.cc (octave_stream::stream_ok): Move definition here, + from oct-stream.h. New arg, warn. If warn is true and stream is + invalid, print warning. + (octave_stream::error): Always avoid warning message from + stream_ok. Return "invalid stream object" if stream is not ok. + 2006-03-08 David Bateman <dbateman@free.fr> * ov-mapper.cc (SPARSE_MAPPER_LOOP_2): Change nnz to nz to remove
--- a/src/oct-stream.cc +++ b/src/oct-stream.cc @@ -3754,9 +3754,9 @@ std::string octave_stream::error (bool clear, int& err_num) { - std::string retval; - - if (stream_ok ("ferror", false)) + std::string retval = "invalid stream object"; + + if (stream_ok ("ferror", false, false)) retval = rep->error (clear, err_num); return retval; @@ -3833,6 +3833,27 @@ return retval; } +bool +octave_stream::stream_ok (const std::string& who, bool clear, bool warn) const +{ + bool retval = true; + + if (rep) + { + if (clear) + rep->clear (); + } + else + { + if (warn) + ::warning ("%s: attempt to use invalid I/O stream", who.c_str ()); + + retval = false; + } + + return retval; +} + octave_stream_list *octave_stream_list::instance = 0; bool
--- a/src/oct-stream.h +++ b/src/oct-stream.h @@ -591,20 +591,8 @@ // The actual representation of this stream. octave_base_stream *rep; - bool stream_ok (const std::string& who, bool clear = true) const - { - bool retval = true; - - if (rep) - { - if (clear) - rep->clear (); - } - else - retval = false; - - return retval; - } + bool stream_ok (const std::string& who, bool clear = true, + bool warn = true) const; void invalid_operation (const std::string& who, const char *rw) {