--- a/PipeStream.st Fri Aug 05 02:55:07 1994 +0200
+++ b/PipeStream.st Fri Aug 05 02:59:40 1994 +0200
@@ -20,6 +20,8 @@
PipeStream comment:'
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
+
+$Header: /cvs/stx/stx/libbasic/PipeStream.st,v 1.12 1994-08-05 00:59:20 claus Exp $
'!
!PipeStream class methodsFor:'documentation'!
@@ -40,7 +42,7 @@
version
"
-$Header: /cvs/stx/stx/libbasic/PipeStream.st,v 1.11 1994-06-02 16:21:16 claus Exp $
+$Header: /cvs/stx/stx/libbasic/PipeStream.st,v 1.12 1994-08-05 00:59:20 claus Exp $
"
!
@@ -141,16 +143,14 @@
%{ /* UNLIMITEDSTACK */
#ifndef transputer
extern int _immediateInterrupt;
- int savInt;
if (_INST(filePointer) != nil) {
- savInt = _immediateInterrupt;
/*
* allow interrupt even when blocking here ...
*/
_immediateInterrupt = 1;
pclose(MKFD(_INST(filePointer)));
- _immediateInterrupt = savInt;
+ _immediateInterrupt = 0;
}
#endif
%}
@@ -158,6 +158,35 @@
!PipeStream methodsFor:'private'!
+atEnd
+ "return true, if position is at end"
+
+%{ /* NOCONTEXT */
+#ifdef IRIX5
+ FILE *f;
+ OBJ t;
+ OBJ _true = true;
+ int c;
+
+ if (_INST(hitEOF) == _true) {
+ RETURN (_true);
+ }
+ if ((t = _INST(filePointer)) != nil) {
+ f = MKFD(t);
+ if (feof(f)) {
+ _INST(hitEOF) = true;
+ RETURN (true);
+ }
+ RETURN ( false );
+ }
+#endif
+%}
+.
+ ^ super atEnd
+! !
+
+!PipeStream methodsFor:'private'!
+
openPipeFor:aCommandString withMode:mode
"open a pipe to the unix command in aCcommandString; mode may be 'r' or 'w'"
@@ -169,10 +198,8 @@
FILE *f;
extern errno;
extern int _immediateInterrupt;
- int savInt;
if (__isString(aCommandString) && __isString(mode)) {
- savInt = _immediateInterrupt;
_immediateInterrupt = 1;
do {
#ifdef LINUX
@@ -187,7 +214,7 @@
(char *) _stringVal(mode));
#endif
} while ((f == NULL) && (errno == EINTR));
- _immediateInterrupt = savInt;
+ _immediateInterrupt = 0;
if (f == NULL) {
ExternalStream_LastErrorNumber = _MKSMALLINT(errno);
} else {
@@ -202,6 +229,7 @@
retVal notNil ifTrue:[
commandString := aCommandString.
buffered := true.
+ hitEOF := false.
Lobby register:self
].
^ retVal
@@ -210,13 +238,13 @@
readingFrom:command
"setup the receiver to read from command"
- self readonly.
+ self readonly. didWrite := false.
^ self openPipeFor:command withMode:'r'
!
writingTo:command
"setup the receiver to write to command"
- self writeonly.
+ self writeonly. didWrite := true.
^ self openPipeFor:command withMode:'w'
! !