# HG changeset patch # User Jaroslav Hajek # Date 1261862463 -3600 # Node ID c461d69e4abeef555aa9844f61e91a9e485a2653 # Parent 8db5553c24f54ec321a44044b8ed32ca8b250b1f implement stdout_nobuf diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -0,0 +1,8 @@ +2009-12-26 Jaroslav Hajek + + * file-io.cc (stdout_nobuf_stream, stdout_nobuf_file): New static + vars. + (initialize_file_io): Define them here. + (Fstdout_nobuf): New defun. + * oct-stream.cc (octave_base_stream::file_number): Handle it here. + diff --git a/src/file-io.cc b/src/file-io.cc --- a/src/file-io.cc +++ b/src/file-io.cc @@ -83,10 +83,12 @@ static octave_value stdin_file; static octave_value stdout_file; static octave_value stderr_file; +static octave_value stdout_nobuf_file; static octave_stream stdin_stream; static octave_stream stdout_stream; static octave_stream stderr_stream; +static octave_stream stdout_nobuf_stream; void initialize_file_io (void) @@ -100,9 +102,12 @@ stderr_stream = octave_ostream::create (&std::cerr, "stderr"); + stdout_nobuf_stream = octave_ostream::create (&std::cout, "stdout_nobuf"); + stdin_file = octave_stream_list::insert (stdin_stream); stdout_file = octave_stream_list::insert (stdout_stream); stderr_file = octave_stream_list::insert (stderr_stream); + stdout_nobuf_file = octave_stream_list::insert (stdout_nobuf_stream); } void @@ -2281,6 +2286,19 @@ return const_value ("stderr", args, stderr_file); } +DEFUN (stdout_nobuf, args, , + "-*- texinfo -*-\n\ address@hidden {Built-in Function} {} stdout_nobuf ()\n\ +Return the numeric value corresponding to the standard output stream.\n\ +Unlike stdout, however, this stream goes directly to standard output regardless\n\ +of any pager settings.\n\ address@hidden, stdout, stderr}\n\ address@hidden deftypefn") +{ + return const_value ("stdout_nobuf", args, stdout_nobuf_file); +} + + /* ;;; Local Variables: *** ;;; mode: C++ *** diff --git a/src/oct-stream.cc b/src/oct-stream.cc --- a/src/oct-stream.cc +++ b/src/oct-stream.cc @@ -887,6 +887,9 @@ if (name () == "stderr") return 2; + if (name () == "stdout_nobuf") + return 3; + int retval = -1; std::istream *is = input_stream (); @@ -915,6 +918,9 @@ else if (o_fid >= 0) retval = o_fid; + if (retval > 0) + retval += 1; + return retval; }