Diff of /src/sclose.cc [05cccf] .. [0c456c]  Maximize  Restore

  Switch to side-by-side view

--- a/src/sclose.cc
+++ b/src/sclose.cc
@@ -18,6 +18,7 @@
 */
 
 #include <octave/oct.h>
+#include <oct-stream.h>
 
 #include "defun-dld.h"
 #include "dirfns.h"
@@ -53,9 +54,10 @@
 
   if(args.length () == 1)
     {
-      int i,nsock=0,sock,k,err=0,nl;
+      int i,nsock=0,sock,k,err=0,nl, rows;
 
-      nsock=args(0).matrix_value().rows()*2;
+      rows = args(0).matrix_value().rows();
+      nsock = rows * 2;
       
       if((int)args(0).matrix_value().data()[0]==0){
 	int num,pid;
@@ -99,10 +101,17 @@
 	}
       }
 
-      for(i=nsock-1;i>=0;i--){
+      for(i=nsock-1;i>=rows;i--){
 	sock=(int)args(0).matrix_value().data()[i];
 	if(sock!=0){
 	  if(close(sock)!=0)
+	    err++;
+	}
+      }
+      for(i=rows-1;i>=0;i--){
+	sock=(int)args(0).matrix_value().data()[i];
+	if(sock!=0){
+	  if(octave_stream_list::remove (octave_value (sock), "") != 0)
 	    err++;
 	}
       }

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks