diff libinterp/corefcn/oct-stream.cc @ 22089:c2c668b3051b

use classes for octave application and interpreter * main-cli.cc (main): Simplify using class objects. * main-gui.cc (main): Likeiwse. * octave.h, octave.cc (octave::cmdline_options, octave::application, octave::cli_application, octave::embedded_application, octave::interpreter): New classes. Replace ordinary functions and static/global data with objects. Access global application data through application object. * octave-gui.h, octave-gui.cc (octave::gui_application): New class. Replace ordinary functions and static/global data with objects. * main-window.cc (main_window::m_app_context): New data member. (main_window::main_window): Pass application object instead of start_gui flag. (main_window::construct_octave_qt_link): Pass m_app_context to octave_qt_link constructor. * octave-interpreter.h, octave-interpreter.cc (octave_interpreter::m_app_context, octave_interpreter::m_exit_status): New data members. (octave_interpreter::execute): Use class object to start interpreter. Save exit status. * octave-qt-link.h, octave-qt-link.cc (octave_qt_link::m_app_context): New data member. (octave_qt_link::do_set_default_prompts): Make prompt settings conditional on whether the GUI is running. * input.h, input.cc (interactive, forced_interactive): Delete global data. * dirfns.cc, error.cc, input.cc, oct-stream.cc, pager.cc, sighandlers.cc, sysdep.cc, toplev.cc, lex.ll: Access interactive and forced_interactive through global application object.
author John W. Eaton <jwe@octave.org>
date Sun, 10 Jul 2016 07:15:21 -0400
parents 278fc29b69ca
children 9203833cab7d
line wrap: on
line diff
--- a/libinterp/corefcn/oct-stream.cc	Mon Jul 11 13:45:12 2016 -0400
+++ b/libinterp/corefcn/oct-stream.cc	Sun Jul 10 07:15:21 2016 -0400
@@ -50,6 +50,7 @@
 #include "error.h"
 #include "errwarn.h"
 #include "input.h"
+#include "octave.h"
 #include "oct-stdstrm.h"
 #include "oct-stream.h"
 #include "ov.h"
@@ -3989,7 +3990,7 @@
 octave_base_stream::do_gets (octave_idx_type max_len, bool& err,
                              bool strip_newline, const std::string& who)
 {
-  if (interactive && file_number () == 0)
+  if (octave::application::interactive () && file_number () == 0)
     ::error ("%s: unable to read from stdin while running interactively",
              who.c_str ());
 
@@ -4100,7 +4101,7 @@
 off_t
 octave_base_stream::skipl (off_t num, bool& err, const std::string& who)
 {
-  if (interactive && file_number () == 0)
+  if (octave::application::interactive () && file_number () == 0)
     ::error ("%s: unable to read from stdin while running interactively",
              who.c_str ());
 
@@ -4568,7 +4569,7 @@
                               octave_idx_type& conversion_count,
                               const std::string& who)
 {
-  if (interactive && file_number () == 0)
+  if (octave::application::interactive () && file_number () == 0)
     ::error ("%s: unable to read from stdin while running interactively",
              who.c_str ());
 
@@ -4896,7 +4897,9 @@
                     is.clear (is.rdstate () & (~std::ios::failbit));
 
                   // FIXME: is this the right thing to do?
-                  if (interactive && ! forced_interactive && name () == "stdin")
+                  if (octave::application::interactive ()
+                      && ! octave::application::forced_interactive ()
+                      && name () == "stdin")
                     {
                       is.clear ();
 
@@ -5126,7 +5129,9 @@
 
       // FIXME: is this the right thing to do?
 
-      if (interactive && ! forced_interactive && name () == "stdin")
+      if (octave::application::interactive ()
+          && ! octave::application::forced_interactive ()
+          && name () == "stdin")
         {
           // Skip to end of line.
           bool err;
@@ -5218,7 +5223,7 @@
                                  const std::string& who,
                                  octave_idx_type& read_count)
 {
-  if (interactive && file_number () == 0)
+  if (octave::application::interactive () && file_number () == 0)
     ::error ("%s: unable to read from stdin while running interactively",
              who.c_str ());