diff src/oct-stream.cc @ 8773:9e3111d203c0

disallow reading from stdin while running interactively
author John W. Eaton <jwe@octave.org>
date Tue, 17 Feb 2009 01:33:10 -0500
parents d477e57e811c
children 5d5db7a347c6
line wrap: on
line diff
--- a/src/oct-stream.cc	Tue Feb 17 00:43:13 2009 -0500
+++ b/src/oct-stream.cc	Tue Feb 17 01:33:10 2009 -0500
@@ -964,6 +964,14 @@
 {
   std::string retval;
 
+  if ((interactive || forced_interactive) && file_number () == 0)
+    {
+      ::error ("%s: unable to read from stdin while running interactively",
+	       who.c_str ());
+	     
+      return retval;
+    }
+
   err = false;
 
   std::istream *isp = input_stream ();
@@ -1651,14 +1659,22 @@
 			      octave_idx_type nr, octave_idx_type nc, bool one_elt_size_spec,
 			      octave_idx_type& conversion_count, const std::string& who)
 {
+  octave_value retval = Matrix ();
+
+  if ((interactive || forced_interactive) && file_number () == 0)
+    {
+      ::error ("%s: unable to read from stdin while running interactively",
+	       who.c_str ());
+	     
+      return retval;
+    }
+
   conversion_count = 0;
 
   int nconv = fmt_list.num_conversions ();
 
   octave_idx_type data_index = 0;
 
-  octave_value retval = Matrix ();
-
   if (nr == 0 || nc == 0)
     {
       if (one_elt_size_spec)