Mercurial > hg > octave-lojdl
diff src/oct-stream.cc @ 3145:0d640dc625c7
[project @ 1998-02-05 08:44:59 by jwe]
author | jwe |
---|---|
date | Thu, 05 Feb 1998 08:45:07 +0000 (1998-02-05) |
parents | 66a1cede95e7 |
children | 8cdcb8945695 |
line wrap: on
line diff
--- a/src/oct-stream.cc +++ b/src/oct-stream.cc @@ -720,6 +720,41 @@ } } +int +octave_base_stream::fileno (void) +{ + // Kluge alert! + + if (name () == "stdin") + return 0; + + if (name () == "stdout") + return 1; + + if (name () == "stderr") + return 2; + + int retval = -1; + + istream *is = input_stream (); + ostream *os = output_stream (); + + int i_fid = is ? ((filebuf *) (is->rdbuf ()))->fd () : -1; + int o_fid = os ? ((filebuf *) (os->rdbuf ()))->fd () : -1; + + if (i_fid >= 0) + { + if (o_fid >= 0) + retval = (i_fid == o_fid) ? i_fid : -1; + else + retval = i_fid; + } + else if (o_fid >= 0) + retval = o_fid; + + return retval; +} + void octave_base_stream::error (const string& msg) { @@ -1541,11 +1576,7 @@ // Get the current value as a string and advance the internal pointer. string string_value (void); - operator void* () const - { - return (curr_state == ok) - ? static_cast<void *> (-1) : static_cast<void *> (0); - } + operator bool () const { return (curr_state == ok); } bool no_more_values (void) { return curr_state == list_exhausted; }