Mercurial > hg > octave-nkf
changeset 3342:d8d3700fb4ab
[project @ 1999-11-05 16:55:17 by jwe]
author | jwe |
---|---|
date | Fri, 05 Nov 1999 16:55:18 +0000 |
parents | 14cfc9475fe4 |
children | 466d7a1cac01 |
files | src/ChangeLog src/file-io.cc src/oct-iostrm.cc src/oct-iostrm.h src/oct-stream.cc |
diffstat | 5 files changed, 43 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,14 @@ 1999-11-05 John W. Eaton <jwe@bevo.che.wisc.edu> + * oct-iostrm.h (octave_istream::eof, octave_ostream::eof): Provide + implementation for these. + + * oct-stream.cc (octave_base_stream::do_scanf): + The stdin stream is only special if we are interactive. + (octave_base_stream::scanf): Ditto. + (octave_base_stream::do_oscanf): Ditto. + (octave_base_stream::oscanf): Ditto. + * ov.h (octave_value::is_stream): New predicate. * ov-file.h (octave_file::is_stream): Return true. * file-io.cc (Fis_stream): New function.
--- a/src/file-io.cc +++ b/src/file-io.cc @@ -689,7 +689,7 @@ { octave_stream os = octave_stream_list::lookup (args(0), "fscanf"); - if (error_state) + if (! error_state) { if (args(1).is_string ()) {
--- a/src/oct-iostrm.cc +++ b/src/oct-iostrm.cc @@ -60,12 +60,28 @@ ::error ("%s: invalid operation", stream_type ()); } +// Return non-zero if EOF has been reached on this stream. + +bool +octave_istream::eof (void) const +{ + return is && is->eof (); +} + octave_stream octave_istream::create (istream *arg, const string& nm) { return octave_stream (new octave_istream (arg, nm)); } +// Return non-zero if EOF has been reached on this stream. + +bool +octave_ostream::eof (void) const +{ + return os && os->eof (); +} + octave_stream octave_ostream::create (ostream *arg, const string& nm) {
--- a/src/oct-iostrm.h +++ b/src/oct-iostrm.h @@ -88,6 +88,10 @@ static octave_stream create (istream *arg = 0, const string& nm = string ()); + // Return non-zero if EOF has been reached on this stream. + + bool eof (void) const; + istream *input_stream (void) { return is; } ostream *output_stream (void) { return 0; } @@ -121,6 +125,10 @@ static octave_stream create (ostream *arg, const string& nm = string ()); + // Return non-zero if EOF has been reached on this stream. + + bool eof (void) const; + istream *input_stream (void) { return 0; } ostream *output_stream (void) { return os; }
--- a/src/oct-stream.cc +++ b/src/oct-stream.cc @@ -36,6 +36,7 @@ #include "str-vec.h" #include "error.h" +#include "input.h" #include "oct-stream.h" #include "oct-obj.h" #include "utils.h" @@ -1271,8 +1272,8 @@ is.clear (is.rdstate () & (~ios::failbit)); // XXX FIXME XXX -- is this the right thing to do? - // What about other streams? - if (name () == "stdin") + + if (interactive && name () == "stdin") { is.clear (); @@ -1351,8 +1352,8 @@ error ("fscanf: read error"); // XXX FIXME XXX -- is this the right thing to do? - // What about other streams? - if (name () == "stdin") + + if (interactive && name () == "stdin") { is.clear (); @@ -1534,8 +1535,8 @@ error ("fscanf: read error"); // XXX FIXME XXX -- is this the right thing to do? - // What about other streams? - if (name () == "stdin") + + if (interactive && name () == "stdin") { is.clear (); @@ -1586,12 +1587,8 @@ error ("fscanf: read error"); // XXX FIXME XXX -- is this the right thing to do? - // Maybe. We should probably also arrange to - // flush the pending input prior to printing a - // prompt. Or maybe just blow off scanf for stdin - // like the MathWorks did. What about other streams? - - if (name () == "stdin") + + if (interactive && name () == "stdin") { is.clear ();