--- a/ExternalStream.st Tue Sep 19 16:35:11 2017 +0200
+++ b/ExternalStream.st Tue Sep 19 16:36:01 2017 +0200
@@ -4348,7 +4348,7 @@
"Write the argument, anIntegerOrCharacter as a short (two bytes).
If msbFlag is true, data is written most-significant byte first;
otherwise least first.
- Notice that integers in the range -16r8000 to +16rFFFF can be written
+ Notice that integers in the range 16r-8000 to +16rFFFF can be written
(i.e. both signed and unsigned int32 values can be written.
Works in both binary and text modes."
@@ -4356,8 +4356,8 @@
%{
int num;
union {
- char bytes[2];
- short shortVal;
+ char bytes[2];
+ short shortVal;
} u;
OBJ fp;
@@ -4367,66 +4367,68 @@
|| (__INST(handleType) == @symbol(socketFilePointer))
|| (__INST(handleType) == @symbol(socketHandle))
|| (__INST(handleType) == @symbol(pipeFilePointer))) {
- if (((fp = __INST(handle)) != nil)
- && (__INST(mode) != @symbol(readonly))
- ) {
- FILEPOINTER f = __FILEVal(fp);
- int _buffered = (__INST(buffered) == true);
- int cnt;
-
- if (__isSmallInteger(anIntegerOrCharacter)) {
- num = __intVal(anIntegerOrCharacter);
- } else if (__isCharacter(anIntegerOrCharacter)) {
- num = __smallIntegerVal(__characterVal(anIntegerOrCharacter));
- } else
- goto out;
-
- if (msbFlag == true) {
+ if (((fp = __INST(handle)) != nil)
+ && (__INST(mode) != @symbol(readonly))
+ ) {
+ FILEPOINTER f = __FILEVal(fp);
+ int _buffered = (__INST(buffered) == true);
+ int cnt;
+
+ if (__isSmallInteger(anIntegerOrCharacter)) {
+ num = __intVal(anIntegerOrCharacter);
+ } else if (__isCharacter(anIntegerOrCharacter)) {
+ num = __smallIntegerVal(__characterVal(anIntegerOrCharacter));
+ } else
+ goto out;
+
+ if (msbFlag == true) {
#if defined(__MSBFIRST__)
- u.shortVal = num;
+ u.shortVal = num;
#else
- u.bytes[0] = (num >> 8) & 0xFF;
- u.bytes[1] = num & 0xFF;
+ u.bytes[0] = (num >> 8) & 0xFF;
+ u.bytes[1] = num & 0xFF;
#endif
- } else {
+ } else {
#if defined(__LSBFIRST__)
- u.shortVal = num;
+ u.shortVal = num;
#else
- u.bytes[1] = (num >> 8) & 0xFF;
- u.bytes[0] = num & 0xFF;
+ u.bytes[1] = (num >> 8) & 0xFF;
+ u.bytes[0] = num & 0xFF;
#endif
- }
-
- if (_buffered) {
- __WRITING__(f)
- }
- __WRITEBYTES__(cnt, f, u.bytes, 2, _buffered, __INST(handleType));
-
- if (cnt == 2) {
- if (__isSmallInteger(__INST(position))) {
- INT np = __intVal(__INST(position)) + 2;
- OBJ t;
-
- t = __MKINT(np); __INST(position) = t; __STORE(self, t);
- } else {
- __INST(position) = nil; /* i.e. do not know */
- }
- RETURN ( self );
- }
- __INST(position) = nil; /* i.e. do not know */
- error = __mkSmallInteger(__threadErrno);
- }
+ }
+
+ if (_buffered) {
+ __WRITING__(f)
+ }
+ __WRITEBYTES__(cnt, f, u.bytes, 2, _buffered, __INST(handleType));
+
+ if (cnt == 2) {
+ if (__isSmallInteger(__INST(position))) {
+ INT np = __intVal(__INST(position)) + 2;
+ OBJ t;
+
+ t = __MKINT(np); __INST(position) = t; __STORE(self, t);
+ } else {
+ __INST(position) = nil; /* i.e. do not know */
+ }
+ RETURN ( self );
+ }
+ __INST(position) = nil; /* i.e. do not know */
+ error = __mkSmallInteger(__threadErrno);
+ }
}
out:;
%}.
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].
self argumentMustBeInteger
+
+ "Modified: / 19-09-2017 / 16:32:29 / stefan"
!
nextPutInt16LSB:anIntegerOrCharacter
@@ -4446,7 +4448,7 @@
nextPutInt16NATIVE:anIntegerOrCharacter
"Write the argument, anIntegerOrCharacter as a short (two bytes) in native byte order.
This is the CPU-specific byte order (LSB on x86, MSB on sparc, VAX and possibly on ARM).
- Notice that integers in the range -16r8000 to +16rFFFF can be written
+ Notice that integers in the range 16r-8000 to +16rFFFF can be written
(i.e. both signed and unsigned int32 values can be written.
Works in both binary and text modes."
@@ -4454,8 +4456,8 @@
%{
int num;
union {
- char bytes[2];
- short shortVal;
+ char bytes[2];
+ short shortVal;
} u;
OBJ fp;
@@ -4465,52 +4467,54 @@
|| (__INST(handleType) == @symbol(socketFilePointer))
|| (__INST(handleType) == @symbol(socketHandle))
|| (__INST(handleType) == @symbol(pipeFilePointer))) {
- if (((fp = __INST(handle)) != nil)
- && (__INST(mode) != @symbol(readonly))
- ) {
- FILEPOINTER f = __FILEVal(fp);
- int _buffered = (__INST(buffered) == true);
- int cnt;
-
- if (__isSmallInteger(anIntegerOrCharacter)) {
- num = __intVal(anIntegerOrCharacter);
- } else if (__isCharacter(anIntegerOrCharacter)) {
- num = __smallIntegerVal(__characterVal(anIntegerOrCharacter));
- } else
- goto out;
-
- u.shortVal = num;
-
- if (_buffered) {
- __WRITING__(f)
- }
- __WRITEBYTES__(cnt, f, u.bytes, 2, _buffered, __INST(handleType));
-
- if (cnt == 2) {
- if (__isSmallInteger(__INST(position))) {
- INT np = __intVal(__INST(position)) + 2;
- OBJ t;
-
- t = __MKINT(np); __INST(position) = t; __STORE(self, t);
- } else {
- __INST(position) = nil; /* i.e. do not know */
- }
- RETURN ( self );
- }
- __INST(position) = nil; /* i.e. do not know */
- error = __mkSmallInteger(__threadErrno);
- }
+ if (((fp = __INST(handle)) != nil)
+ && (__INST(mode) != @symbol(readonly))
+ ) {
+ FILEPOINTER f = __FILEVal(fp);
+ int _buffered = (__INST(buffered) == true);
+ int cnt;
+
+ if (__isSmallInteger(anIntegerOrCharacter)) {
+ num = __intVal(anIntegerOrCharacter);
+ } else if (__isCharacter(anIntegerOrCharacter)) {
+ num = __smallIntegerVal(__characterVal(anIntegerOrCharacter));
+ } else
+ goto out;
+
+ u.shortVal = num;
+
+ if (_buffered) {
+ __WRITING__(f)
+ }
+ __WRITEBYTES__(cnt, f, u.bytes, 2, _buffered, __INST(handleType));
+
+ if (cnt == 2) {
+ if (__isSmallInteger(__INST(position))) {
+ INT np = __intVal(__INST(position)) + 2;
+ OBJ t;
+
+ t = __MKINT(np); __INST(position) = t; __STORE(self, t);
+ } else {
+ __INST(position) = nil; /* i.e. do not know */
+ }
+ RETURN ( self );
+ }
+ __INST(position) = nil; /* i.e. do not know */
+ error = __mkSmallInteger(__threadErrno);
+ }
}
out:;
%}.
self nextPutInt16:anIntegerOrCharacter MSB:(UninterpretedBytes isBigEndian).
+
+ "Modified: / 19-09-2017 / 16:32:40 / stefan"
!
nextPutInt32:aNumber MSB:msbFlag
"Write the argument, aNumber as a long (four bytes).
If msbFlag is true, data is written most-significant byte first;
otherwise least first.
- Notice that integers in the range -16r80000000 to +16rFFFFFFFF can be written
+ Notice that integers in the range 16r-80000000 to +16rFFFFFFFF can be written
(i.e. both signed and unsigned int32 values can be written.
Works in both binary and text modes."
@@ -4519,29 +4523,29 @@
%{
int num;
union {
- char bytes[4];
- int intVal;
+ char bytes[4];
+ int intVal;
} u;
OBJ fp;
__INST(lastErrorNumber) = nil;
if (__isSmallInteger(aNumber)) {
- num = __intVal(aNumber);
+ num = __intVal(aNumber);
} else {
#if __POINTER_SIZE__ == 8
- // always more than 4-bytes
- goto badArg;
+ // always more than 4-bytes
+ goto badArg;
#else
- num = __longIntVal(aNumber);
- if (num == 0) {
- num = __signedLongIntVal(aNumber);
- if (num == 0) {
- /* bad arg or out-of-range integer
- * (handled by the fallBack code)
- */
- goto badArg;
- }
- }
+ num = __longIntVal(aNumber);
+ if (num == 0) {
+ num = __signedLongIntVal(aNumber);
+ if (num == 0) {
+ /* bad arg or out-of-range integer
+ * (handled by the fallBack code)
+ */
+ goto badArg;
+ }
+ }
#endif
}
@@ -4550,67 +4554,69 @@
|| (__INST(handleType) == @symbol(socketFilePointer))
|| (__INST(handleType) == @symbol(socketHandle))
|| (__INST(handleType) == @symbol(pipeFilePointer))) {
- if (((fp = __INST(handle)) != nil)
- && (__INST(mode) != @symbol(readonly))
- ) {
- int _buffered = (__INST(buffered) == true);
- FILEPOINTER f = __FILEVal(fp);
- int cnt;
-
- if (msbFlag == true) {
+ if (((fp = __INST(handle)) != nil)
+ && (__INST(mode) != @symbol(readonly))
+ ) {
+ int _buffered = (__INST(buffered) == true);
+ FILEPOINTER f = __FILEVal(fp);
+ int cnt;
+
+ if (msbFlag == true) {
#if defined(__MSBFIRST__)
- u.intVal = num;
+ u.intVal = num;
#else
- u.bytes[0] = (num >> 24) & 0xFF;
- u.bytes[1] = (num >> 16) & 0xFF;
- u.bytes[2] = (num >> 8) & 0xFF;
- u.bytes[3] = num & 0xFF;
+ u.bytes[0] = (num >> 24) & 0xFF;
+ u.bytes[1] = (num >> 16) & 0xFF;
+ u.bytes[2] = (num >> 8) & 0xFF;
+ u.bytes[3] = num & 0xFF;
#endif
- } else {
+ } else {
#if defined(__LSBFIRST__)
- u.intVal = num;
+ u.intVal = num;
#else
- u.bytes[3] = (num >> 24) & 0xFF;
- u.bytes[2] = (num >> 16) & 0xFF;
- u.bytes[1] = (num >> 8) & 0xFF;
- u.bytes[0] = num & 0xFF;
+ u.bytes[3] = (num >> 24) & 0xFF;
+ u.bytes[2] = (num >> 16) & 0xFF;
+ u.bytes[1] = (num >> 8) & 0xFF;
+ u.bytes[0] = num & 0xFF;
#endif
- }
-
- if (_buffered) {
- __WRITING__(f)
- }
- __WRITEBYTES__(cnt, f, u.bytes, 4, _buffered, __INST(handleType));
-
- if (cnt == 4) {
- if (__isSmallInteger(__INST(position))) {
- INT np = __intVal(__INST(position)) + 4;
- OBJ t;
-
- t = __MKINT(np); __INST(position) = t; __STORE(self, t);
- } else {
- __INST(position) = nil; /* i.e. do not know */
- }
- RETURN ( self );
- }
- __INST(position) = nil; /* i.e. do not know */
- error = __mkSmallInteger(__threadErrno);
- }
+ }
+
+ if (_buffered) {
+ __WRITING__(f)
+ }
+ __WRITEBYTES__(cnt, f, u.bytes, 4, _buffered, __INST(handleType));
+
+ if (cnt == 4) {
+ if (__isSmallInteger(__INST(position))) {
+ INT np = __intVal(__INST(position)) + 4;
+ OBJ t;
+
+ t = __MKINT(np); __INST(position) = t; __STORE(self, t);
+ } else {
+ __INST(position) = nil; /* i.e. do not know */
+ }
+ RETURN ( self );
+ }
+ __INST(position) = nil; /* i.e. do not know */
+ error = __mkSmallInteger(__threadErrno);
+ }
}
badArg: ;
%}.
handle isNil ifTrue:[self errorNotOpen. ^ self].
(mode == #readonly) ifTrue:[self errorReadOnly. ^ self].
error notNil ifTrue:[
- lastErrorNumber := error.
- self writeError:error.
- ^ self
+ lastErrorNumber := error.
+ self writeError:error.
+ ^ self
].
aNumber isInteger ifTrue:[
- ^ super nextPutInt32:aNumber MSB:msbFlag
+ ^ super nextPutInt32:aNumber MSB:msbFlag
].
self argumentMustBeInteger
+
+ "Modified: / 19-09-2017 / 16:32:50 / stefan"
!
nextPutInt32LSB:anIntegerOrCharacter
@@ -4630,41 +4636,41 @@
nextPutInt32NATIVE:anInteger
"Write the argument, anInteger as a long (four bytes) in native byte order.
This is the CPU-specific byte order (LSB on x86, MSB on sparc, VAX and possibly on ARM).
- Notice that integers in the range -16r80000000 to +16rFFFFFFFF can be written
+ Notice that integers in the range 16r-80000000 to +16rFFFFFFFF can be written
(i.e. both signed and unsigned int32 values can be written.
Works in both binary and text modes.
Notice: this message should not be sent explicitly by ANY program.
- the following implementation replaces the code of either nextPutInt32MSB or LSB
- dynamically (see #initialize on the class side)"
+ the following implementation replaces the code of either nextPutInt32MSB or LSB
+ dynamically (see #initialize on the class side)"
|error|
%{
int num;
union {
- char bytes[4];
- int intVal;
+ char bytes[4];
+ int intVal;
} u;
OBJ fp;
__INST(lastErrorNumber) = nil;
if (__isSmallInteger(anInteger)) {
- num = __intVal(anInteger);
+ num = __intVal(anInteger);
} else {
#if __POINTER_SIZE__ == 8
- // always more than 4-bytes
- goto badArg;
+ // always more than 4-bytes
+ goto badArg;
#else
- num = __longIntVal(anInteger);
- if (num == 0) {
- num = __signedLongIntVal(anInteger);
- if (num == 0) {
- /* bad arg or out-of-range integer
- * (handled by the fallBack code)
- */
- goto badArg;
- }
- }
+ num = __longIntVal(anInteger);
+ if (num == 0) {
+ num = __signedLongIntVal(anInteger);
+ if (num == 0) {
+ /* bad arg or out-of-range integer
+ * (handled by the fallBack code)
+ */
+ goto badArg;
+ }
+ }
#endif
}
@@ -4673,37 +4679,39 @@
|| (__INST(handleType) == @symbol(socketFilePointer))
|| (__INST(handleType) == @symbol(socketHandle))
|| (__INST(handleType) == @symbol(pipeFilePointer))) {
- if (((fp = __INST(handle)) != nil)
- && (__INST(mode) != @symbol(readonly))
- ) {
- int _buffered = (__INST(buffered) == true);
- FILEPOINTER f = __FILEVal(fp);
- int cnt;
-
- u.intVal = num;
- if (_buffered) {
- __WRITING__(f)
- }
- __WRITEBYTES__(cnt, f, u.bytes, 4, _buffered, __INST(handleType));
-
- if (cnt == 4) {
- if (__isSmallInteger(__INST(position))) {
- INT np = __intVal(__INST(position)) + 4;
- OBJ t;
-
- t = __MKINT(np); __INST(position) = t; __STORE(self, t);
- } else {
- __INST(position) = nil; /* i.e. do not know */
- }
- RETURN ( self );
- }
- __INST(position) = nil; /* i.e. do not know */
- error = __mkSmallInteger(__threadErrno);
- }
+ if (((fp = __INST(handle)) != nil)
+ && (__INST(mode) != @symbol(readonly))
+ ) {
+ int _buffered = (__INST(buffered) == true);
+ FILEPOINTER f = __FILEVal(fp);
+ int cnt;
+
+ u.intVal = num;
+ if (_buffered) {
+ __WRITING__(f)
+ }
+ __WRITEBYTES__(cnt, f, u.bytes, 4, _buffered, __INST(handleType));
+
+ if (cnt == 4) {
+ if (__isSmallInteger(__INST(position))) {
+ INT np = __intVal(__INST(position)) + 4;
+ OBJ t;
+
+ t = __MKINT(np); __INST(position) = t; __STORE(self, t);
+ } else {
+ __INST(position) = nil; /* i.e. do not know */
+ }
+ RETURN ( self );
+ }
+ __INST(position) = nil; /* i.e. do not know */
+ error = __mkSmallInteger(__threadErrno);
+ }
}
badArg: ;
%}.
self nextPutInt32:anInteger MSB:(UninterpretedBytes isBigEndian)
+
+ "Modified: / 19-09-2017 / 16:32:59 / stefan"
!
nextPutUtf16:aCharacter