--- a/ExternalStream.st Thu Mar 04 18:28:43 2004 +0100
+++ b/ExternalStream.st Thu Mar 04 18:36:22 2004 +0100
@@ -1500,45 +1500,45 @@
OpenErrorSignal isNil ifTrue:[
"/ OpenErrorSignal := OpenError.
"/ OpenErrorSignal nameClass:self message:#openErrorSignal.
- OpenErrorSignal := OpenError.
- OpenErrorSignal notifierString:'open error'.
-
- InvalidReadSignal := ReadErrorSignal newSignalMayProceed:false.
- InvalidReadSignal nameClass:self message:#invalidReadSignal.
- InvalidReadSignal notifierString:'read error'.
-
- InvalidWriteSignal := WriteErrorSignal newSignalMayProceed:false.
- InvalidWriteSignal nameClass:self message:#invalidWriteSignal.
- InvalidWriteSignal notifierString:'write error'.
-
- InvalidModeSignal := StreamErrorSignal newSignalMayProceed:false.
- InvalidModeSignal nameClass:self message:#invalidModeSignal.
- InvalidModeSignal notifierString:'binary/text mode mismatch'.
-
- InvalidOperationSignal := StreamErrorSignal newSignalMayProceed:false.
- InvalidOperationSignal nameClass:self message:#invalidOperationSignal.
- InvalidOperationSignal notifierString:'unsupported file operation'.
-
- StreamNotOpenSignal := StreamErrorSignal newSignalMayProceed:false.
- StreamNotOpenSignal nameClass:self message:#streamNotOpenSignal.
- StreamNotOpenSignal notifierString:'stream is not open'.
-
- StreamIOErrorSignal := StreamErrorSignal newSignalMayProceed:false.
- StreamIOErrorSignal nameClass:self message:#streamIOErrorSignal.
- StreamIOErrorSignal notifierString:'I/O error'.
+ OpenErrorSignal := OpenError.
+ OpenErrorSignal notifierString:'open error'.
+
+ InvalidReadSignal := ReadErrorSignal newSignalMayProceed:false.
+ InvalidReadSignal nameClass:self message:#invalidReadSignal.
+ InvalidReadSignal notifierString:'read error'.
+
+ InvalidWriteSignal := WriteErrorSignal newSignalMayProceed:false.
+ InvalidWriteSignal nameClass:self message:#invalidWriteSignal.
+ InvalidWriteSignal notifierString:'write error'.
+
+ InvalidModeSignal := StreamErrorSignal newSignalMayProceed:false.
+ InvalidModeSignal nameClass:self message:#invalidModeSignal.
+ InvalidModeSignal notifierString:'binary/text mode mismatch'.
+
+ InvalidOperationSignal := StreamErrorSignal newSignalMayProceed:false.
+ InvalidOperationSignal nameClass:self message:#invalidOperationSignal.
+ InvalidOperationSignal notifierString:'unsupported file operation'.
+
+ StreamNotOpenSignal := StreamErrorSignal newSignalMayProceed:false.
+ StreamNotOpenSignal nameClass:self message:#streamNotOpenSignal.
+ StreamNotOpenSignal notifierString:'stream is not open'.
+
+ StreamIOErrorSignal := StreamErrorSignal newSignalMayProceed:false.
+ StreamIOErrorSignal nameClass:self message:#streamIOErrorSignal.
+ StreamIOErrorSignal notifierString:'I/O error'.
].
Lobby isNil ifTrue:[
- Lobby := Registry new.
-
- "want to get informed when returning from snapshot"
- ObjectMemory addDependent:self
+ Lobby := Registry new.
+
+ "want to get informed when returning from snapshot"
+ ObjectMemory addDependent:self
].
DefaultEOLMode isNil ifTrue:[
- self initDefaultEOLMode.
+ self initDefaultEOLMode.
].
ReadMode isNil ifTrue:[
- self initModeStrings.
+ self initModeStrings.
].
"Modified: / 21.5.1998 / 16:33:53 / cg"
!
@@ -2046,7 +2046,7 @@
!
pathName
- ^ nil
+ ^ nil
!
readonly
@@ -2260,10 +2260,10 @@
"/ ^ nil.
"report an error, that the open failed"
- ^ self class openErrorSignal
- raiseRequestWith:self pathName
- errorString:('error on open: ' , self lastErrorString)
- "/ in:thisContext sender
+ ^ OpenError
+ raiseRequestWith:self pathName
+ errorString:('error on open: ' , self lastErrorString)
+ "/ in:thisContext sender
"Modified: / 28.1.1998 / 14:37:42 / stefan"
"Modified: / 8.5.1999 / 20:12:12 / cg"
@@ -2433,121 +2433,121 @@
__INST(lastErrorNumber) = nil;
if (((fp = __INST(filePointer)) != nil)
- && (__INST(mode) != @symbol(writeonly))
- && (__INST(binary) != true)
+ && (__INST(mode) != @symbol(writeonly))
+ && (__INST(binary) != true)
) {
- f = __FILEVal(fp);
- buffer[0] = '\0';
-
- _buffered = (__INST(buffered) == true);
- if (_buffered) {
- __READING__(f);
- }
-
- rslt = nextPtr = buffer;
- limit = buffer + sizeof(buffer) - 2;
-
- for (;;) {
- __READBYTE__(ret, f, nextPtr, _buffered);
- if (ret <= 0) {
- if (nextPtr == buffer)
- rslt = NULL;
- if (ret == 0) {
- __INST(hitEOF) = true;
- break;
- } else {
- __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
- goto err;
- }
- }
-
- if (*nextPtr == '\n') {
- cutOff = 1;
- *nextPtr = '\0';
- break;
- }
- if (*nextPtr == '\r') {
- char peekChar;
-
- /*
- * peek ahead for a newLine ...
- */
- __READBYTE__(ret, f, &peekChar, _buffered);
- if (ret <= 0) {
- cutOff = 1;
- *nextPtr = '\0';
- if (ret == 0) {
- __INST(hitEOF) = true;
- break;
- }
- __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
- goto err;
- }
-
- if (peekChar == '\n') {
- cutOff = 2;
- *nextPtr = '\0';
- break;
- }
-
- __UNGETC__(peekChar, f, _buffered);
-
- cutOff = 1;
- *nextPtr = '\0';
- break;
- }
-
- nextPtr++;
- if (nextPtr >= limit) {
- *nextPtr = '\0';
- lineTooLong = 1;
- if (@global(InfoPrinting) == true) {
- fprintf(stderr, "ExtStream [warning]: line truncated in nextLine\n");
- }
- break;
- }
- }
-
- if (rslt != NULL) {
- len = nextPtr-buffer;
-
- if (__isSmallInteger(__INST(position))) {
- INT np = __intVal(__INST(position)) + len + cutOff;
- OBJ t;
-
- __INST(position) = t = __MKINT(np); __STORE(self, t);
- } else {
- __INST(position) = nil; /* i.e. do not know */
- }
- /* remove any EOL character */
- if (len != 0) {
- if (buffer[len-1] == '\n') {
- buffer[--len] = '\0';
- }
- if ((len != 0) && (buffer[len-1] == '\r')) {
- buffer[--len] = '\0';
- }
- }
- line = __MKSTRING_L(buffer, len);
- if (! lineTooLong) {
- RETURN ( line );
- }
- }
+ f = __FILEVal(fp);
+ buffer[0] = '\0';
+
+ _buffered = (__INST(buffered) == true);
+ if (_buffered) {
+ __READING__(f);
+ }
+
+ rslt = nextPtr = buffer;
+ limit = buffer + sizeof(buffer) - 2;
+
+ for (;;) {
+ __READBYTE__(ret, f, nextPtr, _buffered);
+ if (ret <= 0) {
+ if (nextPtr == buffer)
+ rslt = NULL;
+ if (ret == 0) {
+ __INST(hitEOF) = true;
+ break;
+ } else {
+ __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
+ goto err;
+ }
+ }
+
+ if (*nextPtr == '\n') {
+ cutOff = 1;
+ *nextPtr = '\0';
+ break;
+ }
+ if (*nextPtr == '\r') {
+ char peekChar;
+
+ /*
+ * peek ahead for a newLine ...
+ */
+ __READBYTE__(ret, f, &peekChar, _buffered);
+ if (ret <= 0) {
+ cutOff = 1;
+ *nextPtr = '\0';
+ if (ret == 0) {
+ __INST(hitEOF) = true;
+ break;
+ }
+ __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
+ goto err;
+ }
+
+ if (peekChar == '\n') {
+ cutOff = 2;
+ *nextPtr = '\0';
+ break;
+ }
+
+ __UNGETC__(peekChar, f, _buffered);
+
+ cutOff = 1;
+ *nextPtr = '\0';
+ break;
+ }
+
+ nextPtr++;
+ if (nextPtr >= limit) {
+ *nextPtr = '\0';
+ lineTooLong = 1;
+ if (@global(InfoPrinting) == true) {
+ fprintf(stderr, "ExtStream [warning]: line truncated in nextLine\n");
+ }
+ break;
+ }
+ }
+
+ if (rslt != NULL) {
+ len = nextPtr-buffer;
+
+ if (__isSmallInteger(__INST(position))) {
+ INT np = __intVal(__INST(position)) + len + cutOff;
+ OBJ t;
+
+ __INST(position) = t = __MKINT(np); __STORE(self, t);
+ } else {
+ __INST(position) = nil; /* i.e. do not know */
+ }
+ /* remove any EOL character */
+ if (len != 0) {
+ if (buffer[len-1] == '\n') {
+ buffer[--len] = '\0';
+ }
+ if ((len != 0) && (buffer[len-1] == '\r')) {
+ buffer[--len] = '\0';
+ }
+ }
+ line = __MKSTRING_L(buffer, len);
+ if (! lineTooLong) {
+ RETURN ( line );
+ }
+ }
}
err: ;
%}.
line notNil ifTrue:[
- "/ the line as read is longer than 32k characters (boy - what a line)
- "/ The exception could be handled by reading more and returning the
- "/ concatenation in your exception handler (the receiver and the partial
- "/ line are passed as parameter)
-
- LineTooLongErrorSignal isHandled ifTrue:[
- ^ LineTooLongErrorSignal
- raiseRequestWith:(Array with:self with:line)
- errorString:('line too long read error')
- ].
- ^ line , self nextLine
+ "/ the line as read is longer than 32k characters (boy - what a line)
+ "/ The exception could be handled by reading more and returning the
+ "/ concatenation in your exception handler (the receiver and the partial
+ "/ line are passed as parameter)
+
+ LineTooLongErrorSignal isHandled ifTrue:[
+ ^ LineTooLongErrorSignal
+ raiseRequestWith:(Array with:self with:line)
+ errorString:('line too long read error')
+ ].
+ ^ line , self nextLine
].
(hitEOF == true) ifTrue:[^ self pastEnd].
@@ -2571,49 +2571,49 @@
__INST(lastErrorNumber) = nil;
if (((fp = __INST(filePointer)) != nil)
- && (__INST(mode) != @symbol(readonly))
- && (__INST(binary) != true)
- && __isString(aString)
+ && (__INST(mode) != @symbol(readonly))
+ && (__INST(binary) != true)
+ && __isString(aString)
) {
- f = __FILEVal(fp);
- len = __stringSize(aString);
-
- if (_buffered = (__INST(buffered) == true)) {
- __WRITING__(f)
- }
+ f = __FILEVal(fp);
+ len = __stringSize(aString);
+
+ if (_buffered = (__INST(buffered) == true)) {
+ __WRITING__(f)
+ }
#ifdef BUGGY
- __WRITEBYTES__(cnt, f, __stringVal(aString), len, _buffered);
+ __WRITEBYTES__(cnt, f, __stringVal(aString), len, _buffered);
#else
- o_offs = (char *)__stringVal(aString)-(char *)aString;
- __WRITEBYTES_OBJ__(cnt, f, aString, o_offs, len, _buffered);
+ o_offs = (char *)__stringVal(aString)-(char *)aString;
+ __WRITEBYTES_OBJ__(cnt, f, aString, o_offs, len, _buffered);
#endif
- if (cnt == len) {
- OBJ mode = __INST(eolMode);
-
- len1 = len;
-
- if (mode == @symbol(cr)) {
- cp = "\r"; len = 1;
- } else if (mode == @symbol(crlf)) {
- cp = "\r\n"; len = 2;
- } else {
- cp = "\n"; len = 1;
- }
- __WRITEBYTES__(cnt, f, cp, len, _buffered);
-
- if (cnt > 0) {
- if (__isSmallInteger(__INST(position))) {
- INT np = __intVal(__INST(position)) + cnt;
- 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);
+ if (cnt == len) {
+ OBJ mode = __INST(eolMode);
+
+ len1 = len;
+
+ if (mode == @symbol(cr)) {
+ cp = "\r"; len = 1;
+ } else if (mode == @symbol(crlf)) {
+ cp = "\r\n"; len = 2;
+ } else {
+ cp = "\n"; len = 1;
+ }
+ __WRITEBYTES__(cnt, f, cp, len, _buffered);
+
+ if (cnt > 0) {
+ if (__isSmallInteger(__INST(position))) {
+ INT np = __intVal(__INST(position)) + cnt;
+ 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);
}
%}.
super nextPutLine:aString.
@@ -2646,57 +2646,57 @@
__INST(lastErrorNumber) = nil;
if (__isSmallInteger(srcFilePointer)) {
- if ((aStringOrNil == nil) || __isString(aStringOrNil)) {
- if (aStringOrNil != nil) {
- matchString = (char *) __stringVal(aStringOrNil);
- matchLen = __stringSize(aStringOrNil);
- }
- dst = __FILEVal(__INST(filePointer));
- src = __FILEVal(srcFilePointer);
- __BEGIN_INTERRUPTABLE__
- __threadErrno = 0;
-
- __WRITING__(dst)
-
- for (;;) {
- if (fgets(buffer, sizeof(buffer)-1, src) == NULL) {
- if (ferror(src)) {
- readError = __MKSMALLINT(__threadErrno);
- __END_INTERRUPTABLE__
- goto err;
- }
- break;
- }
- if (fputs(buffer, dst) == EOF) {
- if (ferror(dst)) {
- __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
- __END_INTERRUPTABLE__
- goto err;
- }
- break;
- }
+ if ((aStringOrNil == nil) || __isString(aStringOrNil)) {
+ if (aStringOrNil != nil) {
+ matchString = (char *) __stringVal(aStringOrNil);
+ matchLen = __stringSize(aStringOrNil);
+ }
+ dst = __FILEVal(__INST(filePointer));
+ src = __FILEVal(srcFilePointer);
+ __BEGIN_INTERRUPTABLE__
+ __threadErrno = 0;
+
+ __WRITING__(dst)
+
+ for (;;) {
+ if (fgets(buffer, sizeof(buffer)-1, src) == NULL) {
+ if (ferror(src)) {
+ readError = __MKSMALLINT(__threadErrno);
+ __END_INTERRUPTABLE__
+ goto err;
+ }
+ break;
+ }
+ if (fputs(buffer, dst) == EOF) {
+ if (ferror(dst)) {
+ __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
+ __END_INTERRUPTABLE__
+ goto err;
+ }
+ break;
+ }
#ifndef OLD
- if (__INST(buffered) == false) {
- FFLUSH(dst);
- }
+ if (__INST(buffered) == false) {
+ FFLUSH(dst);
+ }
#endif
- if (matchLen) {
- if (strncmp(matchString, buffer, matchLen) == 0)
- break;
- }
- }
- __END_INTERRUPTABLE__
- __INST(position) = nil; /* i.e. do not know */
- RETURN (self);
- }
+ if (matchLen) {
+ if (strncmp(matchString, buffer, matchLen) == 0)
+ break;
+ }
+ }
+ __END_INTERRUPTABLE__
+ __INST(position) = nil; /* i.e. do not know */
+ RETURN (self);
+ }
}
err: ;
#endif /* ! NO_STDIO */
%}.
readError ifTrue:[
- aStream setLastErrorNumber:readError.
- aStream readError.
- ^ self
+ aStream setLastErrorNumber:readError.
+ aStream readError.
+ ^ self
].
lastErrorNumber notNil ifTrue:[self writeError. ^ self].
buffered ifFalse:[self errorNotBuffered. ^ self].
@@ -2705,14 +2705,14 @@
argument error or unimplemented; try it linewise
"
[aStream atEnd] whileFalse:[
- line := aStream nextLine.
- line isNil ifTrue:[
- ^ self.
- ].
- self nextPutLine:line.
- (aStringOrNil notNil and:[line startsWith:aStringOrNil]) ifTrue:[
- ^ self
- ]
+ line := aStream nextLine.
+ line isNil ifTrue:[
+ ^ self.
+ ].
+ self nextPutLine:line.
+ (aStringOrNil notNil and:[line startsWith:aStringOrNil]) ifTrue:[
+ ^ self
+ ]
].
!
@@ -2755,46 +2755,46 @@
__INST(lastErrorNumber) = nil;
if (__isString(aString)) {
- matchString = (char *) __stringVal(aString);
- l = __stringSize(aString);
-
- f = __FILEVal(__INST(filePointer));
- __READING__(f)
-
- for (;;) {
- FTELL(f, lastpos);
- if (!gotFirst) {
- firstpos = lastpos;
- gotFirst = 1;
- }
-
- __BEGIN_INTERRUPTABLE__
- do {
- cp = fgets(buffer, sizeof(buffer)-1, f);
- } while ((cp == NULL) && ferror(f) && (__threadErrno == EINTR) && (clearerr(f), 1));
- buffer[sizeof(buffer)-1] = '\0';
- __END_INTERRUPTABLE__
-
- if (cp == NULL) {
- if (ferror(f)) {
- __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
- goto err;
- } else {
- FSEEK(f, firstpos);
- RETURN (nil);
- }
- }
- if (strncmp(cp, matchString, l) == 0) {
- FSEEK(f, lastpos);
- break;
- }
- }
- /* remove EOL character */
- cp = buffer;
- while (*cp && (*cp != '\n') && (*cp != '\r')) cp++;
- *cp = '\0';
- __INST(position) = nil; /* i.e. do not know */
- RETURN ( __MKSTRING(buffer) );
+ matchString = (char *) __stringVal(aString);
+ l = __stringSize(aString);
+
+ f = __FILEVal(__INST(filePointer));
+ __READING__(f)
+
+ for (;;) {
+ FTELL(f, lastpos);
+ if (!gotFirst) {
+ firstpos = lastpos;
+ gotFirst = 1;
+ }
+
+ __BEGIN_INTERRUPTABLE__
+ do {
+ cp = fgets(buffer, sizeof(buffer)-1, f);
+ } while ((cp == NULL) && ferror(f) && (__threadErrno == EINTR) && (clearerr(f), 1));
+ buffer[sizeof(buffer)-1] = '\0';
+ __END_INTERRUPTABLE__
+
+ if (cp == NULL) {
+ if (ferror(f)) {
+ __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
+ goto err;
+ } else {
+ FSEEK(f, firstpos);
+ RETURN (nil);
+ }
+ }
+ if (strncmp(cp, matchString, l) == 0) {
+ FSEEK(f, lastpos);
+ break;
+ }
+ }
+ /* remove EOL character */
+ cp = buffer;
+ while (*cp && (*cp != '\n') && (*cp != '\r')) cp++;
+ *cp = '\0';
+ __INST(position) = nil; /* i.e. do not know */
+ RETURN ( __MKSTRING(buffer) );
}
err: ;
@@ -2809,16 +2809,16 @@
firstPos := self position.
[self atEnd] whileFalse:[
- lastPos := self position.
- line := self nextLine.
- line isNil ifTrue:[
- self position:firstPos.
- ^ nil
- ].
- (line startsWith:aString) ifTrue:[
- self position:lastPos.
- ^ line
- ]
+ lastPos := self position.
+ line := self nextLine.
+ line isNil ifTrue:[
+ self position:firstPos.
+ ^ nil
+ ].
+ (line startsWith:aString) ifTrue:[
+ self position:lastPos.
+ ^ line
+ ]
].
self position:firstPos.
^ nil
@@ -2988,39 +2988,39 @@
__INST(lastErrorNumber) = nil;
if ((fp = __INST(filePointer)) != nil) {
- if (__isSmallInteger(ioctlNumber)
- && (__isSmallInteger(arg)
- || (arg == nil)
- || __isBytes(arg)
- || __isExternalBytesLike(arg)
- || __isExternalAddress(arg))) {
- f = __FILEVal(fp);
- ioNum = __intVal(ioctlNumber);
-
- __BEGIN_INTERRUPTABLE__
- do {
- __threadErrno = 0;
- if (arg == nil) {
- ioArg = 0;
- } else if (__isSmallInteger(arg)) {
- ioArg = __intVal(arg);
- } else if (__isExternalBytesLike(arg)) {
- ioArg = (INT)(__externalBytesAddress(arg));
- } else if (__isExternalAddress(arg)) {
- ioArg = (INT)(__externalAddressVal(arg));
- } else {
- ioArg = (INT)(__ByteArrayInstPtr(arg)->ba_element);
- }
- ret = ioctl(fileno(f), ioNum, ioArg);
- } while ((ret < 0) && (__threadErrno == EINTR));
- __END_INTERRUPTABLE__
-
- if (ret >= 0) {
- RETURN ( __MKSMALLINT(ret) );
- }
- __INST(position) = nil; /* i.e. do not know */
- __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
- }
+ if (__isSmallInteger(ioctlNumber)
+ && (__isSmallInteger(arg)
+ || (arg == nil)
+ || __isBytes(arg)
+ || __isExternalBytesLike(arg)
+ || __isExternalAddress(arg))) {
+ f = __FILEVal(fp);
+ ioNum = __intVal(ioctlNumber);
+
+ __BEGIN_INTERRUPTABLE__
+ do {
+ __threadErrno = 0;
+ if (arg == nil) {
+ ioArg = 0;
+ } else if (__isSmallInteger(arg)) {
+ ioArg = __intVal(arg);
+ } else if (__isExternalBytesLike(arg)) {
+ ioArg = (INT)(__externalBytesAddress(arg));
+ } else if (__isExternalAddress(arg)) {
+ ioArg = (INT)(__externalAddressVal(arg));
+ } else {
+ ioArg = (INT)(__ByteArrayInstPtr(arg)->ba_element);
+ }
+ ret = ioctl(fileno(f), ioNum, ioArg);
+ } while ((ret < 0) && (__threadErrno == EINTR));
+ __END_INTERRUPTABLE__
+
+ if (ret >= 0) {
+ RETURN ( __MKSMALLINT(ret) );
+ }
+ __INST(position) = nil; /* i.e. do not know */
+ __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
+ }
}
# endif
#endif
@@ -3067,45 +3067,45 @@
off_t truncateSize;
if (((fp = __INST(filePointer)) != nil)
- && (__INST(mode) != @symbol(readonly))) {
- if (__isSmallInteger(newSize)) {
- truncateSize = __intVal(newSize);
- if (truncateSize < 0) {
- goto getOutOfHere;
- }
- } else {
- truncateSize = __signedLongIntVal(newSize);
- if (truncateSize < 0) {
- goto getOutOfHere;
- }
- if (truncateSize == 0) {
- if (sizeof(truncateSize) == 8) {
- if (__signedLong64IntVal(newSize, &truncateSize) == 0 || truncateSize < 0) {
- goto getOutOfHere;
- }
- } else {
- goto getOutOfHere;
- }
- }
- }
-
- f = __FILEVal(fp);
-
- if (__INST(buffered) == true) {
- __READING__(f)
- FFLUSH(f);
- OPT_FSEEK(f, 0L, SEEK_END); /* needed in stdio */
- }
- ftruncate(fileno(f), truncateSize);
- RETURN (self);
+ && (__INST(mode) != @symbol(readonly))) {
+ if (__isSmallInteger(newSize)) {
+ truncateSize = __intVal(newSize);
+ if (truncateSize < 0) {
+ goto getOutOfHere;
+ }
+ } else {
+ truncateSize = __signedLongIntVal(newSize);
+ if (truncateSize < 0) {
+ goto getOutOfHere;
+ }
+ if (truncateSize == 0) {
+ if (sizeof(truncateSize) == 8) {
+ if (__signedLong64IntVal(newSize, &truncateSize) == 0 || truncateSize < 0) {
+ goto getOutOfHere;
+ }
+ } else {
+ goto getOutOfHere;
+ }
+ }
+ }
+
+ f = __FILEVal(fp);
+
+ if (__INST(buffered) == true) {
+ __READING__(f)
+ FFLUSH(f);
+ OPT_FSEEK(f, 0L, SEEK_END); /* needed in stdio */
+ }
+ ftruncate(fileno(f), truncateSize);
+ RETURN (self);
}
-getOutOfHere:
+getOutOfHere: ;
#endif
%}.
filePointer isNil ifTrue:[self errorNotOpen. ^ self].
(mode == #readonly) ifTrue:[self errorReadOnly. ^ self].
newSize < 0 ifTrue:[
- self error:'wrong arg'.
+ self error:'wrong arg'.
].
self errorUnsupportedOperation
@@ -3191,88 +3191,88 @@
__INST(lastErrorNumber) = nil;
if (((fp = __INST(filePointer)) != nil)
- && (__INST(mode) != @symbol(writeonly))
- && __bothSmallInteger(count, start)
+ && (__INST(mode) != @symbol(writeonly))
+ && __bothSmallInteger(count, start)
) {
- f = __FILEVal(fp);
-
- cnt = __intVal(count);
- offs = __intVal(start) - 1;
-
- if (__isExternalBytesLike(anObject)) {
- OBJ sz;
-
- nInstBytes = 0;
- extPtr = (char *)(__externalBytesAddress(anObject));
- sz = __externalBytesSize(anObject);
- if (__isSmallInteger(sz)) {
- objSize = __intVal(sz);
- } else {
- objSize = 0; /* unknown */
- }
- } else {
- OBJ oClass;
-
- oClass = __Class(anObject);
- switch (__intVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
- case BYTEARRAY:
- case WORDARRAY:
- case LONGARRAY:
- case SWORDARRAY:
- case SLONGARRAY:
- case FLOATARRAY:
- case DOUBLEARRAY:
- break;
- default:
- goto bad;
- }
- extPtr = (char *)0;
- nInstVars = __intVal(__ClassInstPtr(oClass)->c_ninstvars);
- nInstBytes = OHDR_SIZE + __OBJS2BYTES__(nInstVars);
- objSize = __Size(anObject) - nInstBytes;
- }
-
- if ((offs >= 0) && (cnt >= 0) && (objSize >= (cnt + offs))) {
- _buffered = (__INST(buffered) == true);
- if (_buffered) {
- __READING__(f);
- }
-
- if (extPtr) {
- __READAVAILBYTES__(ret, f, extPtr+offs, cnt, _buffered);
- } else {
- /*
- * on interrupt, anObject may be moved to another location.
- * So we pass (char *)__InstPtr(anObject) + nInstBytes + offs to the macro __READ_BYTES__,
- * to get a new address.
- */
- offs += nInstBytes;
- __READAVAILBYTES_OBJ__(ret, f, anObject, offs, cnt, _buffered);
- }
+ f = __FILEVal(fp);
+
+ cnt = __intVal(count);
+ offs = __intVal(start) - 1;
+
+ if (__isExternalBytesLike(anObject)) {
+ OBJ sz;
+
+ nInstBytes = 0;
+ extPtr = (char *)(__externalBytesAddress(anObject));
+ sz = __externalBytesSize(anObject);
+ if (__isSmallInteger(sz)) {
+ objSize = __intVal(sz);
+ } else {
+ objSize = 0; /* unknown */
+ }
+ } else {
+ OBJ oClass;
+
+ oClass = __Class(anObject);
+ switch (__intVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
+ case BYTEARRAY:
+ case WORDARRAY:
+ case LONGARRAY:
+ case SWORDARRAY:
+ case SLONGARRAY:
+ case FLOATARRAY:
+ case DOUBLEARRAY:
+ break;
+ default:
+ goto bad;
+ }
+ extPtr = (char *)0;
+ nInstVars = __intVal(__ClassInstPtr(oClass)->c_ninstvars);
+ nInstBytes = OHDR_SIZE + __OBJS2BYTES__(nInstVars);
+ objSize = __Size(anObject) - nInstBytes;
+ }
+
+ if ((offs >= 0) && (cnt >= 0) && (objSize >= (cnt + offs))) {
+ _buffered = (__INST(buffered) == true);
+ if (_buffered) {
+ __READING__(f);
+ }
+
+ if (extPtr) {
+ __READAVAILBYTES__(ret, f, extPtr+offs, cnt, _buffered);
+ } else {
+ /*
+ * on interrupt, anObject may be moved to another location.
+ * So we pass (char *)__InstPtr(anObject) + nInstBytes + offs to the macro __READ_BYTES__,
+ * to get a new address.
+ */
+ offs += nInstBytes;
+ __READAVAILBYTES_OBJ__(ret, f, anObject, offs, cnt, _buffered);
+ }
#ifdef PRE_22_jan_2000
- if (ret > 0)
+ if (ret > 0)
#else
- /* 0 is NOT an EOF condition here ... */
- if (ret >= 0)
+ /* 0 is NOT an EOF condition here ... */
+ if (ret >= 0)
#endif
- {
- if (__isSmallInteger(__INST(position))) {
- INT np = __intVal(__INST(position)) + ret;
- OBJ t;
-
- __INST(position) = t = __MKINT(np); __STORE(self, t);
- } else {
- __INST(position) = nil; /* i.e. do not know */
- }
- RETURN (__MKSMALLINT(ret));
- }
- if (ret == 0) {
- __INST(hitEOF) = true;
- } else /* ret < 0 */ {
- __INST(position) = nil;
- __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
- }
- }
+ {
+ if (__isSmallInteger(__INST(position))) {
+ INT np = __intVal(__INST(position)) + ret;
+ OBJ t;
+
+ __INST(position) = t = __MKINT(np); __STORE(self, t);
+ } else {
+ __INST(position) = nil; /* i.e. do not know */
+ }
+ RETURN (__MKSMALLINT(ret));
+ }
+ if (ret == 0) {
+ __INST(hitEOF) = true;
+ } else /* ret < 0 */ {
+ __INST(position) = nil;
+ __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
+ }
+ }
}
bad: ;
%}.
@@ -3300,31 +3300,31 @@
__INST(lastErrorNumber) = nil;
if (((fp = __INST(filePointer)) != nil)
&& (__INST(mode) != @symbol(writeonly))) {
- f = __FILEVal(fp);
-
- _buffered = (__INST(buffered) == true);
- if (_buffered) {
- __READING__(f)
- }
- __READBYTE__(ret, f, &byte, _buffered);
- if (ret > 0) {
- 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 (__MKSMALLINT(byte));
- }
-
- if (ret == 0) {
- __INST(hitEOF) = true;
- } else /* ret < 0 */ {
- __INST(position) = nil;
- __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
- }
+ f = __FILEVal(fp);
+
+ _buffered = (__INST(buffered) == true);
+ if (_buffered) {
+ __READING__(f)
+ }
+ __READBYTE__(ret, f, &byte, _buffered);
+ if (ret > 0) {
+ 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 (__MKSMALLINT(byte));
+ }
+
+ if (ret == 0) {
+ __INST(hitEOF) = true;
+ } else /* ret < 0 */ {
+ __INST(position) = nil;
+ __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
+ }
}
%}.
hitEOF ifTrue:[^ self pastEnd].
@@ -3367,81 +3367,81 @@
__INST(lastErrorNumber) = nil;
if (((fp = __INST(filePointer)) != nil)
- && (__INST(mode) != @symbol(writeonly))
- && __bothSmallInteger(count, start)
+ && (__INST(mode) != @symbol(writeonly))
+ && __bothSmallInteger(count, start)
) {
- f = __FILEVal(fp);
-
- cnt = __intVal(count);
- offs = __intVal(start) - 1;
-
- if (__isExternalBytesLike(anObject)) {
- OBJ sz;
-
- nInstBytes = 0;
- extPtr = (char *)(__externalBytesAddress(anObject));
- sz = __externalBytesSize(anObject);
- if (__isSmallInteger(sz)) {
- objSize = __intVal(sz);
- } else {
- objSize = 0; /* unknown */
- }
- } else {
- OBJ oClass;
-
- oClass = __Class(anObject);
- switch (__intVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
- case BYTEARRAY:
- case WORDARRAY:
- case LONGARRAY:
- case SWORDARRAY:
- case SLONGARRAY:
- case FLOATARRAY:
- case DOUBLEARRAY:
- break;
- default:
- goto bad;
- }
- extPtr = (char *)0;
- nInstVars = __intVal(__ClassInstPtr(oClass)->c_ninstvars);
- nInstBytes = OHDR_SIZE + __OBJS2BYTES__(nInstVars);
- objSize = __Size(anObject) - nInstBytes;
- }
- if ((offs >= 0) && (cnt >= 0) && (objSize >= (cnt + offs))) {
- _buffered = (__INST(buffered) == true);
- if (_buffered) {
- __READING__(f);
- }
-
- if (extPtr) {
- __READBYTES__(ret, f, extPtr+offs, cnt, _buffered);
- } else {
- /*
- * on interrupt, anObject may be moved to another location.
- * So we pass anObject, and the offset to the __READBYTES_OBJ__ macro.
- */
- offs += nInstBytes;
- __READBYTES_OBJ__(ret, f, anObject, offs, cnt, _buffered);
- }
-
- if (ret > 0) {
- if (__isSmallInteger(__INST(position))) {
- INT np = __intVal(__INST(position)) + ret;
- OBJ t;
-
- __INST(position) = t = __MKINT(np); __STORE(self, t);
- } else {
- __INST(position) = nil; /* i.e. do not know */
- }
- RETURN (__MKSMALLINT(ret));
- }
- if (ret == 0) {
- __INST(hitEOF) = true;
- } else /* ret < 0 */ {
- __INST(position) = nil;
- __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
- }
- }
+ f = __FILEVal(fp);
+
+ cnt = __intVal(count);
+ offs = __intVal(start) - 1;
+
+ if (__isExternalBytesLike(anObject)) {
+ OBJ sz;
+
+ nInstBytes = 0;
+ extPtr = (char *)(__externalBytesAddress(anObject));
+ sz = __externalBytesSize(anObject);
+ if (__isSmallInteger(sz)) {
+ objSize = __intVal(sz);
+ } else {
+ objSize = 0; /* unknown */
+ }
+ } else {
+ OBJ oClass;
+
+ oClass = __Class(anObject);
+ switch (__intVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
+ case BYTEARRAY:
+ case WORDARRAY:
+ case LONGARRAY:
+ case SWORDARRAY:
+ case SLONGARRAY:
+ case FLOATARRAY:
+ case DOUBLEARRAY:
+ break;
+ default:
+ goto bad;
+ }
+ extPtr = (char *)0;
+ nInstVars = __intVal(__ClassInstPtr(oClass)->c_ninstvars);
+ nInstBytes = OHDR_SIZE + __OBJS2BYTES__(nInstVars);
+ objSize = __Size(anObject) - nInstBytes;
+ }
+ if ((offs >= 0) && (cnt >= 0) && (objSize >= (cnt + offs))) {
+ _buffered = (__INST(buffered) == true);
+ if (_buffered) {
+ __READING__(f);
+ }
+
+ if (extPtr) {
+ __READBYTES__(ret, f, extPtr+offs, cnt, _buffered);
+ } else {
+ /*
+ * on interrupt, anObject may be moved to another location.
+ * So we pass anObject, and the offset to the __READBYTES_OBJ__ macro.
+ */
+ offs += nInstBytes;
+ __READBYTES_OBJ__(ret, f, anObject, offs, cnt, _buffered);
+ }
+
+ if (ret > 0) {
+ if (__isSmallInteger(__INST(position))) {
+ INT np = __intVal(__INST(position)) + ret;
+ OBJ t;
+
+ __INST(position) = t = __MKINT(np); __STORE(self, t);
+ } else {
+ __INST(position) = nil; /* i.e. do not know */
+ }
+ RETURN (__MKSMALLINT(ret));
+ }
+ if (ret == 0) {
+ __INST(hitEOF) = true;
+ } else /* ret < 0 */ {
+ __INST(position) = nil;
+ __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
+ }
+ }
}
bad: ;
%}.
@@ -3476,67 +3476,67 @@
__INST(lastErrorNumber) = nil;
if (((fp = __INST(filePointer)) != nil)
- && (__INST(mode) != @symbol(writeonly))
+ && (__INST(mode) != @symbol(writeonly))
) {
- FILEPOINTER f;
- int ret, _buffered;
- int value;
- union {
- unsigned char buffer[4];
- int intVal;
- } u;
-
- f = __FILEVal(fp);
- _buffered = (__INST(buffered) == true);
- if (_buffered) {
- __READING__(f)
- }
- __READBYTES__(ret, f, u.buffer, 4, _buffered);
-
- if (ret == 4) {
- if (__isSmallInteger(__INST(position))) {
- INT np = __intVal(__INST(position)) + 4;
- OBJ t;
-
- __INST(position) = t = __MKINT(np); __STORE(self, t);
- } else {
- __INST(position) = nil; /* i.e. do not know */
- }
- if (msbFlag == true) {
+ FILEPOINTER f;
+ int ret, _buffered;
+ int value;
+ union {
+ unsigned char buffer[4];
+ int intVal;
+ } u;
+
+ f = __FILEVal(fp);
+ _buffered = (__INST(buffered) == true);
+ if (_buffered) {
+ __READING__(f)
+ }
+ __READBYTES__(ret, f, u.buffer, 4, _buffered);
+
+ if (ret == 4) {
+ if (__isSmallInteger(__INST(position))) {
+ INT np = __intVal(__INST(position)) + 4;
+ OBJ t;
+
+ __INST(position) = t = __MKINT(np); __STORE(self, t);
+ } else {
+ __INST(position) = nil; /* i.e. do not know */
+ }
+ if (msbFlag == true) {
#if defined(__MSBFIRST)
- value = u.intVal;
+ value = u.intVal;
#else
- value = (u.buffer[0] & 0xFF);
- value = (value << 8) | (u.buffer[1] & 0xFF);
- value = (value << 8) | (u.buffer[2] & 0xFF);
- value = (value << 8) | (u.buffer[3] & 0xFF);
+ value = (u.buffer[0] & 0xFF);
+ value = (value << 8) | (u.buffer[1] & 0xFF);
+ value = (value << 8) | (u.buffer[2] & 0xFF);
+ value = (value << 8) | (u.buffer[3] & 0xFF);
#endif
- } else {
+ } else {
#if defined(__LSBFIRST)
- value = u.intVal;
+ value = u.intVal;
#else
- value = (u.buffer[3] & 0xFF);
- value = (value << 8) | (u.buffer[2] & 0xFF);
- value = (value << 8) | (u.buffer[1] & 0xFF);
- value = (value << 8) | (u.buffer[0] & 0xFF);
+ value = (u.buffer[3] & 0xFF);
+ value = (value << 8) | (u.buffer[2] & 0xFF);
+ value = (value << 8) | (u.buffer[1] & 0xFF);
+ value = (value << 8) | (u.buffer[0] & 0xFF);
#endif
- }
+ }
#ifdef alpha64
- RETURN ( __MKSMALLINT(value));
+ RETURN ( __MKSMALLINT(value));
#else
- if ((value >= _MIN_INT) && (value <= _MAX_INT)) {
- RETURN ( __MKSMALLINT(value));
- }
- RETURN ( __MKLARGEINT(value) );
+ if ((value >= _MIN_INT) && (value <= _MAX_INT)) {
+ RETURN ( __MKSMALLINT(value));
+ }
+ RETURN ( __MKLARGEINT(value) );
#endif
- }
-
- if (ret < 0) {
- __INST(position) = nil;
- __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
- } else /* ret == 0 */ {
- __INST(hitEOF) = true;
- }
+ }
+
+ if (ret < 0) {
+ __INST(position) = nil;
+ __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
+ } else /* ret == 0 */ {
+ __INST(hitEOF) = true;
+ }
}
%}.
hitEOF ifTrue:[^ self pastEnd].
@@ -3557,54 +3557,54 @@
__INST(lastErrorNumber) = nil;
if (((fp = __INST(filePointer)) != nil)
- && (__INST(mode) != @symbol(writeonly))
+ && (__INST(mode) != @symbol(writeonly))
) {
- FILEPOINTER f;
- int ret, _buffered;
- short value;
- union {
- unsigned char buffer[2];
- short shortVal;
- } u;
-
- f = __FILEVal(fp);
- _buffered = (__INST(buffered) == true);
- if (_buffered) {
- __READING__(f)
- }
- __READBYTES__(ret, f, u.buffer, 2, _buffered);
-
- if (ret == 2) {
- if (__isSmallInteger(__INST(position))) {
- INT np = __intVal(__INST(position)) + 2;
- OBJ t;
-
- __INST(position) = t = __MKINT(np); __STORE(self, t);
- } else {
- __INST(position) = nil; /* i.e. do not know */
- }
- if (msbFlag == true) {
+ FILEPOINTER f;
+ int ret, _buffered;
+ short value;
+ union {
+ unsigned char buffer[2];
+ short shortVal;
+ } u;
+
+ f = __FILEVal(fp);
+ _buffered = (__INST(buffered) == true);
+ if (_buffered) {
+ __READING__(f)
+ }
+ __READBYTES__(ret, f, u.buffer, 2, _buffered);
+
+ if (ret == 2) {
+ if (__isSmallInteger(__INST(position))) {
+ INT np = __intVal(__INST(position)) + 2;
+ OBJ t;
+
+ __INST(position) = t = __MKINT(np); __STORE(self, t);
+ } else {
+ __INST(position) = nil; /* i.e. do not know */
+ }
+ if (msbFlag == true) {
#if defined(__MSBFIRST)
- value = u.shortVal;
+ value = u.shortVal;
#else
- value = ((u.buffer[0] & 0xFF) << 8) | (u.buffer[1] & 0xFF);
+ value = ((u.buffer[0] & 0xFF) << 8) | (u.buffer[1] & 0xFF);
#endif
- } else {
+ } else {
#if defined(__LSBFIRST)
- value = u.shortVal;
+ value = u.shortVal;
#else
- value = ((u.buffer[1] & 0xFF) << 8) | (u.buffer[0] & 0xFF);
+ value = ((u.buffer[1] & 0xFF) << 8) | (u.buffer[0] & 0xFF);
#endif
- }
- RETURN (__MKSMALLINT(value));
- }
-
- if (ret < 0) {
- __INST(position) = nil; /* i.e. do not know */
- __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
- } else /* ret == 0 */ {
- __INST(hitEOF) = true;
- }
+ }
+ RETURN (__MKSMALLINT(value));
+ }
+
+ if (ret < 0) {
+ __INST(position) = nil; /* i.e. do not know */
+ __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
+ } else /* ret == 0 */ {
+ __INST(hitEOF) = true;
+ }
}
%}.
hitEOF ifTrue:[^ self pastEnd].
@@ -3626,68 +3626,68 @@
__INST(lastErrorNumber) = nil;
if (((fp = __INST(filePointer)) != nil)
- && (__INST(mode) != @symbol(writeonly))
+ && (__INST(mode) != @symbol(writeonly))
) {
- FILEPOINTER f;
- int ret, _buffered;
- unsigned INT value;
- union {
- unsigned char buffer[4];
- unsigned int intVal;
- } u;
-
- f = __FILEVal(fp);
- _buffered = (__INST(buffered) == true);
- if (_buffered) {
- __READING__(f)
- }
- __READBYTES__(ret, f, u.buffer, 4, _buffered);
-
- if (ret == 4) {
- if (__isSmallInteger(__INST(position))) {
- INT np = __intVal(__INST(position)) + 4;
- OBJ t;
-
- __INST(position) = t = __MKINT(np); __STORE(self, t);
- } else {
- __INST(position) = nil; /* i.e. do not know */
- }
- if (msbFlag == true) {
+ FILEPOINTER f;
+ int ret, _buffered;
+ unsigned INT value;
+ union {
+ unsigned char buffer[4];
+ unsigned int intVal;
+ } u;
+
+ f = __FILEVal(fp);
+ _buffered = (__INST(buffered) == true);
+ if (_buffered) {
+ __READING__(f)
+ }
+ __READBYTES__(ret, f, u.buffer, 4, _buffered);
+
+ if (ret == 4) {
+ if (__isSmallInteger(__INST(position))) {
+ INT np = __intVal(__INST(position)) + 4;
+ OBJ t;
+
+ __INST(position) = t = __MKINT(np); __STORE(self, t);
+ } else {
+ __INST(position) = nil; /* i.e. do not know */
+ }
+ if (msbFlag == true) {
#if defined(__MSBFIRST)
- value = u.intVal;
+ value = u.intVal;
#else
- value = u.buffer[0];
- value = (value << 8) | u.buffer[1];
- value = (value << 8) | u.buffer[2];
- value = (value << 8) | u.buffer[3];
+ value = u.buffer[0];
+ value = (value << 8) | u.buffer[1];
+ value = (value << 8) | u.buffer[2];
+ value = (value << 8) | u.buffer[3];
#endif
- } else {
+ } else {
#if defined(__LSBFIRST)
- value = u.intVal;
+ value = u.intVal;
#else
- value = u.buffer[3];
- value = (value << 8) | u.buffer[2];
- value = (value << 8) | u.buffer[1];
- value = (value << 8) | u.buffer[0];
+ value = u.buffer[3];
+ value = (value << 8) | u.buffer[2];
+ value = (value << 8) | u.buffer[1];
+ value = (value << 8) | u.buffer[0];
#endif
- }
+ }
#ifdef alpha64
- value &= 0xFFFFFFFF;
- RETURN (__MKSMALLINT(value));
+ value &= 0xFFFFFFFF;
+ RETURN (__MKSMALLINT(value));
#else
- if (value <= _MAX_INT) {
- RETURN (__MKSMALLINT(value));
- }
- RETURN (__MKULARGEINT(value) );
+ if (value <= _MAX_INT) {
+ RETURN (__MKSMALLINT(value));
+ }
+ RETURN (__MKULARGEINT(value) );
#endif
- }
-
- if (ret < 0) {
- __INST(position) = nil; /* i.e. do not know */
- __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
- } else /* ret == 0 */ {
- __INST(hitEOF) = true;
- }
+ }
+
+ if (ret < 0) {
+ __INST(position) = nil; /* i.e. do not know */
+ __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
+ } else /* ret == 0 */ {
+ __INST(hitEOF) = true;
+ }
}
%}.
hitEOF ifTrue:[^ self pastEnd].
@@ -3708,54 +3708,54 @@
__INST(lastErrorNumber) = nil;
if (((fp = __INST(filePointer)) != nil)
- && (__INST(mode) != @symbol(writeonly))
+ && (__INST(mode) != @symbol(writeonly))
) {
- FILEPOINTER f;
- int ret, _buffered;
- unsigned int value;
- union {
- unsigned char buffer[2];
- unsigned short shortVal;
- } u;
-
- f = __FILEVal(fp);
- _buffered = (__INST(buffered) == true);
- if (_buffered) {
- __READING__(f)
- }
- __READBYTES__(ret, f, u.buffer, 2, _buffered);
-
- if (ret == 2) {
- if (__isSmallInteger(__INST(position))) {
- INT np = __intVal(__INST(position)) + 2;
- OBJ t;
-
- __INST(position) = t = __MKINT(np); __STORE(self, t);
- } else {
- __INST(position) = nil; /* i.e. do not know */
- }
- if (msbFlag == true) {
+ FILEPOINTER f;
+ int ret, _buffered;
+ unsigned int value;
+ union {
+ unsigned char buffer[2];
+ unsigned short shortVal;
+ } u;
+
+ f = __FILEVal(fp);
+ _buffered = (__INST(buffered) == true);
+ if (_buffered) {
+ __READING__(f)
+ }
+ __READBYTES__(ret, f, u.buffer, 2, _buffered);
+
+ if (ret == 2) {
+ if (__isSmallInteger(__INST(position))) {
+ INT np = __intVal(__INST(position)) + 2;
+ OBJ t;
+
+ __INST(position) = t = __MKINT(np); __STORE(self, t);
+ } else {
+ __INST(position) = nil; /* i.e. do not know */
+ }
+ if (msbFlag == true) {
#if defined(__MSBFIRST)
- value = u.shortVal;
+ value = u.shortVal;
#else
- value = (u.buffer[0] << 8) | u.buffer[1];
+ value = (u.buffer[0] << 8) | u.buffer[1];
#endif
- } else {
+ } else {
#if defined(__LSBFIRST)
- value = u.shortVal;
+ value = u.shortVal;
#else
- value = (u.buffer[1] << 8) | u.buffer[0];
+ value = (u.buffer[1] << 8) | u.buffer[0];
#endif
- }
- RETURN (__MKSMALLINT(value));
- }
-
- if (ret < 0) {
- __INST(position) = nil; /* i.e. do not know */
- __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
- } else /* ret == 0 */ {
- __INST(hitEOF) = true;
- }
+ }
+ RETURN (__MKSMALLINT(value));
+ }
+
+ if (ret < 0) {
+ __INST(position) = nil; /* i.e. do not know */
+ __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
+ } else /* ret == 0 */ {
+ __INST(hitEOF) = true;
+ }
}
%}.
hitEOF ifTrue:[^ self pastEnd].
@@ -3792,31 +3792,31 @@
__INST(lastErrorNumber) = nil;
if (((fp = __INST(filePointer)) != nil)
- && (__INST(mode) != @symbol(readonly))
- && __isSmallInteger(aByteValue)
+ && (__INST(mode) != @symbol(readonly))
+ && __isSmallInteger(aByteValue)
) {
- c = __intVal(aByteValue);
- f = __FILEVal(fp);
- 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);
- }
- if (cnt < 0) {
- __INST(position) = nil; /* i.e. do not know */
- }
- __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
+ c = __intVal(aByteValue);
+ f = __FILEVal(fp);
+ 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);
+ }
+ if (cnt < 0) {
+ __INST(position) = nil; /* i.e. do not know */
+ }
+ __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
}
%}.
filePointer isNil ifTrue:[self errorNotOpen. ^ self].
@@ -3833,9 +3833,9 @@
Use with care - non object oriented i/o.
Warning:
- in general, you cannot use this method to pass non-byte data to other
- architectures (unless you prepared the buffer with care),
- since it does not care for byte order or float representation."
+ in general, you cannot use this method to pass non-byte data to other
+ architectures (unless you prepared the buffer with care),
+ since it does not care for byte order or float representation."
%{
FILEPOINTER f;
@@ -3846,78 +3846,78 @@
__INST(lastErrorNumber) = nil;
if (((fp = __INST(filePointer)) != nil)
- && (__INST(mode) != @symbol(readonly))
- && __bothSmallInteger(count, start)
+ && (__INST(mode) != @symbol(readonly))
+ && __bothSmallInteger(count, start)
) {
- len = __intVal(count);
- offs = __intVal(start) - 1;
- f = __FILEVal(fp);
-
- if (__isExternalBytesLike(anObject)) {
- OBJ sz;
-
- nInstBytes = 0;
- extPtr = (char *)__externalBytesAddress(anObject);
- sz = __externalBytesSize(anObject);
- if (__isSmallInteger(sz)) {
- objSize = __intVal(sz);
- } else {
- objSize = 0; /* unknown */
- }
- } else {
- OBJ oClass;
-
- oClass = __Class(anObject);
- switch (__intVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
- case BYTEARRAY:
- case WORDARRAY:
- case LONGARRAY:
- case SWORDARRAY:
- case SLONGARRAY:
- case FLOATARRAY:
- case DOUBLEARRAY:
- break;
- default:
- goto bad;
- }
- extPtr = (char *)0;
- nInstVars = __intVal(__ClassInstPtr(oClass)->c_ninstvars);
- nInstBytes = OHDR_SIZE + __OBJS2BYTES__(nInstVars);
- objSize = __Size(anObject) - nInstBytes;
- }
- if ( (offs >= 0) && (len >= 0) && (objSize >= (len + offs)) ) {
- if (_buffered = (__INST(buffered) == true)) {
- __WRITING__(f)
- }
-
- if (extPtr) {
- __WRITEBYTES__(cnt, f, extPtr+offs, len, _buffered);
- } else {
- /*
- * on interrupt, anObject may be moved to another location.
- * So we pass anObject, and the offset to the __WRITEBYTES_OBJ__ macro.
- */
- offs += nInstBytes;
- __WRITEBYTES_OBJ__(cnt, f, anObject, offs, len, _buffered);
- }
-
- if (cnt >= 0) {
- if (__isSmallInteger(__INST(position))) {
- INT np = __intVal(__INST(position)) + cnt;
- OBJ t;
-
- __INST(position) = t = __MKINT(np); __STORE(self, t);
- } else {
- __INST(position) = nil; /* i.e. do not know */
- }
- RETURN ( __MKSMALLINT(cnt) );
- }
- if ((__threadErrno == EWOULDBLOCK) || ((__threadErrno == EAGAIN))) {
- RETURN ( __MKSMALLINT(0) );
- }
- __INST(position) = nil; /* i.e. do not know */
- __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
- }
+ len = __intVal(count);
+ offs = __intVal(start) - 1;
+ f = __FILEVal(fp);
+
+ if (__isExternalBytesLike(anObject)) {
+ OBJ sz;
+
+ nInstBytes = 0;
+ extPtr = (char *)__externalBytesAddress(anObject);
+ sz = __externalBytesSize(anObject);
+ if (__isSmallInteger(sz)) {
+ objSize = __intVal(sz);
+ } else {
+ objSize = 0; /* unknown */
+ }
+ } else {
+ OBJ oClass;
+
+ oClass = __Class(anObject);
+ switch (__intVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
+ case BYTEARRAY:
+ case WORDARRAY:
+ case LONGARRAY:
+ case SWORDARRAY:
+ case SLONGARRAY:
+ case FLOATARRAY:
+ case DOUBLEARRAY:
+ break;
+ default:
+ goto bad;
+ }
+ extPtr = (char *)0;
+ nInstVars = __intVal(__ClassInstPtr(oClass)->c_ninstvars);
+ nInstBytes = OHDR_SIZE + __OBJS2BYTES__(nInstVars);
+ objSize = __Size(anObject) - nInstBytes;
+ }
+ if ( (offs >= 0) && (len >= 0) && (objSize >= (len + offs)) ) {
+ if (_buffered = (__INST(buffered) == true)) {
+ __WRITING__(f)
+ }
+
+ if (extPtr) {
+ __WRITEBYTES__(cnt, f, extPtr+offs, len, _buffered);
+ } else {
+ /*
+ * on interrupt, anObject may be moved to another location.
+ * So we pass anObject, and the offset to the __WRITEBYTES_OBJ__ macro.
+ */
+ offs += nInstBytes;
+ __WRITEBYTES_OBJ__(cnt, f, anObject, offs, len, _buffered);
+ }
+
+ if (cnt >= 0) {
+ if (__isSmallInteger(__INST(position))) {
+ INT np = __intVal(__INST(position)) + cnt;
+ OBJ t;
+
+ __INST(position) = t = __MKINT(np); __STORE(self, t);
+ } else {
+ __INST(position) = nil; /* i.e. do not know */
+ }
+ RETURN ( __MKSMALLINT(cnt) );
+ }
+ if ((__threadErrno == EWOULDBLOCK) || ((__threadErrno == EAGAIN))) {
+ RETURN ( __MKSMALLINT(0) );
+ }
+ __INST(position) = nil; /* i.e. do not know */
+ __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
+ }
}
bad: ;
%}.
@@ -3936,8 +3936,8 @@
%{
int num;
union {
- char bytes[4];
- int intVal;
+ char bytes[4];
+ int intVal;
} u;
FILEPOINTER f;
int cnt, _buffered;
@@ -3945,66 +3945,66 @@
__INST(lastErrorNumber) = nil;
if (__isSmallInteger(aNumber)) {
- num = __intVal(aNumber);
+ num = __intVal(aNumber);
} else {
#ifdef alpha64
- goto badArg;
+ 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
}
if (((fp = __INST(filePointer)) != nil)
&& (__INST(mode) != @symbol(readonly))
) {
- if (msbFlag == true) {
+ 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
- }
-
- f = __FILEVal(fp);
- if (_buffered = (__INST(buffered) == true)) {
- __WRITING__(f)
- }
- __WRITEBYTES__(cnt, f, u.bytes, 4, _buffered);
-
- if (cnt == 4) {
- if (__isSmallInteger(__INST(position))) {
- INT np = __intVal(__INST(position)) + 4;
- OBJ t;
-
- __INST(position) = t = __MKINT(np); __STORE(self, t);
- } else {
- __INST(position) = nil; /* i.e. do not know */
- }
- RETURN ( self );
- }
- __INST(position) = nil; /* i.e. do not know */
- __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
+ }
+
+ f = __FILEVal(fp);
+ if (_buffered = (__INST(buffered) == true)) {
+ __WRITING__(f)
+ }
+ __WRITEBYTES__(cnt, f, u.bytes, 4, _buffered);
+
+ if (cnt == 4) {
+ if (__isSmallInteger(__INST(position))) {
+ INT np = __intVal(__INST(position)) + 4;
+ OBJ t;
+
+ __INST(position) = t = __MKINT(np); __STORE(self, t);
+ } else {
+ __INST(position) = nil; /* i.e. do not know */
+ }
+ RETURN ( self );
+ }
+ __INST(position) = nil; /* i.e. do not know */
+ __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
}
badArg: ;
%}.
@@ -4013,7 +4013,7 @@
lastErrorNumber notNil ifTrue:[self writeError. ^ self].
aNumber isInteger ifTrue:[
- ^ super nextPutLong:aNumber MSB:msbFlag
+ ^ super nextPutLong:aNumber MSB:msbFlag
].
self argumentMustBeInteger
!
@@ -4027,8 +4027,8 @@
%{
int num;
union {
- char bytes[2];
- short shortVal;
+ char bytes[2];
+ short shortVal;
} u;
FILEPOINTER f;
@@ -4037,45 +4037,45 @@
__INST(lastErrorNumber) = nil;
if (((fp = __INST(filePointer)) != nil)
- && (__INST(mode) != @symbol(readonly))
- && __isSmallInteger(aNumber)
+ && (__INST(mode) != @symbol(readonly))
+ && __isSmallInteger(aNumber)
) {
- num = __intVal(aNumber);
- if (msbFlag == true) {
+ num = __intVal(aNumber);
+ 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
- }
-
- f = __FILEVal(fp);
- if (_buffered = (__INST(buffered) == true)) {
- __WRITING__(f)
- }
- __WRITEBYTES__(cnt, f, u.bytes, 2, _buffered);
-
- if (cnt == 2) {
- if (__isSmallInteger(__INST(position))) {
- INT np = __intVal(__INST(position)) + 2;
- OBJ t;
-
- __INST(position) = t = __MKINT(np); __STORE(self, t);
- } else {
- __INST(position) = nil; /* i.e. do not know */
- }
- RETURN ( self );
- }
- __INST(position) = nil; /* i.e. do not know */
- __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
+ }
+
+ f = __FILEVal(fp);
+ if (_buffered = (__INST(buffered) == true)) {
+ __WRITING__(f)
+ }
+ __WRITEBYTES__(cnt, f, u.bytes, 2, _buffered);
+
+ if (cnt == 2) {
+ if (__isSmallInteger(__INST(position))) {
+ INT np = __intVal(__INST(position)) + 2;
+ OBJ t;
+
+ __INST(position) = t = __MKINT(np); __STORE(self, t);
+ } else {
+ __INST(position) = nil; /* i.e. do not know */
+ }
+ RETURN ( self );
+ }
+ __INST(position) = nil; /* i.e. do not know */
+ __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
}
%}.
lastErrorNumber notNil ifTrue:[self writeError. ^ self.].
@@ -4262,37 +4262,37 @@
__INST(lastErrorNumber) = nil;
if (((fp = __INST(filePointer)) != nil)
- && (__INST(mode) != @symbol(writeonly))
+ && (__INST(mode) != @symbol(writeonly))
) {
- f = __FILEVal(fp);
-
- _buffered = (__INST(buffered) == true);
- if (_buffered) {
- __READING__(f)
- }
- __READBYTE__(ret, f, &ch, _buffered);
-
- if (ret > 0) {
- pos = __INST(position);
- if (__isSmallInteger(pos)) {
- OBJ t;
-
- __INST(position) = t = __MKINT(__intVal(pos) + 1); __STORE(self, t);
- } else {
- __INST(position) = nil; /* i.e. do not know */
- }
- if (__INST(binary) == true) {
- RETURN ( __MKSMALLINT(ch) );
- }
- RETURN ( __MKCHARACTER(ch) );
- }
-
- __INST(position) = nil;
- if (ret < 0) {
- __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
- } else /* ret == 0 */ {
- __INST(hitEOF) = true;
- }
+ f = __FILEVal(fp);
+
+ _buffered = (__INST(buffered) == true);
+ if (_buffered) {
+ __READING__(f)
+ }
+ __READBYTE__(ret, f, &ch, _buffered);
+
+ if (ret > 0) {
+ pos = __INST(position);
+ if (__isSmallInteger(pos)) {
+ OBJ t;
+
+ __INST(position) = t = __MKINT(__intVal(pos) + 1); __STORE(self, t);
+ } else {
+ __INST(position) = nil; /* i.e. do not know */
+ }
+ if (__INST(binary) == true) {
+ RETURN ( __MKSMALLINT(ch) );
+ }
+ RETURN ( __MKCHARACTER(ch) );
+ }
+
+ __INST(position) = nil;
+ if (ret < 0) {
+ __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
+ } else /* ret == 0 */ {
+ __INST(hitEOF) = true;
+ }
}
%}.
hitEOF == true ifTrue:[^ self pastEnd].
@@ -4301,16 +4301,16 @@
(mode == #writeonly) ifTrue:[^ self errorWriteOnly].
readAhead notNil ifTrue:[
- c := readAhead.
- readAhead := nil.
- ^ c.
+ c := readAhead.
+ readAhead := nil.
+ ^ c.
].
c := self nextByteFromFile:filePointer.
c isNil ifTrue:[
- ^ self pastEnd.
+ ^ self pastEnd.
].
binary == true ifTrue:[
- ^ c
+ ^ c
].
^ Character value:c
!
@@ -4451,71 +4451,71 @@
if (((fp = __INST(filePointer)) != nil)
&& (__INST(mode) != @symbol(writeonly))
) {
- f = __FILEVal(fp);
- _buffered = (__INST(buffered) == true);
- if (_buffered) {
- __READING__(f)
- }
-
- /*
- * skip whiteSpace first ...
- */
- do {
- __READBYTE__(ret, f, &ch, _buffered);
- if (ret > 0)
- cnt++;
- else
- break;
- } while (
+ f = __FILEVal(fp);
+ _buffered = (__INST(buffered) == true);
+ if (_buffered) {
+ __READING__(f)
+ }
+
+ /*
+ * skip whiteSpace first ...
+ */
+ do {
+ __READBYTE__(ret, f, &ch, _buffered);
+ if (ret > 0)
+ cnt++;
+ else
+ break;
+ } while (
#ifndef NON_ASCII
- (ch < ' ') ||
+ (ch < ' ') ||
#endif
- (ch == ' ' ) || (ch == '\t') || (ch == '\r')
- || (ch == '\n') || (ch == 0x0b));
-
- len = 0;
- while (ret > 0 &&
- (((ch >= 'a') && (ch <= 'z')) ||
- ((ch >= 'A') && (ch <= 'Z')) ||
- ((ch >= '0') && (ch <= '9')))
- ) {
- buffer[len++] = ch;
- if (len >= (sizeof(buffer)-1)) {
- /* emergency */
- break;
- }
- __READBYTE__(ret, f, &ch, _buffered);
- if (ret > 0)
- cnt++;
- else
- break;
- }
-
- if (ret <= 0) {
- if (ret < 0) {
- __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
- goto err;
- }
- else if (ret == 0)
- __INST(hitEOF) = true;
- } else {
- __UNGETC__(ch, f, _buffered);
- cnt--;
- }
-
- if (__isSmallInteger(__INST(position))) {
- INT np = __intVal(__INST(position)) + cnt;
- OBJ t;
-
- __INST(position) = t = __MKINT(np); __STORE(self, t);
- } else {
- __INST(position) = nil; /* i.e. do not know */
- }
-
- if (len != 0) {
- buffer[len] = '\0';
- RETURN ( __MKSTRING_L(buffer, len) );
- }
+ (ch == ' ' ) || (ch == '\t') || (ch == '\r')
+ || (ch == '\n') || (ch == 0x0b));
+
+ len = 0;
+ while (ret > 0 &&
+ (((ch >= 'a') && (ch <= 'z')) ||
+ ((ch >= 'A') && (ch <= 'Z')) ||
+ ((ch >= '0') && (ch <= '9')))
+ ) {
+ buffer[len++] = ch;
+ if (len >= (sizeof(buffer)-1)) {
+ /* emergency */
+ break;
+ }
+ __READBYTE__(ret, f, &ch, _buffered);
+ if (ret > 0)
+ cnt++;
+ else
+ break;
+ }
+
+ if (ret <= 0) {
+ if (ret < 0) {
+ __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
+ goto err;
+ }
+ else if (ret == 0)
+ __INST(hitEOF) = true;
+ } else {
+ __UNGETC__(ch, f, _buffered);
+ cnt--;
+ }
+
+ if (__isSmallInteger(__INST(position))) {
+ INT np = __intVal(__INST(position)) + cnt;
+ OBJ t;
+
+ __INST(position) = t = __MKINT(np); __STORE(self, t);
+ } else {
+ __INST(position) = nil; /* i.e. do not know */
+ }
+
+ if (len != 0) {
+ buffer[len] = '\0';
+ RETURN ( __MKSTRING_L(buffer, len) );
+ }
}
err: ;
%}.
@@ -4565,7 +4565,7 @@
_buffered = (__INST(buffered) == true);
if (_buffered) {
- __READING__(f)
+ __READING__(f)
}
/*
@@ -4573,27 +4573,27 @@
*/
c = '\n';
while (! done) {
- lastC = c;
- __READBYTE__(ret, f, &c, _buffered);
- if (ret <= 0) {
- goto err;
- }
- nread++;
- atBeginOfLine = 0;
- switch (c) {
- case '\n':
- case ' ':
- case '\t':
- case '\r':
- case '\b':
- case '\014':
- break;
-
- default:
- atBeginOfLine = (lastC == '\n');
- done = 1;
- break;
- }
+ lastC = c;
+ __READBYTE__(ret, f, &c, _buffered);
+ if (ret <= 0) {
+ goto err;
+ }
+ nread++;
+ atBeginOfLine = 0;
+ switch (c) {
+ case '\n':
+ case ' ':
+ case '\t':
+ case '\r':
+ case '\b':
+ case '\014':
+ break;
+
+ default:
+ atBeginOfLine = (lastC == '\n');
+ done = 1;
+ break;
+ }
}
/*
@@ -4604,96 +4604,96 @@
index = 0;
for (;;) {
- __READBYTE__(ret, f, &peekC, _buffered);
- if ((c == '%') && atBeginOfLine && ret > 0) {
- if (peekC == '{') {
- inPrimitive = 1;
- } else if (peekC == '}') {
- inPrimitive = 0;
- }
- } else if (c == '!' && !inPrimitive) {
- if (ret > 0 && peekC == '!') {
- /*
- * convert double-! to a single !
- */
- __READBYTE__(ret, f, &peekC, _buffered);
- if (ret > 0)
- nread++;
- } else {
- /*
- * End of chunk, push back lookahead character
- * and leave loop.
- */
- if (ret > 0) {
- __UNGETC__(peekC, f, _buffered);
- } else
- ret = 1;
- break;
- }
- }
-
- /*
- * do we have to resize the buffer ?
- */
- if ((index+2) >= currSize) {
- OBJ newBuffer;
- unsigned char *nbp;
-
- newBuffer = __MKEMPTYSTRING(currSize * 2);
- if (!fastFlag) {
- /*
- * refetch - buffer could be moved by GC
- */
- bufferPtr = __stringVal(buffer);
- }
- if (newBuffer == nil) {
- /*
- * mhmh - chunk seems to be very big ....
- */
- outOfMemory = true;
- goto err;
- }
- nbp = __stringVal(newBuffer);
- bcopy(bufferPtr, nbp, index);
- bufferPtr = nbp;
- bufferPtr[index] = '\0';
- buffer = newBuffer;
- fastFlag = 0;
- currSize = currSize * 2;
- }
-
- if (!fastFlag) {
- /*
- * old buffer may have moved (interrupt while reading)
- * - refetch pointer
- */
- bufferPtr = __stringVal(buffer);
- }
-
- /*
- * filter out cr-nl; make it nl
- */
- if (c == '\n') {
- haveNL = 1;
- if (index > 0) {
- if (bufferPtr[index-1] == '\r') {
- index--;
- }
- }
- } else {
- if (c == '\r') {
- haveCR = 1;
- }
- }
- bufferPtr[index++] = c;
- if (ret <= 0) {
- if (ret == 0)
- break; /* End of chunk reached */
- goto err;
- }
- nread++;
- atBeginOfLine = (c == '\n');
- c = peekC;
+ __READBYTE__(ret, f, &peekC, _buffered);
+ if ((c == '%') && atBeginOfLine && ret > 0) {
+ if (peekC == '{') {
+ inPrimitive = 1;
+ } else if (peekC == '}') {
+ inPrimitive = 0;
+ }
+ } else if (c == '!' && !inPrimitive) {
+ if (ret > 0 && peekC == '!') {
+ /*
+ * convert double-! to a single !
+ */
+ __READBYTE__(ret, f, &peekC, _buffered);
+ if (ret > 0)
+ nread++;
+ } else {
+ /*
+ * End of chunk, push back lookahead character
+ * and leave loop.
+ */
+ if (ret > 0) {
+ __UNGETC__(peekC, f, _buffered);
+ } else
+ ret = 1;
+ break;
+ }
+ }
+
+ /*
+ * do we have to resize the buffer ?
+ */
+ if ((index+2) >= currSize) {
+ OBJ newBuffer;
+ unsigned char *nbp;
+
+ newBuffer = __MKEMPTYSTRING(currSize * 2);
+ if (!fastFlag) {
+ /*
+ * refetch - buffer could be moved by GC
+ */
+ bufferPtr = __stringVal(buffer);
+ }
+ if (newBuffer == nil) {
+ /*
+ * mhmh - chunk seems to be very big ....
+ */
+ outOfMemory = true;
+ goto err;
+ }
+ nbp = __stringVal(newBuffer);
+ bcopy(bufferPtr, nbp, index);
+ bufferPtr = nbp;
+ bufferPtr[index] = '\0';
+ buffer = newBuffer;
+ fastFlag = 0;
+ currSize = currSize * 2;
+ }
+
+ if (!fastFlag) {
+ /*
+ * old buffer may have moved (interrupt while reading)
+ * - refetch pointer
+ */
+ bufferPtr = __stringVal(buffer);
+ }
+
+ /*
+ * filter out cr-nl; make it nl
+ */
+ if (c == '\n') {
+ haveNL = 1;
+ if (index > 0) {
+ if (bufferPtr[index-1] == '\r') {
+ index--;
+ }
+ }
+ } else {
+ if (c == '\r') {
+ haveCR = 1;
+ }
+ }
+ bufferPtr[index++] = c;
+ if (ret <= 0) {
+ if (ret == 0)
+ break; /* End of chunk reached */
+ goto err;
+ }
+ nread++;
+ atBeginOfLine = (c == '\n');
+ c = peekC;
}
/*
@@ -4701,13 +4701,13 @@
* Replace CR's by NL's
*/
if (!haveNL && haveCR) {
- int i;
-
- for (i=index-1; i>=0; i--) {
- if (bufferPtr[i] == '\r') {
- bufferPtr[i] = '\n';
- }
- }
+ int i;
+
+ for (i=index-1; i>=0; i--) {
+ if (bufferPtr[i] == '\r') {
+ bufferPtr[i] = '\n';
+ }
+ }
}
/*
@@ -4717,44 +4717,44 @@
* fast (C) buffer or from real (ST) buffer.
*/
if (fastFlag) {
- retVal = __MKSTRING_L(bufferPtr, index);
+ retVal = __MKSTRING_L(bufferPtr, index);
} else {
- retVal = __MKSTRING_ST_L(buffer, index);
+ retVal = __MKSTRING_ST_L(buffer, index);
}
err: ;
if (ret <= 0) {
- if (ret == 0)
- __INST(hitEOF) = true;
- else /* ret < 0 */
- __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
+ if (ret == 0)
+ __INST(hitEOF) = true;
+ else /* ret < 0 */
+ __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
}
if (__isSmallInteger(__INST(position))) {
- INT np = __intVal(__INST(position)) + nread;
- OBJ t;
-
- __INST(position) = t = __MKINT(np); __STORE(self, t);
+ INT np = __intVal(__INST(position)) + nread;
+ OBJ t;
+
+ __INST(position) = t = __MKINT(np); __STORE(self, t);
} else {
- __INST(position) = nil; /* i.e. do not know */
+ __INST(position) = nil; /* i.e. do not know */
}
%}.
retVal isNil ifTrue:[
- "/
- "/ arrive here with retVal==nil either on error or premature EOF
- "/ or if running out of malloc-memory
- "/
- hitEOF == true ifTrue:[^ self pastEnd].
- lastErrorNumber notNil ifTrue:[^ self readError].
- outOfMemory == true ifTrue:[
- "
- buffer memory allocation failed.
- When we arrive here, there was no memory available for the
- chunk. (seems to be too big of a chunk ...)
- Bad luck - you should increase the ulimit and/or swap space on your machine.
- "
- ^ ObjectMemory allocationFailureSignal raise.
- ].
- ^ super nextChunk
+ "/
+ "/ arrive here with retVal==nil either on error or premature EOF
+ "/ or if running out of malloc-memory
+ "/
+ hitEOF == true ifTrue:[^ self pastEnd].
+ lastErrorNumber notNil ifTrue:[^ self readError].
+ outOfMemory == true ifTrue:[
+ "
+ buffer memory allocation failed.
+ When we arrive here, there was no memory available for the
+ chunk. (seems to be too big of a chunk ...)
+ Bad luck - you should increase the ulimit and/or swap space on your machine.
+ "
+ ^ ObjectMemory allocationFailureSignal raise.
+ ].
+ ^ super nextChunk
].
^ retVal
!
@@ -4773,42 +4773,42 @@
__INST(lastErrorNumber) = nil;
if (((fp = __INST(filePointer)) != nil)
- && (__INST(mode) != @symbol(writeonly))
+ && (__INST(mode) != @symbol(writeonly))
) {
- if ((__INST(binary) == true) && __isSmallInteger(anObject)) {
- peekValue = __intVal(anObject) & 0xFF;
- } else {
- if ((__INST(binary) != true) && __isCharacter(anObject)) {
- peekValue = __intVal(_characterVal(anObject)) & 0xFF;
- } else {
- peekValue = -1;
- }
- }
-
- if (peekValue >= 0) {
- int _buffered;
-
- __INST(position) = nil; /* i.e. do not know */
- f = __FILEVal(fp);
-
- if (_buffered = (__INST(buffered) == true)) {
- __READING__(f)
- }
-
- for (;;) {
- __READBYTE__(ret, f, &c, _buffered);
- if (ret <= 0) {
- if (ret < 0)
- __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
- else
- __INST(hitEOF) = true;
- break;
- }
- if (c == peekValue) {
- RETURN (anObject);
- }
- }
- }
+ if ((__INST(binary) == true) && __isSmallInteger(anObject)) {
+ peekValue = __intVal(anObject) & 0xFF;
+ } else {
+ if ((__INST(binary) != true) && __isCharacter(anObject)) {
+ peekValue = __intVal(_characterVal(anObject)) & 0xFF;
+ } else {
+ peekValue = -1;
+ }
+ }
+
+ if (peekValue >= 0) {
+ int _buffered;
+
+ __INST(position) = nil; /* i.e. do not know */
+ f = __FILEVal(fp);
+
+ if (_buffered = (__INST(buffered) == true)) {
+ __READING__(f)
+ }
+
+ for (;;) {
+ __READBYTE__(ret, f, &c, _buffered);
+ if (ret <= 0) {
+ if (ret < 0)
+ __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
+ else
+ __INST(hitEOF) = true;
+ break;
+ }
+ if (c == peekValue) {
+ RETURN (anObject);
+ }
+ }
+ }
}
%}.
hitEOF ifTrue:[^ self pastEnd].
@@ -4832,49 +4832,49 @@
__INST(lastErrorNumber) = nil;
if (((fp = __INST(filePointer)) != nil)
- && (__INST(mode) != @symbol(writeonly))
+ && (__INST(mode) != @symbol(writeonly))
) {
- if (__INST(binary) == true) {
- if (__isSmallInteger(anObject)) {
- peekValue = __intVal(anObject) & 0xFF;
- } else {
- goto bad;
- }
- } else {
- if (__isCharacter(anObject)) {
- peekValue = __intVal(_characterVal(anObject)) & 0xFF;
- } else {
- goto bad;
- }
- }
-
- f = __FILEVal(fp);
-
- _buffered = (__INST(buffered) == true);
- if (_buffered) {
- __READING__(f)
- }
- __READBYTE__(ret, f, &c, _buffered);
- if (ret > 0) {
- if (c == peekValue) {
- 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 (true);
- }
- __UNGETC__(c, f, _buffered);
- RETURN (false);
- }
- if (ret < 0) {
- __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
- } else /* ret == 0 */
- __INST(hitEOF) = true;
- }
+ if (__INST(binary) == true) {
+ if (__isSmallInteger(anObject)) {
+ peekValue = __intVal(anObject) & 0xFF;
+ } else {
+ goto bad;
+ }
+ } else {
+ if (__isCharacter(anObject)) {
+ peekValue = __intVal(_characterVal(anObject)) & 0xFF;
+ } else {
+ goto bad;
+ }
+ }
+
+ f = __FILEVal(fp);
+
+ _buffered = (__INST(buffered) == true);
+ if (_buffered) {
+ __READING__(f)
+ }
+ __READBYTE__(ret, f, &c, _buffered);
+ if (ret > 0) {
+ if (c == peekValue) {
+ 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 (true);
+ }
+ __UNGETC__(c, f, _buffered);
+ RETURN (false);
+ }
+ if (ret < 0) {
+ __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
+ } else /* ret == 0 */
+ __INST(hitEOF) = true;
+ }
bad: ;
%}.
^ super peekFor:anObject
@@ -5172,66 +5172,66 @@
int ret, _buffered;
if (__INST(hitEOF) == true) {
- RETURN (true);
+ RETURN (true);
}
pos = __INST(position);
lim = __INST(readLimit);
if (lim != nil) {
- off_t _pos, _readLimit;
-
- _pos = __signedLongIntVal(pos);
- _pos = _pos - __intVal( @global(PositionableStream:ZeroPosition)) + 1;
- _readLimit = __signedLongIntVal(lim);
- if (_pos > _readLimit) {
- RETURN (true);
- }
+ off_t _pos, _readLimit;
+
+ _pos = __signedLongIntVal(pos);
+ _pos = _pos - __intVal( @global(PositionableStream:ZeroPosition)) + 1;
+ _readLimit = __signedLongIntVal(lim);
+ if (_pos > _readLimit) {
+ RETURN (true);
+ }
}
__INST(lastErrorNumber) = nil;
if ((fp = __INST(filePointer)) != nil) {
- f = __FILEVal(fp);
-
- if (_buffered = (__INST(buffered) == true)) {
- __READING__(f);
- } else {
- if (__INST(readAhead) != nil) {
- RETURN (false);
- }
- }
-
- /*
- * read ahead ...
- */
- do {
- __BEGIN_INTERRUPTABLE__
+ f = __FILEVal(fp);
+
+ if (_buffered = (__INST(buffered) == true)) {
+ __READING__(f);
+ } else {
+ if (__INST(readAhead) != nil) {
+ RETURN (false);
+ }
+ }
+
+ /*
+ * read ahead ...
+ */
+ do {
+ __BEGIN_INTERRUPTABLE__
#ifdef WIN32
- __threadErrno = 0;
+ __threadErrno = 0;
#endif
- __READBYTE__(ret, f, &c, _buffered);
-
- __END_INTERRUPTABLE__
- } while ((ret < 0) && (__threadErrno == EINTR));
+ __READBYTE__(ret, f, &c, _buffered);
+
+ __END_INTERRUPTABLE__
+ } while ((ret < 0) && (__threadErrno == EINTR));
#if defined(WIN32) && defined(EPIPE)
- if ((ret < 0) && (__threadErrno == EPIPE)) {
- ret = 0;
- __threadErrno = 0;
- }
+ if ((ret < 0) && (__threadErrno == EPIPE)) {
+ ret = 0;
+ __threadErrno = 0;
+ }
#endif
- if (ret > 0) {
- __UNGETC__(c&0xff, f, _buffered);
- RETURN (false);
- }
-
- if (ret == 0) {
- __INST(hitEOF) = true;
- RETURN (true);
- }
-
- /* ret < 0 */
- __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
+ if (ret > 0) {
+ __UNGETC__(c&0xff, f, _buffered);
+ RETURN (false);
+ }
+
+ if (ret == 0) {
+ __INST(hitEOF) = true;
+ RETURN (true);
+ }
+
+ /* ret < 0 */
+ __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
}
%}.
lastErrorNumber notNil ifTrue:[^ self readError].
@@ -5241,7 +5241,7 @@
"/ migration support
^ self
- atEndFile:filePointer
+ atEndFile:filePointer
"Modified: / 30.10.1998 / 20:16:06 / cg"
!
@@ -5551,45 +5551,45 @@
__INST(lastErrorNumber) = nil;
if (((fp = __INST(filePointer)) != nil)
- && (__INST(mode) != @symbol(readonly))
- && (__INST(binary) != true)
+ && (__INST(mode) != @symbol(readonly))
+ && (__INST(binary) != true)
) {
- f = __FILEVal(fp);
-
- if (_buffered = (__INST(buffered) == true)) {
- __WRITING__(f)
- }
- {
- OBJ mode = __INST(eolMode);
-
- if (mode == @symbol(cr)) {
- cp = "\r"; len = 1;
- } else if (mode == @symbol(crlf)) {
- cp = "\r\n"; len = 2;
- } else {
- cp = "\n"; len = 1;
- }
- }
+ f = __FILEVal(fp);
+
+ if (_buffered = (__INST(buffered) == true)) {
+ __WRITING__(f)
+ }
+ {
+ OBJ mode = __INST(eolMode);
+
+ if (mode == @symbol(cr)) {
+ cp = "\r"; len = 1;
+ } else if (mode == @symbol(crlf)) {
+ cp = "\r\n"; len = 2;
+ } else {
+ cp = "\n"; len = 1;
+ }
+ }
#ifdef WIN32
- if ((f == stdout) || (f == stderr)) {
- cnt = fwrite(cp, 1, len, f);
- } else
+ if ((f == stdout) || (f == stderr)) {
+ cnt = fwrite(cp, 1, len, f);
+ } else
#endif
- {
- __WRITEBYTES__(cnt, f, cp, len, _buffered);
- }
- if (cnt == len) {
- if (__isSmallInteger(__INST(position))) {
- INT np = __intVal(__INST(position)) + len;
- OBJ t;
-
- __INST(position) = t = __MKINT(np); __STORE(self, t);
- } else {
- __INST(position) = nil; /* i.e: dont know */
- }
- RETURN ( self );
- }
- __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
+ {
+ __WRITEBYTES__(cnt, f, cp, len, _buffered);
+ }
+ if (cnt == len) {
+ if (__isSmallInteger(__INST(position))) {
+ INT np = __intVal(__INST(position)) + len;
+ OBJ t;
+
+ __INST(position) = t = __MKINT(np); __STORE(self, t);
+ } else {
+ __INST(position) = nil; /* i.e: dont know */
+ }
+ RETURN ( self );
+ }
+ __INST(lastErrorNumber) = __MKSMALLINT(__threadErrno);
}
%}.
lastErrorNumber notNil ifTrue:[self writeError. ^ self].
@@ -5643,49 +5643,49 @@
__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)) {
+ c = __intVal(__characterVal(aCharacter)) & 0xFF;
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)
- }
+ 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
+ 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;
- }
- }
+ {
+ __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: ;
%}.
@@ -5693,20 +5693,20 @@
filePointer isNil ifTrue:[self errorNotOpen. ^ self].
(mode == #readonly) ifTrue:[self errorReadOnly. ^ self].
binary == true ifFalse:[
- aCharacter isCharacter ifFalse:[
- self argumentMustBeCharacter.
- ^ self.
- ]
+ aCharacter isCharacter ifFalse:[
+ 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
@@ -5724,67 +5724,67 @@
__INST(lastErrorNumber) = nil;
if (((fp = __INST(filePointer)) != nil)
- && (__INST(mode) != @symbol(readonly))
+ && (__INST(mode) != @symbol(readonly))
) {
- f = __FILEVal(fp);
- if (! f) {
- fprintf(stderr, "oops - fileHandle is NULL in nextPutAll:\n");
- __INST(filePointer) = nil;
- goto out;
- }
- if (_buffered = (__INST(buffered) == true)) {
- __WRITING__(f)
- }
-
- if (__isString(aCollection) || __isSymbol(aCollection)) {
- len = __stringSize(aCollection);
+ f = __FILEVal(fp);
+ if (! f) {
+ fprintf(stderr, "oops - fileHandle is NULL in nextPutAll:\n");
+ __INST(filePointer) = nil;
+ goto out;
+ }
+ if (_buffered = (__INST(buffered) == true)) {
+ __WRITING__(f)
+ }
+
+ if (__isString(aCollection) || __isSymbol(aCollection)) {
+ len = __stringSize(aCollection);
#ifdef WIN32
- if ((f == stdout) || (f == stderr)) {
- cnt = fwrite(__stringVal(aCollection), 1, len, f);
- } else
+ if ((f == stdout) || (f == stderr)) {
+ cnt = fwrite(__stringVal(aCollection), 1, len, f);
+ } else
#endif
- {
- o_offs = (char *)__stringVal(aCollection)-(char *)__InstPtr(aCollection);
- __WRITEBYTES_OBJ__(cnt, f, aCollection, o_offs, len, _buffered);
- }
- } else {
- if (__INST(binary) == true) {
- int offs;
-
- if (__isByteArray(aCollection)) {
- offs = 0;
- len = __byteArraySize(aCollection);
- } else if (__isBytes(aCollection)) {
- offs = __OBJS2BYTES__(__intVal(__ClassInstPtr(__qClass(aCollection))->c_ninstvars));
- len = __byteArraySize(aCollection) - offs;
- } else
- goto out;
+ {
+ o_offs = (char *)__stringVal(aCollection)-(char *)__InstPtr(aCollection);
+ __WRITEBYTES_OBJ__(cnt, f, aCollection, o_offs, len, _buffered);
+ }
+ } else {
+ if (__INST(binary) == true) {
+ int offs;
+
+ if (__isByteArray(aCollection)) {
+ offs = 0;
+ len = __byteArraySize(aCollection);
+ } else if (__isBytes(aCollection)) {
+ offs = __OBJS2BYTES__(__intVal(__ClassInstPtr(__qClass(aCollection))->c_ninstvars));
+ len = __byteArraySize(aCollection) - offs;
+ } else
+ goto out;
#ifdef WIN32
- if ((f == stdout) || (f == stderr)) {
- cnt = fwrite(__stringVal(aCollection), 1, len, f);
- } else
+ if ((f == stdout) || (f == stderr)) {
+ cnt = fwrite(__stringVal(aCollection), 1, len, f);
+ } else
#endif
- {
- o_offs = (char *)(__ByteArrayInstPtr(aCollection)->ba_element) - (char *)__InstPtr(aCollection);
- o_offs += offs;
- __WRITEBYTES_OBJ__(cnt, f, aCollection, o_offs, len, _buffered);
- }
- } else
- goto out;
- }
-
- if (cnt == len) {
- if (__isSmallInteger(__INST(position))) {
- INT np = __intVal(__INST(position)) + len;
- 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);
+ {
+ o_offs = (char *)(__ByteArrayInstPtr(aCollection)->ba_element) - (char *)__InstPtr(aCollection);
+ o_offs += offs;
+ __WRITEBYTES_OBJ__(cnt, f, aCollection, o_offs, len, _buffered);
+ }
+ } else
+ goto out;
+ }
+
+ if (cnt == len) {
+ if (__isSmallInteger(__INST(position))) {
+ INT np = __intVal(__INST(position)) + len;
+ 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);
}
out: ;
%}.
@@ -5808,79 +5808,79 @@
__INST(lastErrorNumber) = nil;
if (((fp = __INST(filePointer)) != nil)
- && (__INST(mode) != @symbol(readonly))
- && __bothSmallInteger(start, stop)
+ && (__INST(mode) != @symbol(readonly))
+ && __bothSmallInteger(start, stop)
) {
- f = __FILEVal(fp);
- if (_buffered = (__INST(buffered) == true)) {
- __WRITING__(f)
- }
- iStart = __intVal(start);
- iStop = __intVal(stop);
- if ((iStart < 1) || (iStop < iStart)) {
- RETURN(self);
- }
- if (__isString(aCollection) || __isSymbol(aCollection)) {
- len = __stringSize(aCollection);
- if (iStop > len) {
- RETURN(self);
- }
- if (iStop > len)
- iStop = len;
- len = iStop - iStart + 1;
+ f = __FILEVal(fp);
+ if (_buffered = (__INST(buffered) == true)) {
+ __WRITING__(f)
+ }
+ iStart = __intVal(start);
+ iStop = __intVal(stop);
+ if ((iStart < 1) || (iStop < iStart)) {
+ RETURN(self);
+ }
+ if (__isString(aCollection) || __isSymbol(aCollection)) {
+ len = __stringSize(aCollection);
+ if (iStop > len) {
+ RETURN(self);
+ }
+ if (iStop > len)
+ iStop = len;
+ len = iStop - iStart + 1;
#ifdef WIN32
- if ((f == stdout) || (f == stderr)) {
- cnt = fwrite(__stringVal(aCollection)+iStart-1, 1, len, f);
- } else
+ if ((f == stdout) || (f == stderr)) {
+ cnt = fwrite(__stringVal(aCollection)+iStart-1, 1, len, f);
+ } else
#endif
- {
- o_offs = (char *)__stringVal(aCollection)-(char *)__InstPtr(aCollection);
- __WRITEBYTES_OBJ__(cnt, f, aCollection, o_offs+iStart-1, len, _buffered);
- }
- } else {
- if (__INST(binary) == true) {
- int offs;
-
- if (__isByteArray(aCollection)) {
- offs = 0;
- len = __byteArraySize(aCollection);
- } else if (__isBytes(aCollection)) {
- offs = __OBJS2BYTES__(__intVal(__ClassInstPtr(__qClass(aCollection))->c_ninstvars));
- len = __byteArraySize(aCollection) - offs;
- } else
- goto out;
-
- if (iStop > len) {
- RETURN(self);
- }
- if (iStop > len)
- iStop = len;
- len = iStop - iStart + 1;
- offs += iStart - 1;
+ {
+ o_offs = (char *)__stringVal(aCollection)-(char *)__InstPtr(aCollection);
+ __WRITEBYTES_OBJ__(cnt, f, aCollection, o_offs+iStart-1, len, _buffered);
+ }
+ } else {
+ if (__INST(binary) == true) {
+ int offs;
+
+ if (__isByteArray(aCollection)) {
+ offs = 0;
+ len = __byteArraySize(aCollection);
+ } else if (__isBytes(aCollection)) {
+ offs = __OBJS2BYTES__(__intVal(__ClassInstPtr(__qClass(aCollection))->c_ninstvars));
+ len = __byteArraySize(aCollection) - offs;
+ } else
+ goto out;
+
+ if (iStop > len) {
+ RETURN(self);
+ }
+ if (iStop > len)
+ iStop = len;
+ len = iStop - iStart + 1;
+ offs += iStart - 1;
#ifdef WIN32
- if ((f == stdout) || (f == stderr)) {
- cnt = fwrite(__stringVal(aCollection)+iStart-1, 1, len, f);
- } else
+ if ((f == stdout) || (f == stderr)) {
+ cnt = fwrite(__stringVal(aCollection)+iStart-1, 1, len, f);
+ } else
#endif
- {
- o_offs = (char *)(__ByteArrayInstPtr(aCollection)->ba_element)-(char *)__InstPtr(aCollection);
- __WRITEBYTES_OBJ__(cnt, f, aCollection, o_offs+offs, len, _buffered);
- }
- } else
- goto out;
- }
- if (cnt == len) {
- if (__isSmallInteger(__INST(position))) {
- INT np = __intVal(__INST(position)) + len;
- 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);
+ {
+ o_offs = (char *)(__ByteArrayInstPtr(aCollection)->ba_element)-(char *)__InstPtr(aCollection);
+ __WRITEBYTES_OBJ__(cnt, f, aCollection, o_offs+offs, len, _buffered);
+ }
+ } else
+ goto out;
+ }
+ if (cnt == len) {
+ if (__isSmallInteger(__INST(position))) {
+ INT np = __intVal(__INST(position)) + len;
+ 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);
}
out: ;
%}.
@@ -5891,7 +5891,7 @@
!ExternalStream class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.275 2004-03-04 17:28:43 mb Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.276 2004-03-04 17:36:22 cg Exp $'
! !
ExternalStream initialize!