--- a/ExternalStream.st Thu Dec 15 14:04:40 2016 +0100
+++ b/ExternalStream.st Thu Dec 15 14:11:45 2016 +0100
@@ -2065,8 +2065,8 @@
"return the kind of object to be returned by sub-collection builders
(such as upTo)"
- binary == true ifTrue:[
- ^ ByteArray
+ binary ifTrue:[
+ ^ ByteArray
].
^ String
!
@@ -2746,14 +2746,14 @@
^ line , self nextLine
].
- (hitEOF == true) ifTrue:[^ self pastEndRead].
+ hitEOF ifTrue:[^ self pastEndRead].
error notNil ifTrue:[
lastErrorNumber := error.
^ self readError:error
].
handle isNil ifTrue:[^ self errorNotOpen].
(mode == #writeonly) ifTrue:[^ self errorWriteOnly].
- (binary == true) ifTrue:[^ self errorBinary].
+ binary ifTrue:[^ self errorBinary].
^ super nextLine
!
@@ -3024,13 +3024,6 @@
"
!
-create
- "create the stream
- - this must be redefined in subclass"
-
- ^ self subclassResponsibility
-!
-
ioctl:ioctlNumber
"to provide a simple ioctl facility - an ioctl is performed
on the underlying file; no arguments are passed."
@@ -5218,7 +5211,7 @@
}
#endif /* not SCHTEAM */
%}.
- hitEOF == true ifTrue:[^ self pastEndRead].
+ hitEOF ifTrue:[^ self pastEndRead].
error notNil ifTrue:[
lastErrorNumber := error.
^ self readError:error
@@ -5237,7 +5230,7 @@
c isNil ifTrue:[
^ self pastEndRead.
].
- binary == true ifTrue:[
+ binary ifTrue:[
^ c
].
^ Character value:c
@@ -5316,7 +5309,7 @@
}
}
%}.
- hitEOF == true ifTrue:[^ nil].
+ hitEOF ifTrue:[^ nil].
error notNil ifTrue:[
lastErrorNumber := error.
^ self readError:error.
@@ -5396,7 +5389,7 @@
}
}
%}.
- hitEOF == true ifTrue:[^ self pastEndRead].
+ hitEOF ifTrue:[^ self pastEndRead].
error notNil ifTrue:[
lastErrorNumber := error.
^ self readError:error.
@@ -5468,7 +5461,7 @@
}
}
%}.
- hitEOF == true ifTrue:[^ nil].
+ hitEOF ifTrue:[^ nil].
error notNil ifTrue:[
lastErrorNumber := error.
^ self readError:error.
@@ -5679,7 +5672,7 @@
gotErrorOrEOF
"answer true, if amn error or eof has been occurred on the stream"
- ^ hitEOF == true or:[lastErrorNumber notNil]
+ ^ hitEOF or:[lastErrorNumber notNil]
!
isBinary
@@ -5712,13 +5705,13 @@
isReadable
"return true, if this stream can be read from"
- ^ (mode ~~ #writeonly)
+ ^ mode ~~ #writeonly
!
isWritable
"return true, if this stream can be written to"
- ^ (mode ~~ #readonly)
+ ^ mode ~~ #readonly
! !
!ExternalStream methodsFor:'waiting for I/O'!
@@ -5982,7 +5975,7 @@
lastErrorNumber notNil ifTrue:[self writeError. ^ self].
handle isNil ifTrue:[self errorNotOpen. ^ self].
(mode == #readonly) ifTrue:[self errorReadOnly. ^ self].
- (binary==true) ifTrue:[self errorBinary. ^ self].
+ binary ifTrue:[self errorBinary. ^ self].
(eolMode == #cr) ifTrue:[
self nextPut:(Character return).
@@ -6045,9 +6038,9 @@
if ((handle != STObject.Nil)
&& (aCharacter.isSTCharacter())) {
- handle.writeChar( aCharacter );
- self.instVarAt_put(I_position, STObject.Nil);
- return __c__._RETURN_self();
+ handle.writeChar( aCharacter );
+ self.instVarAt_put(I_position, STObject.Nil);
+ return __c__._RETURN_self();
}
#else
__INST(lastErrorNumber) = nil;
@@ -6056,112 +6049,109 @@
|| (__INST(handleType) == @symbol(socketFilePointer))
|| (__INST(handleType) == @symbol(socketHandle))
|| (__INST(handleType) == @symbol(pipeFilePointer))) {
- OBJ fp;
-
- if (((fp = __INST(handle)) != nil)
- && (__INST(mode) != @symbol(readonly))
- ) {
- FILEPOINTER f = __FILEVal(fp);
- int _buffered = (__INST(buffered) == true);
- unsigned codePoint;
- unsigned char c;
- int cnt;
- char buff[2];
- int nBytes = 1;
-
- if (__INST(binary) != true) {
- if (__isCharacter(aCharacter)) {
-
- codePoint = __intVal(__characterVal(aCharacter));
- if (codePoint <= 0xFF) {
- c = codePoint;
- buff[0] = c; nBytes = 1;
-
- if (c == '\n') {
- OBJ mode = __INST(eolMode);
- if (mode == @symbol(nl)) {
- // no EOL translation
- } else if (mode == nil) {
- // no EOL translation
- } else if (mode == @symbol(cr)) {
- buff[0] = '\r';
- } else if (mode == @symbol(eot)) {
- buff[0] = '\004';
- } else if (mode == @symbol(etx)) {
- buff[0] = '\003';
- } else if (mode == @symbol(crlf)) {
- buff[0] = '\r';
- buff[1] = '\n';
- nBytes = 2;
- }
- }
+ OBJ fp;
+
+ if (((fp = __INST(handle)) != nil)
+ && (__INST(mode) != @symbol(readonly))
+ ) {
+ FILEPOINTER f = __FILEVal(fp);
+ int _buffered = (__INST(buffered) == true);
+ int cnt;
+ char buff[2];
+ int nBytes = 1;
+
+ if (__INST(binary) != true) {
+ if (__isCharacter(aCharacter)) {
+ unsigned int codePoint = __intVal(__characterVal(aCharacter));
+ if (codePoint <= 0xFF) {
+ unsigned char c = codePoint;
+ buff[0] = c; nBytes = 1;
+
+ if (c == '\n') {
+ OBJ mode = __INST(eolMode);
+ if (mode == @symbol(nl)) {
+ // no EOL translation
+ } else if (mode == nil) {
+ // no EOL translation
+ } else if (mode == @symbol(cr)) {
+ buff[0] = '\r';
+ } else if (mode == @symbol(eot)) {
+ buff[0] = '\004';
+ } else if (mode == @symbol(etx)) {
+ buff[0] = '\003';
+ } else if (mode == @symbol(crlf)) {
+ buff[0] = '\r';
+ buff[1] = '\n';
+ nBytes = 2;
+ }
+ }
doWrite:
- if (! f) {
- fprintf(stderr, "oops - fileHandle is NULL in nextPut:\n");
- __INST(handle) = nil;
- goto out;
- }
-
- if (_buffered) {
- __WRITING__(f)
- }
+ if (! f) {
+ fprintf(stderr, "oops - fileHandle is NULL in nextPut:\n");
+ __INST(handle) = nil;
+ goto out;
+ }
+
+ if (_buffered) {
+ __WRITING__(f)
+ }
# ifdef __win32__
- if ((f == __win32_stdout()) || (f == __win32_stderr())) {
- cnt = __win32_fwrite(buff, 1, nBytes, f);
- } else
+ if ((f == __win32_stdout()) || (f == __win32_stderr())) {
+ cnt = __win32_fwrite(buff, 1, nBytes, f);
+ } else
# endif
- {
- __WRITEBYTES__(cnt, f, buff, nBytes, _buffered, __INST(handleType));
- }
- if (cnt == nBytes) {
- if (__isSmallInteger(__INST(position))) {
- INT np = __intVal(__INST(position)) + nBytes;
- OBJ t;
-
- t = __MKINT(np); __INST(position) = t; __STORE(self, t);
- } else {
- __INST(position) = nil; /* i.e. do not know */
- }
- RETURN ( self );
- }
- error = __mkSmallInteger(__threadErrno);
- }
- }
- } else {
- if (__isSmallInteger(aCharacter)) {
- c = __intVal(aCharacter);
- buff[0] = c; nBytes = 1;
- goto doWrite;
- }
- }
- }
+ {
+ __WRITEBYTES__(cnt, f, buff, nBytes, _buffered, __INST(handleType));
+ }
+ if (cnt == nBytes) {
+ if (__isSmallInteger(__INST(position))) {
+ INT np = __intVal(__INST(position)) + nBytes;
+ OBJ t;
+
+ t = __MKINT(np); __INST(position) = t; __STORE(self, t);
+ } else {
+ __INST(position) = nil; /* i.e. do not know */
+ }
+ RETURN ( self );
+ }
+ error = __mkSmallInteger(__threadErrno);
+ }
+ }
+ } else {
+ if (__isSmallInteger(aCharacter)) {
+ unsigned char c = __intVal(aCharacter);
+ buff[0] = c; nBytes = 1;
+ goto doWrite;
+ }
+ }
+ }
}
out: ;
#endif /* not SCHTEAM */
%}.
error notNil ifTrue:[
- lastErrorNumber := error.
- self writeError:error.
- ^ self
+ lastErrorNumber := error.
+ self writeError:error.
+ ^ self
].
handle isNil ifTrue:[self errorNotOpen. ^ self].
(mode == #readonly) ifTrue:[self errorReadOnly. ^ self].
- binary == true ifFalse:[
- (aCharacter isCharacter not
- or:[aCharacter codePoint > 16rFF]) ifTrue:[
- self argumentMustBeCharacter.
- ^ self.
- ].
- ] ifTrue:[
- aCharacter isInteger ifFalse:[
- self argumentMustBeInteger.
- ^ self.
- ].
+ binary == true ifTrue:[
+ aCharacter isInteger ifFalse:[
+ self argumentMustBeInteger.
+ ^ self.
+ ].
+ ] ifFalse:[
+ (aCharacter isCharacter not
+ or:[aCharacter codePoint > 16rFF]) ifTrue:[
+ self argumentMustBeCharacter.
+ ^ self.
+ ].
].
"/ migration support
self
- nextPutByte:aCharacter asInteger
- toFile:handle
+ nextPutByte:aCharacter asInteger
+ toFile:handle
!
nextPutAll:aCollection
@@ -6736,100 +6726,6 @@
"normal streams can not handle multi-byte characters, so convert them to utf8"
self nextPutUtf8:aCharacter.
-!
-
-old_nextPut:aCharacter
- "write the argument, aCharacter - return nil if failed, self if ok.
- Only single-byte characters are currently supported"
-
- |error|
-%{
- OBJ fp;
-
- __INST(lastErrorNumber) = nil;
- if ((__INST(handleType) == nil)
- || (__INST(handleType) == @symbol(filePointer))
- || (__INST(handleType) == @symbol(socketFilePointer))
- || (__INST(handleType) == @symbol(socketHandle))
- || (__INST(handleType) == @symbol(pipeFilePointer))) {
- if (((fp = __INST(handle)) != nil)
- && (__INST(mode) != @symbol(readonly))
- ) {
- unsigned char c;
- int _buffered = (__INST(buffered) == true);
- FILEPOINTER f = __FILEVal(fp);
-
- if (__INST(binary) != true) {
- if (__isCharacter(aCharacter)) {
- unsigned codePoint = __intVal(__characterVal(aCharacter));
-
- if (codePoint <= 0xFF) {
- int cnt;
-
- c = codePoint;
- doWrite:
- if (! f) {
- fprintf(stderr, "oops - fileHandle is NULL in nextPut:\n");
- __INST(handle) = nil;
- goto out;
- }
-
- if (_buffered) {
- __WRITING__(f)
- }
-#ifdef __win32__
- if ((f == __win32_stdout()) || (f == __win32_stderr())) {
- cnt = __win32_fwrite(&c, 1, 1, f);
- } else
-#endif
- __WRITEBYTE__(cnt, f, &c, _buffered, __INST(handleType));
- if (cnt == 1) {
- if (__isSmallInteger(__INST(position))) {
- INT np = __intVal(__INST(position)) + 1;
- OBJ t;
-
- t = __MKINT(np); __INST(position) = t; __STORE(self, t);
- } else {
- __INST(position) = nil; /* i.e. do not know */
- }
- RETURN ( self );
- }
- error = __mkSmallInteger(__threadErrno);
- }
- }
- } else {
- if (__isSmallInteger(aCharacter)) {
- c = __intVal(aCharacter);
- goto doWrite;
- }
- }
- }
- }
-out: ;
-%}.
- error notNil ifTrue:[
- lastErrorNumber := error.
- self writeError:error.
- ^ self
- ].
- handle isNil ifTrue:[self errorNotOpen. ^ self].
- (mode == #readonly) ifTrue:[self errorReadOnly. ^ self].
- binary == true ifFalse:[
- (aCharacter isCharacter not
- or:[aCharacter codePoint > 16rFF]) ifTrue:[
- self argumentMustBeCharacter.
- ^ self.
- ].
- ] ifTrue:[
- aCharacter isInteger ifFalse:[
- self argumentMustBeInteger.
- ^ self.
- ].
- ].
- "/ migration support
- self
- nextPutByte:aCharacter asInteger
- toFile:handle
! !
!ExternalStream class methodsFor:'documentation'!