--- a/ExternalStream.st Tue Mar 16 11:11:55 2004 +0100
+++ b/ExternalStream.st Tue Mar 16 11:28:51 2004 +0100
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
"
COPYRIGHT (c) 1988 by Claus Gittinger
All Rights Reserved
@@ -2099,9 +2097,9 @@
argumentMustBeCharacter
"{ Pragma: +optSpace }"
- "report an error, that the argument must be a character"
-
- ^ self error:'argument must be a character'
+ "report an error, that the argument must be a character in 0..FF"
+
+ ^ self error:'argument must be a single byte character'
!
argumentMustBeInteger
@@ -5646,55 +5644,52 @@
%{
FILEPOINTER f;
- char c;
+ unsigned codePoint;
+ unsigned char c;
int cnt, _buffered;
OBJ fp;
__INST(lastErrorNumber) = nil;
if (((fp = __INST(filePointer)) != nil)
- && (__INST(mode) != @symbol(readonly))
+ && (__INST(mode) != @symbol(readonly))
) {
- if (__INST(binary) != true) {
- if (__isCharacter(aCharacter)) {
- c = __intVal(__characterVal(aCharacter)) & 0xFF;
+ if (__INST(binary) != true) {
+ if (__isCharacter(aCharacter)) {
+ codePoint = __intVal(__characterVal(aCharacter));
+ if (codePoint <= 0xFF) {
+ c = codePoint;
doWrite:
- f = __FILEVal(fp);
- if (! f) {
- fprintf(stderr, "oops - fileHandle is NULL in nextPut:\n");
- __INST(filePointer) = nil;
- goto out;
- }
-
- if (_buffered = (__INST(buffered) == true)) {
- __WRITING__(f)
- }
-#ifdef WIN32
- if ((f == stdout) || (f == stderr)) {
- cnt = fwrite(&c, 1, 1, f);
- } else
-#endif
- {
- __WRITEBYTE__(cnt, f, &c, _buffered);
- }
- if (cnt == 1) {
- if (__isSmallInteger(__INST(position))) {
- INT np = __intVal(__INST(position)) + 1;
- OBJ t;
-
- __INST(position) = t = __MKINT(np); __STORE(self, t);
- } else {
- __INST(position) = nil; /* i.e. do not know */
- }
- RETURN ( self );
- }
- __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
- }
- } else {
- if (__isSmallInteger(aCharacter)) {
- c = __intVal(aCharacter);
- goto doWrite;
- }
- }
+ f = __FILEVal(fp);
+ if (! f) {
+ fprintf(stderr, "oops - fileHandle is NULL in nextPut:\n");
+ __INST(filePointer) = nil;
+ goto out;
+ }
+
+ if (_buffered = (__INST(buffered) == true)) {
+ __WRITING__(f)
+ }
+ __WRITEBYTE__(cnt, f, &c, _buffered);
+ if (cnt == 1) {
+ if (__isSmallInteger(__INST(position))) {
+ INT np = __intVal(__INST(position)) + 1;
+ OBJ t;
+
+ __INST(position) = t = __MKINT(np); __STORE(self, t);
+ } else {
+ __INST(position) = nil; /* i.e. do not know */
+ }
+ RETURN ( self );
+ }
+ __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
+ }
+ }
+ } else {
+ if (__isSmallInteger(aCharacter)) {
+ c = __intVal(aCharacter);
+ goto doWrite;
+ }
+ }
}
out: ;
%}.
@@ -5702,20 +5697,21 @@
filePointer isNil ifTrue:[self errorNotOpen. ^ self].
(mode == #readonly) ifTrue:[self errorReadOnly. ^ self].
binary == true ifFalse:[
- aCharacter isCharacter ifFalse:[
- self argumentMustBeCharacter.
- ^ self.
- ]
+ (aCharacter isCharacter not
+ or:[aCharacter codePoint > 16rFF]) ifTrue:[
+ self argumentMustBeCharacter.
+ ^ self.
+ ].
] ifTrue:[
- aCharacter isInteger ifFalse:[
- self argumentMustBeInteger.
- ^ self.
- ].
+ aCharacter isInteger ifFalse:[
+ self argumentMustBeInteger.
+ ^ self.
+ ].
].
"/ migration support
self
- nextPutByte:aCharacter asInteger
- toFile:filePointer
+ nextPutByte:aCharacter asInteger
+ toFile:filePointer
!
nextPutAll:aCollection
@@ -5900,7 +5896,7 @@
!ExternalStream class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.277 2004-03-04 19:29:51 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.278 2004-03-16 10:28:51 cg Exp $'
! !
ExternalStream initialize!