--- 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!
--- a/GenericException.st Thu Mar 04 18:28:43 2004 +0100
+++ b/GenericException.st Thu Mar 04 18:36:22 2004 +0100
@@ -2,7 +2,7 @@
"
COPYRIGHT (c) 1993 by Claus Gittinger
- All Rights Reserved
+ All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
@@ -34,7 +34,7 @@
copyright
"
COPYRIGHT (c) 1993 by Claus Gittinger
- All Rights Reserved
+ All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
@@ -48,16 +48,16 @@
documentation
"
Note:
- The instance based Signal framework is being replaced by
- class based exceptions.
- I.e. what used to be instances of Signal/QuerySignal is beeing
- rewritten into subclasses of Exception/Error/Query and Warning.
- Although the functionality is basically unchanged, the new
- class based exceptions are easier to instanciate (no need for
- creation in a classes initialize method), easier to use (no real
- need for SIgnal-constant accessors) and allow for easier parameter
- passing (not only a single parameter, but allows for individual
- exception subclasses to add additional state).
+ The instance based Signal framework is being replaced by
+ class based exceptions.
+ I.e. what used to be instances of Signal/QuerySignal is beeing
+ rewritten into subclasses of Exception/Error/Query and Warning.
+ Although the functionality is basically unchanged, the new
+ class based exceptions are easier to instanciate (no need for
+ creation in a classes initialize method), easier to use (no real
+ need for SIgnal-constant accessors) and allow for easier parameter
+ passing (not only a single parameter, but allows for individual
+ exception subclasses to add additional state).
GenericException and its subclasses implement the same protocol as Signal.
So class based exceptions may be implemented as subclasses of GenericException.
@@ -70,22 +70,22 @@
The handler block may perform various actions by sending corresponding messages
to the exception object. The following actions are possible:
- reject - don't handle this signal;
- another handler will be searched for,
- upper in the calling hierarchy
-
- proceed - return from the Signal>>raise, with nil as value
-
- proceedWith:val - same, but return val from Signal>>raise
-
- return - return from the Signal>>handle:do:, with nil as value
-
- returnWith:val - same, but return val from Signal>>handle:do:
- (this is also the handlers default,
- if it falls through; taking the handlerBlocks value
- as return value)
-
- restart - restart the Signal>>handle:do:, after repairing
+ reject - don't handle this signal;
+ another handler will be searched for,
+ upper in the calling hierarchy
+
+ proceed - return from the Signal>>raise, with nil as value
+
+ proceedWith:val - same, but return val from Signal>>raise
+
+ return - return from the Signal>>handle:do:, with nil as value
+
+ returnWith:val - same, but return val from Signal>>handle:do:
+ (this is also the handlers default,
+ if it falls through; taking the handlerBlocks value
+ as return value)
+
+ restart - restart the Signal>>handle:do:, after repairing
Via the Exception object, the handler can also query the state of execution:
where the Signal was raised, where the handler is, the signal which caused
@@ -93,18 +93,18 @@
parameter can be passed - the use is signal specific.
[instance variables:]
- signal <Signal> the signal which caused the exception
-
- parameter <Object> a parameter (if any) which was passed when raising
- the signal (only if raised with #raiseWith:aParameter)
-
- errorString <String> an errorString
- (usually the signals own errorString, but sometimes
- changed explicitely in #raiseWith:errorString:)
-
- suspendedContext <Context> the context in which the raise occured
-
- handlerContext <Context> the context of the handler (if any)
+ signal <Signal> the signal which caused the exception
+
+ parameter <Object> a parameter (if any) which was passed when raising
+ the signal (only if raised with #raiseWith:aParameter)
+
+ errorString <String> an errorString
+ (usually the signals own errorString, but sometimes
+ changed explicitely in #raiseWith:errorString:)
+
+ suspendedContext <Context> the context in which the raise occured
+
+ handlerContext <Context> the context of the handler (if any)
In case of an unhandled signal raise, Exceptions EmergenyHandler will be evaluated.
The default emergeny handler will enter the debugger.
@@ -112,53 +112,53 @@
For applications, which do not want Debuggers to come up, other handlers are
possible.
For example, to get the typical C++ behavior, use:
- Exception emergencyHandler:[:ex | Smalltalk exitWithCoreDump]
+ Exception emergencyHandler:[:ex | Smalltalk exitWithCoreDump]
Raising:
- two different raising messages are to be used,
- depending on whether the exception is proceedable or not
-
- For some stupid reason, someone decided that the raise-code checks if
- the raising messages matches to what the signal thinks is its proceedability.
- (i.e. not only do both the sender and the signal itself specify proceedability,
- this is checked by the raise code and a warning is generated if there is a mismatch)
- This used to be even worse (WrongProceedabilityError), but we relaxed this to
- a message sent to stderr.
-
- That means, that PROCEEDABLE signals must be raised with:
- raiseRequest
- and NON-PROCEEDABLE signals must be raised with:
- raise
-
- If you dont know/care as a raiser, you can use
- raiseSignal
- which checks for proceedability and sends the appropriate message.
- (sigh)
+ two different raising messages are to be used,
+ depending on whether the exception is proceedable or not
+
+ For some stupid reason, someone decided that the raise-code checks if
+ the raising messages matches to what the signal thinks is its proceedability.
+ (i.e. not only do both the sender and the signal itself specify proceedability,
+ this is checked by the raise code and a warning is generated if there is a mismatch)
+ This used to be even worse (WrongProceedabilityError), but we relaxed this to
+ a message sent to stderr.
+
+ That means, that PROCEEDABLE signals must be raised with:
+ raiseRequest
+ and NON-PROCEEDABLE signals must be raised with:
+ raise
+
+ If you dont know/care as a raiser, you can use
+ raiseSignal
+ which checks for proceedability and sends the appropriate message.
+ (sigh)
all of the 3 messages above come in various flavours:
- raiseXXX - do not pass any additional parameter;
- default errorString
-
- raiseXXXWith: - pass additional parameter;
- default errorString
-
- raiseXXXErrorString: - do not pass any additional parameter;
- given errorString
-
- raiseXXXWith:errorString:
- - pass any additional parameter;
- AND given errorString
+ raiseXXX - do not pass any additional parameter;
+ default errorString
+
+ raiseXXXWith: - pass additional parameter;
+ default errorString
+
+ raiseXXXErrorString: - do not pass any additional parameter;
+ given errorString
+
+ raiseXXXWith:errorString:
+ - pass any additional parameter;
+ AND given errorString
[see also:]
- Signal SignalSet QuerySignal
- Context Block
- Object DebugView
- (``Exception handling and signals'': programming/exceptions.html)
+ Signal SignalSet QuerySignal
+ Context Block
+ Object DebugView
+ (``Exception handling and signals'': programming/exceptions.html)
[author:]
- Claus Gittinger
+ Claus Gittinger
"
!
@@ -202,11 +202,11 @@
"{ Pragma: +inlineNew }"
^ (self basicNew)
- signal:aSignal
- parameter:aParameter
- errorString:aString
- suspendedContext:sContext
- originator:origin.
+ signal:aSignal
+ parameter:aParameter
+ errorString:aString
+ suspendedContext:sContext
+ originator:origin.
! !
!GenericException class methodsFor:'Compatibility-ANSI'!
@@ -221,7 +221,7 @@
"actually raise an exception (whatever the proceedability is)."
self mayProceed ifFalse:[
- ^ self raiseWith:aParameter errorString:errorMessage
+ ^ self raiseWith:aParameter errorString:errorMessage
].
^ self raiseRequestWith:aParameter errorString:errorMessage
!
@@ -239,9 +239,9 @@
<context: #return>
^ (self newException
- suspendedContext:thisContext sender
- errorString:errorString)
- raiseSignal.
+ suspendedContext:thisContext sender
+ errorString:errorString)
+ raiseSignal.
! !
!GenericException class methodsFor:'Signal constants'!
@@ -328,14 +328,14 @@
(I prefer to get right into the debugger, though)
Exception
- emergencyHandler:
- [:ex | self errorNotify:ex errorString ]
+ emergencyHandler:
+ [:ex | self errorNotify:ex errorString ]
"
"ST-X behavior of going right into the debugger:
Exception
- emergencyHandler:nil
+ emergencyHandler:nil
"
"automatically aborting current operation, on error:
@@ -343,15 +343,15 @@
you have abortSignal handlers at appropriate places)
Exception
- emergencyHandler:
- [:ex | Object abortSignal raise. ex return. ]
+ emergencyHandler:
+ [:ex | Object abortSignal raise. ex return. ]
"
"finally, traditional language system behavior; dump core ;-)
Exception
- emergencyHandler:
- [:ex | Smalltalk exitWithCoreDump. ]
+ emergencyHandler:
+ [:ex | Smalltalk exitWithCoreDump. ]
"
"Modified: 15.1.1997 / 20:49:06 / cg"
@@ -371,8 +371,8 @@
s := aSignal.
[s notNil] whileTrue:[
- self == s ifTrue:[^ true].
- s := s parent
+ self == s ifTrue:[^ true].
+ s := s parent
].
^ false
@@ -387,13 +387,13 @@
con := Context findFirstSpecialHandle:true raise:false.
[con notNil] whileTrue:[
- ((r := con receiver) notNil
- and:[(r handlerForSignal:anExceptionOrSignal context:con originator:nil) notNil]
- ) ifTrue:[
- "found a handler context"
- ^ true
- ].
- con := con findSpecialHandle:true raise:false.
+ ((r := con receiver) notNil
+ and:[(r handlerForSignal:anExceptionOrSignal context:con originator:nil) notNil]
+ ) ifTrue:[
+ "found a handler context"
+ ^ true
+ ].
+ con := con findSpecialHandle:true raise:false.
].
^ false
@@ -407,9 +407,9 @@
(theContext selector ~~ #'handle:from:do:'
or:[(theContext argAt:2) == originator]) ifTrue:[
- (self == signal or:[self accepts:signal]) ifTrue:[
- ^ theContext argAt:1
- ]
+ (self == signal or:[self accepts:signal]) ifTrue:[
+ ^ theContext argAt:1
+ ]
].
^ nil
@@ -424,9 +424,9 @@
sel := context selector.
sel == #handle:do: ifTrue:[
- context argAt:2 put:doBlock.
+ context argAt:2 put:doBlock.
] ifFalse:[sel == #handle:from:do: ifTrue:[
- context argAt:3 put:doBlock.
+ context argAt:3 put:doBlock.
]].
!
@@ -438,7 +438,7 @@
sel := theContext selector.
(sel == #'handle:from:do:'
or:[sel == #'handle:do:']) ifTrue:[
- ^ theContext receiver
+ ^ theContext receiver
].
^ nil
@@ -514,7 +514,7 @@
existing Signals."
self == GenericException ifTrue:[
- ^ nil
+ ^ nil
].
^ self superclass
@@ -559,8 +559,8 @@
<context: #return>
^ self newException
- suspendedContext:thisContext sender;
- raise
+ suspendedContext:thisContext sender;
+ raise
"Modified: / 2.5.1996 / 16:36:23 / cg"
"Modified: / 5.3.1998 / 16:44:36 / stefan"
@@ -574,9 +574,9 @@
<context: #return>
^ (self newException
- suspendedContext:thisContext sender
- errorString:aString)
- raise.
+ suspendedContext:thisContext sender
+ errorString:aString)
+ raise.
"Modified: / 9.5.1996 / 15:17:59 / cg"
"Modified: / 12.3.1998 / 15:15:22 / stefan"
@@ -590,9 +590,9 @@
<context: #return>
^ (self newException
- suspendedContext:aContext
- errorString:aString)
- raise.
+ suspendedContext:aContext
+ errorString:aString)
+ raise.
"Modified: / 9.5.1996 / 15:17:59 / cg"
"Modified: / 12.3.1998 / 15:15:22 / stefan"
@@ -606,9 +606,9 @@
<context: #return>
^ ((self newExceptionFrom:something)
- suspendedContext:thisContext sender
- parameter:something)
- raise
+ suspendedContext:thisContext sender
+ parameter:something)
+ raise
"Modified: / 2.5.1996 / 16:36:38 / cg"
"Modified: / 5.3.1998 / 16:49:55 / stefan"
@@ -622,8 +622,8 @@
<context: #return>
^ self newException
- suspendedContext:thisContext sender;
- raiseRequest.
+ suspendedContext:thisContext sender;
+ raiseRequest.
"Modified: / 2.5.1996 / 16:36:52 / cg"
"Modified: / 5.3.1998 / 16:50:46 / stefan"
@@ -637,9 +637,9 @@
<context: #return>
^ (self newException
- suspendedContext:thisContext sender
- errorString:aString)
- raiseRequest
+ suspendedContext:thisContext sender
+ errorString:aString)
+ raiseRequest
!
raiseRequestFrom:something
@@ -649,9 +649,9 @@
<context: #return>
^ ((self newExceptionFrom:something)
- suspendedContext:thisContext sender
- parameter:something)
- raiseRequest.
+ suspendedContext:thisContext sender
+ parameter:something)
+ raiseRequest.
"Modified: / 2.5.1996 / 16:36:38 / cg"
"Modified: / 5.3.1998 / 16:52:46 / stefan"
@@ -665,9 +665,9 @@
<context: #return>
^ (self newException
- suspendedContext:thisContext sender
- parameter:aParameter)
- raiseRequest.
+ suspendedContext:thisContext sender
+ parameter:aParameter)
+ raiseRequest.
"Modified: / 9.5.1996 / 15:13:20 / cg"
"Modified: / 12.3.1998 / 15:16:57 / stefan"
@@ -681,10 +681,10 @@
<context: #return>
^ (self newException
- suspendedContext:thisContext sender
- parameter:aParameter
- errorString:aString)
- raiseRequest
+ suspendedContext:thisContext sender
+ parameter:aParameter
+ errorString:aString)
+ raiseRequest
"Modified: / 9.5.1996 / 15:13:35 / cg"
"Modified: / 12.3.1998 / 15:17:52 / stefan"
@@ -698,10 +698,10 @@
allowing a raise to mimicri the exception happened somewhere else."
^ (self newException
- suspendedContext:aContext
- parameter:aParameter
- errorString:aString)
- raiseRequest
+ suspendedContext:aContext
+ parameter:aParameter
+ errorString:aString)
+ raiseRequest
"Modified: / 26.7.1996 / 16:29:27 / cg"
"Modified: / 12.3.1998 / 15:18:34 / stefan"
@@ -714,9 +714,9 @@
allowing a raise to mimicri the exception happened somewhere else."
^ (self newException
- suspendedContext:aContext
- parameter:aParameter)
- raiseRequest
+ suspendedContext:aContext
+ parameter:aParameter)
+ raiseRequest
!
raiseSignal
@@ -726,8 +726,8 @@
<context: #return>
^ (self newException
- suspendedContext:thisContext sender)
- raiseSignal
+ suspendedContext:thisContext sender)
+ raiseSignal
"Modified: / 10.11.2001 / 15:13:34 / cg"
!
@@ -739,9 +739,9 @@
<context: #return>
^ (self newException
- suspendedContext:thisContext sender
- errorString:aString)
- raiseSignal.
+ suspendedContext:thisContext sender
+ errorString:aString)
+ raiseSignal.
!
raiseSignalWith:aParameter
@@ -751,9 +751,9 @@
<context: #return>
^ (self newException
- suspendedContext:thisContext sender
- parameter:aParameter)
- raiseSignal.
+ suspendedContext:thisContext sender
+ parameter:aParameter)
+ raiseSignal.
!
raiseSignalWith:aParameter errorString:aString
@@ -764,10 +764,10 @@
<context: #return>
^ (self newException
- suspendedContext:thisContext sender
- parameter:aParameter
- errorString:aString)
- raiseSignal.
+ suspendedContext:thisContext sender
+ parameter:aParameter
+ errorString:aString)
+ raiseSignal.
!
raiseWith:aParameter
@@ -777,9 +777,9 @@
<context: #return>
^ (self newException
- suspendedContext:thisContext sender
- parameter:aParameter)
- raise.
+ suspendedContext:thisContext sender
+ parameter:aParameter)
+ raise.
"Modified: / 9.5.1996 / 15:14:24 / cg"
"Modified: / 12.3.1998 / 15:19:11 / stefan"
@@ -794,10 +794,10 @@
<context: #return>
^ (self newException
- suspendedContext:thisContext sender
- parameter:aParameter
- errorString:aString)
- raise.
+ suspendedContext:thisContext sender
+ parameter:aParameter
+ errorString:aString)
+ raise.
"Modified: / 9.5.1996 / 15:14:32 / cg"
"Modified: / 12.3.1998 / 15:19:40 / stefan"
@@ -812,10 +812,10 @@
allowing a raise to mimicri the exception happened somewhere else."
^ (self newException
- suspendedContext:aContext
- parameter:aParameter
- errorString:aString)
- raise.
+ suspendedContext:aContext
+ parameter:aParameter
+ errorString:aString)
+ raise.
"Modified: / 26.7.1996 / 16:29:42 / cg"
"Modified: / 12.3.1998 / 15:20:12 / stefan"
@@ -839,7 +839,7 @@
"
Object messageNotUnderstoodSignal catch:[
- 123 size open
+ 123 size open
]
"
@@ -862,27 +862,27 @@
|coughtException result|
self handle:[:ex |
- coughtException isNil ifTrue:[
- coughtException := ex.
- ].
- ex proceedWith:nil
+ coughtException isNil ifTrue:[
+ coughtException := ex.
+ ].
+ ex proceedWith:nil
] do:[
- result := aBlock value.
+ result := aBlock value.
].
coughtException notNil ifTrue:[
- coughtException suspendedContext:thisContext.
-
- "/ the exception was raised during the execution of aBlock above.
- "/ Raise it now (delayed).
- coughtException raiseSignal
+ coughtException suspendedContext:thisContext.
+
+ "/ the exception was raised during the execution of aBlock above.
+ "/ Raise it now (delayed).
+ coughtException raiseSignal.
].
^ result
"
UserInterrupt deferAfter:[
- Transcript showCR:'1 - now raising, but will be deferred.'.
- UserInterrupt raiseRequestWith:'hello'.
- Transcript showCR:'2 - after the raise, deferred exception will be handled soon.'.
+ Transcript showCR:'1 - now raising, but will be deferred.'.
+ UserInterrupt raiseRequestWith:'hello'.
+ Transcript showCR:'2 - after the raise, deferred exception will be handled soon.'.
].
Transcript showCR:'3 - here after the protected block.'.
"
@@ -905,10 +905,10 @@
"
Object messageNotUnderstoodSignal handle:[:ex |
- 'oops' printNL.
- ex return
+ 'oops' printNL.
+ ex return
] do:[
- 123 size open
+ 123 size open
]
"
@@ -917,10 +917,10 @@
num := 0.
Number divisionByZeroSignal handle:[:ex |
- 'oops' printNL.
- ex return
+ 'oops' printNL.
+ ex return
] do:[
- 123 / num
+ 123 / num
]
"
@@ -952,17 +952,17 @@
o1 := 123.
o2 := nil.
Object messageNotUnderstoodSignal
- handle:
- [:ex |
- 'oops' printNL.
- ex proceed
- ]
- from:o1
- do:
- [
- o1 open.
- o2 open
- ]
+ handle:
+ [:ex |
+ 'oops' printNL.
+ ex proceed
+ ]
+ from:o1
+ do:
+ [
+ o1 open.
+ o2 open
+ ]
"
"Created: / 23.7.1999 / 14:06:26 / stefan"
@@ -980,7 +980,7 @@
"
Object messageNotUnderstoodSignal ignoreIn:[
- 123 size open
+ 123 size open
]
"
@@ -1005,17 +1005,17 @@
|sig|
self isQuerySignal ifTrue:[
- sig := QuerySignal basicNew.
- mayProceedBoolean ifFalse:[
- 'Exception [warning]: nonProceedable Queries do not make sense' infoPrintCR.
- ].
+ sig := QuerySignal basicNew.
+ mayProceedBoolean ifFalse:[
+ 'Exception [warning]: nonProceedable Queries do not make sense' infoPrintCR.
+ ].
] ifFalse:[
- sig := Signal basicNew.
+ sig := Signal basicNew.
].
^ sig
- mayProceed:mayProceedBoolean;
- notifierString:NotifierString;
- parent:self
+ mayProceed:mayProceedBoolean;
+ notifierString:NotifierString;
+ parent:self
"Created: / 23.7.1999 / 20:12:43 / stefan"
! !
@@ -1039,12 +1039,12 @@
|parent|
NotifierString isNil ifTrue:[
- ^ self name asString
+ ^ self name asString
].
(NotifierString startsWith:Character space) ifTrue:[
- (parent := self parent) notNil ifTrue:[
- ^ parent description, NotifierString
- ].
+ (parent := self parent) notNil ifTrue:[
+ ^ parent description, NotifierString
+ ].
].
^ NotifierString
@@ -1074,7 +1074,7 @@
moved there - it is (for now) left here for backward compatibility."
^ [:ex | self warn:'Error: ' , ex description.
- AbortSignal raise
+ AbortSignal raise
]
"test with (try a few halts or CTRL-C's):
@@ -1099,61 +1099,61 @@
from time to time).
Notice:
- The code below is just an example; you may want to change the
- name of the error-file in your application
- (but please: copy the code; do not modify here)
+ The code below is just an example; you may want to change the
+ name of the error-file in your application
+ (but please: copy the code; do not modify here)
WARNING: this method belongs to NoHandlerError, and may eventually be
moved there - it is (for now) left here for backward compatibility."
^ [:ex |
- |str printedException|
-
- ex signal == NoHandlerError ifTrue:[
- printedException := ex parameter.
- ] ifFalse:[
- printedException := ex
- ].
-
- "/ user interruption is handled specially:
- "/ allow user to choose between proceeding or aborting
- "/ but never dump that information to the file.
-
- printedException signal == Object userInterruptSignal ifTrue:[
- (self confirm:'abort current action ?') ifTrue:[
- AbortSignal raise
- ].
- ex proceedWith:nil
- ].
-
- "/
- "/ dump it to 'errorTrace.stx'
- "/
- str := 'errorTrace.stx' asFilename appendingWriteStream.
-
- str nextPutLine:('******************************* '
- , AbsoluteTime now printString
- , ' *******************************').
- str cr.
-
- str nextPutLine:('** Error: ' , printedException description).
- str nextPutLine:('** Signal: ' , printedException signal printString).
- str nextPutLine:('** Parameter: ' , printedException parameter printString).
- str nextPutLine:('** Process: ' , Processor activeProcess printString).
- str nextPutLine:('** Backtrace:').
- str cr.
+ |str printedException|
+
+ ex signal == NoHandlerError ifTrue:[
+ printedException := ex parameter.
+ ] ifFalse:[
+ printedException := ex
+ ].
+
+ "/ user interruption is handled specially:
+ "/ allow user to choose between proceeding or aborting
+ "/ but never dump that information to the file.
+
+ printedException signal == Object userInterruptSignal ifTrue:[
+ (self confirm:'abort current action ?') ifTrue:[
+ AbortSignal raise
+ ].
+ ex proceedWith:nil
+ ].
+
+ "/
+ "/ dump it to 'errorTrace.stx'
+ "/
+ str := 'errorTrace.stx' asFilename appendingWriteStream.
+
+ str nextPutLine:('******************************* '
+ , AbsoluteTime now printString
+ , ' *******************************').
+ str cr.
+
+ str nextPutLine:('** Error: ' , printedException description).
+ str nextPutLine:('** Signal: ' , printedException signal printString).
+ str nextPutLine:('** Parameter: ' , printedException parameter printString).
+ str nextPutLine:('** Process: ' , Processor activeProcess printString).
+ str nextPutLine:('** Backtrace:').
+ str cr.
- printedException suspendedContext fullPrintAllOn:str.
- str cr.
- str cr.
- str close.
-
- "/ send a line to stdErr
-
- ('[warning]: ignored error: ' , printedException description) errorPrintCR.
- ('[warning]: error information appended to ''errorTrace.stx''') errorPrintCR.
-
- AbortSignal raise
+ printedException suspendedContext fullPrintAllOn:str.
+ str cr.
+ str cr.
+ str close.
+
+ "/ send a line to stdErr
+
+ ('[warning]: ignored error: ' , printedException description) errorPrintCR.
+ ('[warning]: error information appended to ''errorTrace.stx''') errorPrintCR.
+
+ AbortSignal raise
]
"test with (try a few halts or CTRL-C's):
@@ -1177,81 +1177,81 @@
debugged (i.e. the programmers may have a look at the errors).
Notice: the stuff here is a demonstration only; it should be modified
- for your particular environment ...
- ... but please: copy the code and modify there;
- leave the stuff below as it is.
+ for your particular environment ...
+ ... but please: copy the code and modify there;
+ leave the stuff below as it is.
WARNING: this method belongs to NoHandlerError, and may eventually be
moved there - it is (for now) left here for backward compatibility."
^ [:ex |
- |str printedException doMail emergencyMailReceiver pipe|
-
- ex signal == NoHandlerError ifTrue:[
- printedException := ex parameter.
- ] ifFalse:[
- printedException := ex
- ].
-
- "/ user interruption is handled specially:
- "/ allow user to choose between proceeding or aborting
- "/ but never dump that information to the file.
-
- printedException signal == Object userInterruptSignal ifTrue:[
- (self confirm:'abort current action ?') ifTrue:[
- AbortSignal raise
- ].
- ex proceedWith:nil
- ].
-
- "/ somehow get the name of the guy to receive the mail
- "/ you have to implement that yourself.
-
- "/ emergencyMailReceiver := OneOfYourClass getEmergencyMailReceiver.
- emergencyMailReceiver := OperatingSystem getLoginName.
-
- emergencyMailReceiver isNil ifTrue:[
- self warn:(printedException description
- , '\\No mailing to service people possible.') withCRs.
- doMail := false.
- ] ifFalse:[
- doMail := self confirm:(printedException description
- , '\\Mail error information to the service people ('
- , emergencyMailReceiver , ') ?') withCRs
- ].
- doMail ifTrue:[
- str := '' writeStream.
-
- str nextPutLine:('Error notification from '
- , OperatingSystem getLoginName
- , '@'
- , OperatingSystem getHostName).
- str cr.
-
- str nextPutLine:('Time: ' , AbsoluteTime now printString).
- str nextPutLine:('Error: ', printedException description).
- str nextPutLine:('Signal: ', printedException signal printString).
- str nextPutLine:('Parameter: ', printedException parameter printString).
- str nextPutLine:('Process: ', Processor activeProcess printString).
- str nextPutLine:'Backtrace:'.
- str cr.
-
- printedException suspendedContext fullPrintAllOn:str.
- str cr;cr.
-
- str close.
-
- pipe := PipeStream
- writingTo:'mail ', emergencyMailReceiver.
- pipe notNil ifTrue:[
- pipe nextPutLine:'Subject: automatic error report'.
- pipe nextPutAll:str contents.
- pipe cr.
- pipe close.
- ]
- ].
-
- AbortSignal raise
+ |str printedException doMail emergencyMailReceiver pipe|
+
+ ex signal == NoHandlerError ifTrue:[
+ printedException := ex parameter.
+ ] ifFalse:[
+ printedException := ex
+ ].
+
+ "/ user interruption is handled specially:
+ "/ allow user to choose between proceeding or aborting
+ "/ but never dump that information to the file.
+
+ printedException signal == Object userInterruptSignal ifTrue:[
+ (self confirm:'abort current action ?') ifTrue:[
+ AbortSignal raise
+ ].
+ ex proceedWith:nil
+ ].
+
+ "/ somehow get the name of the guy to receive the mail
+ "/ you have to implement that yourself.
+
+ "/ emergencyMailReceiver := OneOfYourClass getEmergencyMailReceiver.
+ emergencyMailReceiver := OperatingSystem getLoginName.
+
+ emergencyMailReceiver isNil ifTrue:[
+ self warn:(printedException description
+ , '\\No mailing to service people possible.') withCRs.
+ doMail := false.
+ ] ifFalse:[
+ doMail := self confirm:(printedException description
+ , '\\Mail error information to the service people ('
+ , emergencyMailReceiver , ') ?') withCRs
+ ].
+ doMail ifTrue:[
+ str := '' writeStream.
+
+ str nextPutLine:('Error notification from '
+ , OperatingSystem getLoginName
+ , '@'
+ , OperatingSystem getHostName).
+ str cr.
+
+ str nextPutLine:('Time: ' , AbsoluteTime now printString).
+ str nextPutLine:('Error: ', printedException description).
+ str nextPutLine:('Signal: ', printedException signal printString).
+ str nextPutLine:('Parameter: ', printedException parameter printString).
+ str nextPutLine:('Process: ', Processor activeProcess printString).
+ str nextPutLine:'Backtrace:'.
+ str cr.
+
+ printedException suspendedContext fullPrintAllOn:str.
+ str cr;cr.
+
+ str close.
+
+ pipe := PipeStream
+ writingTo:'mail ', emergencyMailReceiver.
+ pipe notNil ifTrue:[
+ pipe nextPutLine:'Subject: automatic error report'.
+ pipe nextPutAll:str contents.
+ pipe cr.
+ pipe close.
+ ]
+ ].
+
+ AbortSignal raise
]
"test with (try a few halts or CTRL-C's):
@@ -1277,20 +1277,20 @@
moved there - it is (for now) left here for backward compatibility."
^ [:ex |
- (ex signal == NoHandlerError
- and:[ex parameter signal inheritsFrom:ControlInterrupt]) ifTrue:[
- "/ go directly into the debugger ...
- Debugger
- enter:ex suspendedContext
- withMessage:ex description
- mayProceed:true
- ] ifFalse:[
- "/ ask, and maybe go into the debugger ...
- nil
- errorNotify:ex description
- from:ex suspendedContext
- allowDebug:true
- ]
+ (ex signal == NoHandlerError
+ and:[ex parameter signal inheritsFrom:ControlInterrupt]) ifTrue:[
+ "/ go directly into the debugger ...
+ Debugger
+ enter:ex suspendedContext
+ withMessage:ex description
+ mayProceed:true
+ ] ifFalse:[
+ "/ ask, and maybe go into the debugger ...
+ nil
+ errorNotify:ex description
+ from:ex suspendedContext
+ allowDebug:true
+ ]
]
"test with (NOTE: halt, breakpoints or CTRL-C's still go straight into the debugger):
@@ -1317,33 +1317,33 @@
^ [:ex |
- |theException|
-
- Processor activeProcessIsSystemProcess ifTrue:[
- 'EmergencyHandler [info]: exception cought: ' errorPrint.
- ex signal == NoHandlerError ifTrue:[
- theException := ex parameter.
- ] ifFalse:[
- theException := ex
- ].
- theException description errorPrintCR.
- AbortSignal raise.
- ] ifFalse:[
- (ex signal == NoHandlerError
- and:[ex parameter signal inheritsFrom:ControlInterrupt]) ifTrue:[
- "/ go directly into the debugger ...
- Debugger
- enter:ex suspendedContext
- withMessage:ex description
- mayProceed:true
- ] ifFalse:[
- "/ ask, and maybe go into the debugger ...
- nil
- errorNotify:ex description
- from:ex suspendedContext
- allowDebug:true
- ]
- ]
+ |theException|
+
+ Processor activeProcessIsSystemProcess ifTrue:[
+ 'EmergencyHandler [info]: exception cought: ' errorPrint.
+ ex signal == NoHandlerError ifTrue:[
+ theException := ex parameter.
+ ] ifFalse:[
+ theException := ex
+ ].
+ theException description errorPrintCR.
+ AbortSignal raise.
+ ] ifFalse:[
+ (ex signal == NoHandlerError
+ and:[ex parameter signal inheritsFrom:ControlInterrupt]) ifTrue:[
+ "/ go directly into the debugger ...
+ Debugger
+ enter:ex suspendedContext
+ withMessage:ex description
+ mayProceed:true
+ ] ifFalse:[
+ "/ ask, and maybe go into the debugger ...
+ nil
+ errorNotify:ex description
+ from:ex suspendedContext
+ allowDebug:true
+ ]
+ ]
]
"test with:
@@ -1390,7 +1390,7 @@
"return the creator of the exception"
signal == nil ifTrue:[
- ^ self class
+ ^ self class
].
^ signal
!
@@ -1579,8 +1579,8 @@
try per signal handler
"
(handlerBlock := signal handlerBlock) notNil ifTrue:[
- "... and call it"
- ^ handlerBlock value:self.
+ "... and call it"
+ ^ handlerBlock value:self.
].
"/ if its a querySignal, ignore it
@@ -1613,21 +1613,21 @@
|msg|
rejected == true ifTrue:[
- msg := 'unhandled (rejected)'
+ msg := 'unhandled (rejected)'
] ifFalse:[
- msg := 'unhandled'
+ msg := 'unhandled'
].
msg := msg , ' exception: (' , self description , ')'.
self mayProceed ifTrue:[
- ^ NoHandlerError
- raiseRequestWith:self
- errorString:msg
- in:suspendedContext.
+ ^ NoHandlerError
+ raiseRequestWith:self
+ errorString:msg
+ in:suspendedContext.
].
NoHandlerError
- raiseWith:self
- errorString:msg
- in:suspendedContext.
+ raiseWith:self
+ errorString:msg
+ in:suspendedContext.
! !
@@ -1648,9 +1648,9 @@
VW compatibility."
self isResumable ifTrue:[
- self resume:(self defaultResumeValue)
+ self resume:(self defaultResumeValue)
] ifFalse:[
- self return:(self defaultReturnValue)
+ self return:(self defaultReturnValue)
]
"Modified: / 7.9.2001 / 13:28:54 / cg"
@@ -1661,9 +1661,9 @@
VW compatibility."
self isResumable ifTrue:[
- self resume:value
+ self resume:value
] ifFalse:[
- self return:value
+ self return:value
]
"Created: / 7.9.2001 / 13:29:55 / cg"
@@ -1676,13 +1676,13 @@
self proceedWith:(self defaultResumeValue).
"cg: a strange example:
- there are two cought errors here - can you spot them ?
+ there are two cought errors here - can you spot them ?
Object errorSignal handle:[:ex|
- 'proceeding' printCR.
- ex proceed
+ 'proceeding' printCR.
+ ex proceed
] do:[
- Object errorSignal raiseRequest
+ Object errorSignal raiseRequest
].
"
@@ -1713,7 +1713,7 @@
con := Context findFirstSpecialHandle:false raise:true.
[con notNil
and:[con receiver ~~ self]] whileTrue:[
- con := con findSpecialHandle:false raise:true.
+ con := con findSpecialHandle:false raise:true.
].
"/ now, have the doCallXXX context at-hand
con := con sender.
@@ -1738,7 +1738,7 @@
con := Context findFirstSpecialHandle:false raise:true.
[con notNil
and:[con receiver ~~ self]] whileTrue:[
- con := con findSpecialHandle:false raise:true.
+ con := con findSpecialHandle:false raise:true.
].
"/ now, have the doCallXXX context at-hand
@@ -1747,15 +1747,15 @@
"
Object errorSignal handle:[:ex |
- '1' printCR.
- ex reject
+ '1' printCR.
+ ex reject
] do:[
- Object errorSignal handle:[:ex |
- '2' printCR.
- ex reject
- ] do:[
- #() at:1
- ]
+ Object errorSignal handle:[:ex |
+ '2' printCR.
+ ex reject
+ ] do:[
+ #() at:1
+ ]
]
"
!
@@ -1767,17 +1767,17 @@
con := suspendedContext.
con canReturn ifFalse:[
- "the context that triggered the exception cannot return.
- This is a fallback: return the the context of the raise*.
- We know, that this context is returnable"
-
- con := Context findFirstSpecialHandle:false raise:true.
- [con notNil and:[con receiver ~~ self]] whileTrue:[
- con := con findSpecialHandle:false raise:true.
- ].
- [con notNil and:[con sender ~~ suspendedContext]] whileTrue:[
- con := con sender.
- ].
+ "the context that triggered the exception cannot return.
+ This is a fallback: return the the context of the raise*.
+ We know, that this context is returnable"
+
+ con := Context findFirstSpecialHandle:false raise:true.
+ [con notNil and:[con receiver ~~ self]] whileTrue:[
+ con := con findSpecialHandle:false raise:true.
+ ].
+ [con notNil and:[con sender ~~ suspendedContext]] whileTrue:[
+ con := con sender.
+ ].
].
handlerContext := suspendedContext := nil.
con unwindThenDo:[anotherException raiseSignal].
@@ -1786,9 +1786,9 @@
|rslt|
ZeroDivide handle:[:ex |
- ex resignalAs:Number domainErrorSignal
+ ex resignalAs:Number domainErrorSignal
] do:[
- rslt := 5 // 0
+ rslt := 5 // 0
].
rslt
"
@@ -1797,9 +1797,9 @@
|rslt|
MessageNotUnderstood handle:[:ex |
- ex resignalAs:Number domainErrorSignal
+ ex resignalAs:Number domainErrorSignal
] do:[
- rslt := 1 perform:#foo
+ rslt := 1 perform:#foo
].
rslt
"
@@ -1819,11 +1819,11 @@
|rslt n|
Object errorSignal handle:[:ex |
- 'fixing divisor ...' printCR.
- n := 1.
- ex restart.
+ 'fixing divisor ...' printCR.
+ n := 1.
+ ex restart.
] do:[
- rslt := 5 / n.
+ rslt := 5 / n.
].
rslt
"
@@ -1852,10 +1852,10 @@
sig := Signal new.
sig handle:[:ex |
- ex restartDo:[ rslt := 999 ]
+ ex restartDo:[ rslt := 999 ]
] do:[
- rslt := 0.
- sig raise
+ rslt := 0.
+ sig raise
].
Transcript showCR:rslt
"
@@ -1864,9 +1864,9 @@
|sig rslt|
Object errorSignal handle:[:ex |
- ex restartDo:[ rslt := 999 ]
+ ex restartDo:[ rslt := 999 ]
] do:[
- rslt := nil foo.
+ rslt := nil foo.
].
Transcript showCR:rslt
@@ -1876,9 +1876,9 @@
|sig rslt|
Object errorSignal handle:[:ex |
- ex restartDo:[ 'handler' printCR. rslt := nil foo ]
+ ex restartDo:[ 'handler' printCR. rslt := nil foo ]
] do:[
- rslt := nil foo.
+ rslt := nil foo.
].
Transcript showCR:rslt
@@ -1976,13 +1976,13 @@
sigDescr := signal description.
(errorString isNil or:[ errorString isString not])
ifTrue:[
- ^ sigDescr
+ ^ sigDescr
].
(errorString startsWith:Character space) ifTrue:[
- ^ sigDescr, errorString.
+ ^ sigDescr, errorString.
].
(errorString endsWith:Character space) ifTrue:[
- ^ errorString, sigDescr.
+ ^ errorString, sigDescr.
].
^ errorString
@@ -2028,11 +2028,11 @@
"/ thisContext markForRaise. -- same as above pragma
aHandlerBlock numArgs == 0 ifTrue:[
- "/ 0-arg handler - not interested in the ex - object
- val := aHandlerBlock value
+ "/ 0-arg handler - not interested in the ex - object
+ val := aHandlerBlock value
] ifFalse:[
- "/ 1-arg handler - pass myself as ex-arg
- val := aHandlerBlock value:self.
+ "/ 1-arg handler - pass myself as ex-arg
+ val := aHandlerBlock value:self.
].
"
@@ -2065,12 +2065,12 @@
"/ instanceVariable to record the originator setting.
originator isNil ifTrue:[
- originator := suspendedContext homeReceiver
+ originator := suspendedContext homeReceiver
].
theSignal := signal.
theSignal isExceptionCreator ifFalse:[
- GenericException raiseWith:theSignal errorString:'unexpected non-ExceptionCreator in calling context'.
+ GenericException raiseWith:theSignal errorString:'unexpected non-ExceptionCreator in calling context'.
].
"/ 'search handler for: ' print. theSignal displayString printCR.
@@ -2092,45 +2092,45 @@
c := Context findFirstSpecialHandle:searchForHandle raise:true.
[c notNil] whileTrue:[
- (c isRaiseContext) ifTrue:[
- ex1 := c receiver. "exception, that has been raised before"
- h := ex1 handlerContext. "the context of the previous exception handler"
- h notNil ifTrue:[
- sig1 := ex1 signal. "the signal that has been raised before"
- (sig1 == theSignal "are we going to raise the same signal again"
-
- "/ mhmh - if not ==, the raised signal there is not ours,
- "/ but the handler could still be for a signalSet, parentSig
- "/ or other thingy which accepts our signal.
- "/ If we omit that check, a signalSet-handler gets invoked
- "/ again by an exception occuring inside its handler.
-
- "/ to avoid overhead, only do it if the
- "/ handlers receiver is not of the signals class...
- "/ ...i.e. knowing that most are r handle:do: contexts,
- "/ where the receiver is the handling signal.
-
- "is the signal that has been raised different
- from the signal that has been handled?"
- or:[(h receiver handlingExceptionInContext:h) ~~ sig1
- and:[ex1 handlingException accepts:theSignal]]) ifTrue:[
- "...and will the previous handler accept the signal
- we are going to raise?"
- activeHandlers isNil ifTrue:[
- activeHandlers := OrderedCollection new
- ].
-
- activeHandlers add:h.
- "/ lastHandler := h.
- c := h.
- ]
- ]
- ] ifFalse:[
- "/ must be a handle context ...
- firstHandler := c.
- searchForHandle := false.
- ].
- c := c findSpecialHandle:searchForHandle raise:true.
+ (c isRaiseContext) ifTrue:[
+ ex1 := c receiver. "exception, that has been raised before"
+ h := ex1 handlerContext. "the context of the previous exception handler"
+ h notNil ifTrue:[
+ sig1 := ex1 signal. "the signal that has been raised before"
+ (sig1 == theSignal "are we going to raise the same signal again"
+
+ "/ mhmh - if not ==, the raised signal there is not ours,
+ "/ but the handler could still be for a signalSet, parentSig
+ "/ or other thingy which accepts our signal.
+ "/ If we omit that check, a signalSet-handler gets invoked
+ "/ again by an exception occuring inside its handler.
+
+ "/ to avoid overhead, only do it if the
+ "/ handlers receiver is not of the signals class...
+ "/ ...i.e. knowing that most are r handle:do: contexts,
+ "/ where the receiver is the handling signal.
+
+ "is the signal that has been raised different
+ from the signal that has been handled?"
+ or:[(h receiver handlingExceptionInContext:h) ~~ sig1
+ and:[ex1 handlingException accepts:theSignal]]) ifTrue:[
+ "...and will the previous handler accept the signal
+ we are going to raise?"
+ activeHandlers isNil ifTrue:[
+ activeHandlers := OrderedCollection new
+ ].
+
+ activeHandlers add:h.
+ "/ lastHandler := h.
+ c := h.
+ ]
+ ]
+ ] ifFalse:[
+ "/ must be a handle context ...
+ firstHandler := c.
+ searchForHandle := false.
+ ].
+ c := c findSpecialHandle:searchForHandle raise:true.
].
h := nil.
@@ -2147,41 +2147,41 @@
"/ theContext := lastHandler.
"/ theContext := lastHandler findNextHandleContext
"/ ] ifFalse:[
- theContext := firstHandler.
+ theContext := firstHandler.
"/ ].
firstHandler := nil.
[theContext notNil] whileTrue:[
- "/
- "/ ask the Signal instance/Exception class for the handler.
- "/ nil is returned, if the signal is not accepted
- "/
- r := theContext receiver.
- (r notNil and:[(handler := r handlerForSignal:signal
- context:theContext
- originator:originator) notNil]
- ) ifTrue:[
- (activeHandlers notNil
- and:[activeHandlers includesIdentical:theContext]) ifTrue:[
+ "/
+ "/ ask the Signal instance/Exception class for the handler.
+ "/ nil is returned, if the signal is not accepted
+ "/
+ r := theContext receiver.
+ (r notNil and:[(handler := r handlerForSignal:signal
+ context:theContext
+ originator:originator) notNil]
+ ) ifTrue:[
+ (activeHandlers notNil
+ and:[activeHandlers includesIdentical:theContext]) ifTrue:[
"/ 'skip activeHandler: ' print. theContext displayString printCR.
- ] ifFalse:[
- "call the handler"
-
- handlerContext := theContext.
- "/ remember the handling signal, sigSet, or exception
- "/ for the #accepts: check above
- handlingException := r handlingExceptionInContext:theContext.
- theContext := nil.
- self doCallHandler:handler.
-
- "/ if the handler rejects, we arrive here
- "/ continue search for another handler
- theContext := handlerContext.
- handlerContext := nil.
- ].
- ].
- theContext := theContext findSpecialHandle:true raise:false.
+ ] ifFalse:[
+ "call the handler"
+
+ handlerContext := theContext.
+ "/ remember the handling signal, sigSet, or exception
+ "/ for the #accepts: check above
+ handlingException := r handlingExceptionInContext:theContext.
+ theContext := nil.
+ self doCallHandler:handler.
+
+ "/ if the handler rejects, we arrive here
+ "/ continue search for another handler
+ theContext := handlerContext.
+ handlerContext := nil.
+ ].
+ ].
+ theContext := theContext findSpecialHandle:true raise:false.
].
"/ help GC a bit, by clearing things we no longer need
@@ -2207,7 +2207,7 @@
<context: #return>
suspendedContext isNil ifTrue:[
- suspendedContext := thisContext sender
+ suspendedContext := thisContext sender
].
proceedable := false.
@@ -2223,17 +2223,17 @@
<context: #return>
suspendedContext isNil ifTrue:[
- suspendedContext := thisContext sender
+ suspendedContext := thisContext sender
].
self mayProceed ifFalse:[
- StrictRaising ifTrue:[
- "/ proceeding from wrongProceedabilitySignal grants the raiseRequest
- WrongProceedabilityError raiseRequestWith:signal
- ] ifFalse:[
- 'Exception [warning]: raised with wrong proceedability: ' infoPrint.
- self class name infoPrintCR.
- ]
+ StrictRaising ifTrue:[
+ "/ proceeding from wrongProceedabilitySignal grants the raiseRequest
+ WrongProceedabilityError raiseRequestWith:signal
+ ] ifFalse:[
+ 'Exception [warning]: raised with wrong proceedability: ' infoPrint.
+ self class name infoPrintCR.
+ ]
].
proceedable := true.
@@ -2249,7 +2249,7 @@
<context: #return>
self mayProceed ifFalse:[
- ^ self raise
+ ^ self raise
].
^ self raiseRequest
! !
@@ -2333,7 +2333,7 @@
!GenericException class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/GenericException.st,v 1.83 2004-03-04 16:38:57 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/GenericException.st,v 1.84 2004-03-04 17:36:22 cg Exp $'
! !
GenericException initialize!