changeset 1965:01e3ed56c415

[project @ 1996-02-17 02:02:50 by jwe]
author jwe
date Sat, 17 Feb 1996 02:03:11 +0000
parents 2ff7b73519db
children 4b8e9571bbdf
files src/dirfns.cc src/pager.cc src/procstream.cc src/procstream.h src/toplev.cc
diffstat 5 files changed, 110 insertions(+), 120 deletions(-) [+]
line wrap: on
line diff
--- a/src/dirfns.cc	Sat Feb 17 00:11:53 1996 +0000
+++ b/src/dirfns.cc	Sat Feb 17 02:03:11 1996 +0000
@@ -318,7 +318,7 @@
 
   int argc = args.length () + 1;
 
-  string_vector argv = make_argv (args, "cd");
+  string_vector argv = args.make_argv ("cd");
 
   if (error_state)
     return retval;
@@ -353,6 +353,12 @@
 
 // Get a directory listing.
 
+static void
+cleanup_iprocstream (void *p)
+{
+  delete (iprocstream *) p;
+}
+
 DEFUN_TEXT (ls, args, ,
   "ls [options]\n\
 \n\
@@ -362,7 +368,7 @@
 
   int argc = args.length () + 1;
 
-  string_vector argv = make_argv (args, "ls");
+  string_vector argv = args.make_argv ("ls");
 
   if (error_state)
     return retval;
--- a/src/pager.cc	Sat Feb 17 00:11:53 1996 +0000
+++ b/src/pager.cc	Sat Feb 17 02:03:11 1996 +0000
@@ -112,6 +112,12 @@
     }
 }
 
+static void
+cleanup_oprocstream (void *p)
+{
+  delete (oprocstream *) p;
+}
+
 void
 flush_output_to_pager (void)
 {
@@ -203,7 +209,7 @@
 
   int argc = args.length () + 1;
 
-  string_vector argv = make_argv (args, "diary");
+  string_vector argv = args.make_argv ("diary");
 
   if (error_state)
     return retval;
@@ -255,7 +261,7 @@
 
   int argc = args.length () + 1;
 
-  string_vector argv = make_argv (args, "more");
+  string_vector argv = args.make_argv ("more");
 
   if (error_state)
     return retval;
--- a/src/procstream.cc	Sat Feb 17 00:11:53 1996 +0000
+++ b/src/procstream.cc	Sat Feb 17 02:03:11 1996 +0000
@@ -29,127 +29,41 @@
 #include <config.h>
 #endif
 
-#include <fstream.h>
-#include <procbuf.h>
-
 #include "procstream.h"
 
-iprocstream::iprocstream (const char *command, int mode)
+procstreambase::procstreambase (const char *command, int mode)
 {
-  pbuf = new procbuf ();
+  pb_init ();
 
-  init (pbuf);
-
-  if (! pbuf->open (command, mode))
+  if (! pb.open (command, mode))
     set (ios::badbit);
 }
 
-iprocstream::~iprocstream (void)
-{
-  delete pbuf;
-}
-
 void
-iprocstream::open (const char *command, int mode)
+procstreambase::open (const char *command, int mode)
 {
   clear ();
 
-  if (pbuf)
-    delete pbuf;
-
-  pbuf = new procbuf ();
-
-  init (pbuf);
-
-  if (! pbuf->open (command, mode))
+  if (! pb.open (command, mode))
     set (ios::badbit);
 }
 
 int
-iprocstream::is_open (void)
-{
-  return pbuf && pbuf->is_open ();
-}
-
-int
-iprocstream::close (void)
+procstreambase::close (void)
 {
   int status = 0;
 
   if (is_open ())
     {
-      status = pbuf->sys_close ();
+      status = pb.sys_close ();
 
-      if (! pbuf->close ())
+      if (! pb.close ())
 	set (ios::failbit);
     }
 
   return status;
 }
 
-void
-cleanup_iprocstream (void *buf)
-{
-  delete (iprocstream *) buf;
-}
-
-oprocstream::oprocstream (const char *command, int mode)
-{
-  pbuf = new procbuf ();
-
-  init (pbuf);
-
-  if (! pbuf->open (command, mode))
-    set (ios::badbit);
-}
-
-oprocstream::~oprocstream (void)
-{
-  delete pbuf;
-}
-
-void
-oprocstream::open (const char *command, int mode)
-{
-  clear ();
-
-  if (pbuf)
-    delete pbuf;
-    
-  pbuf = new procbuf ();
-
-  init (pbuf);
-
-  if (! pbuf->open (command, mode))
-    set (ios::badbit);
-}
-
-int
-oprocstream::is_open (void)
-{
-  return pbuf && pbuf->is_open ();
-}
-
-int
-oprocstream::close (void)
-{
-  int status = 0;
-
-  if (is_open ())
-    {
-      if (! pbuf->close ())
-	set (ios::failbit);
-    }
-
-  return status;
-}
-
-void
-cleanup_oprocstream (void *buf)
-{
-  delete (oprocstream *) buf;
-}
-
 /*
 ;;; Local Variables: ***
 ;;; mode: C++ ***
--- a/src/procstream.h	Sat Feb 17 00:11:53 1996 +0000
+++ b/src/procstream.h	Sat Feb 17 02:03:11 1996 +0000
@@ -28,51 +28,109 @@
 #pragma interface
 #endif
 
-#include <fstream.h>
-
-class procbuf;
+#include <iostream.h>
+#include <procbuf.h>
 
 class
-iprocstream : public ifstream
+procstreambase : virtual public ios
 {
 public:
-  iprocstream (void) { pbuf = 0; }
-  iprocstream (const char *command, int mode=ios::in);
+
+  procstreambase (void) { pb_init (); }
+
+  procstreambase (const char *name, int mode);
 
-  ~iprocstream (void);
+  ~procstreambase (void) { close (); }
 
-  void open (const char *command, int mode=ios::in);
+  void open (const char *name, int mode);
 
-  int is_open (void);
+  int is_open (void) const { return pb.is_open (); }
 
   int close (void);
 
 private:
-  procbuf *pbuf;
+
+  procbuf pb;
+
+  void pb_init (void) { init (&pb); }
+
+  procstreambase (const procstreambase&);
+
+  procstreambase& operator = (const procstreambase&);
 };
 
-extern void cleanup_iprocstream (void *);
+class
+iprocstream : public procstreambase, public istream
+{
+public:
+
+  iprocstream (void) : procstreambase () { }
+
+  iprocstream (const char *name, int mode=ios::in)
+    : procstreambase(name, mode) { }
+
+  ~iprocstream (void) { }
+
+  void open (const char *name, int mode=ios::in)
+    {
+      procstreambase::open (name, mode);
+    }
+
+private:
+
+  iprocstream (const iprocstream&);
+
+  iprocstream& operator = (const iprocstream&);
+};
 
 class
-oprocstream : public ofstream
+oprocstream : public procstreambase, public ostream
 {
 public:
-  oprocstream (void) { pbuf = 0; }
-  oprocstream (const char *command, int mode=ios::out);
+ 
+  oprocstream (void) : procstreambase () { }
 
-  ~oprocstream (void);
+  oprocstream (const char *name, int mode=ios::out)
+    : procstreambase(name, mode) { }
 
-  void open (const char *command, int mode=ios::out);
+  ~oprocstream (void) { }
 
-  int is_open (void);
-
-  int close (void);
+  void open (const char *name, int mode=ios::out)
+    {
+      procstreambase::open(name, mode);
+    }
 
 private:
-  procbuf *pbuf;
+
+  oprocstream (const oprocstream&);
+
+  oprocstream& operator = (const oprocstream&);
 };
 
-extern void cleanup_oprocstream (void *);
+class
+procstream : public procstreambase, public iostream
+{
+public:
+
+  procstream (void) : procstreambase () { }
+
+  procstream (const char *name, int mode)
+    : procstreambase(name, mode) { }
+
+
+  ~procstream (void) { }
+
+  void open (const char *name, int mode)
+    {
+      procstreambase::open(name, mode);
+    }
+
+private:
+
+  procstream (const procstream&);
+
+  procstream& operator = (const procstream&);
+};
 
 #endif
 
--- a/src/toplev.cc	Sat Feb 17 00:11:53 1996 +0000
+++ b/src/toplev.cc	Sat Feb 17 02:03:11 1996 +0000
@@ -332,7 +332,7 @@
 
   int argc = args.length () + 1;
 
-  string_vector argv = make_argv (args, "casesen");
+  string_vector argv = args.make_argv ("casesen");
 
   if (error_state)
     return retval;
@@ -598,6 +598,12 @@
 
 // Execute a shell command.
 
+static void
+cleanup_iprocstream (void *p)
+{
+  delete (iprocstream *) p;
+}
+
 DEFUN (system, args, nargout,
   "system (string [, return_output]): execute shell commands")
 {