diff src/graphics.cc @ 7680:a0ec02774303

Use popen2 for communication with gnuplot
author David Bateman <dbateman@free.fr>
date Wed, 02 Apr 2008 13:29:19 -0400
parents d219e712c20e
children cb4838d70ab2
line wrap: on
line diff
--- a/src/graphics.cc	Tue Apr 01 16:35:48 2008 -0400
+++ b/src/graphics.cc	Wed Apr 02 13:29:19 2008 -0400
@@ -1291,12 +1291,22 @@
       if (! pstream.is_empty())
 	{
 	  octave_value_list args;
-	  args(1) = "\nquit;\n";
-	  args(0) = pstream;
-	  feval ("fputs", args);
-	  args.resize (1);
-	  feval ("fflush", args);
-	  feval ("pclose", args);
+	  Matrix fids = pstream.matrix_value ();
+
+	  if (! error_state)
+	    {
+	      args(1) = "\nquit;\n";
+	      args(0) = octave_value (fids (0));
+	      feval ("fputs", args);
+	      args.resize (1);
+	      feval ("fflush", args);
+	      feval ("pclose", args);
+	      if (fids.numel () > 1)
+		{
+		  args(0) = octave_value (fids (1));
+		  feval ("pclose", args);
+		}
+	    }
 	}
     }