Index: src/OFData.m ================================================================== --- src/OFData.m +++ src/OFData.m @@ -434,17 +434,17 @@ return false; return true; } -- (of_comparison_result_t)compare: (id )object +- (of_comparison_result_t)compare: (id )object { OFData *data; int comparison; size_t count, minCount; - if (![object isKindOfClass: [OFData class]]) + if (![(id)object isKindOfClass: [OFData class]]) @throw [OFInvalidArgumentException exception]; data = (OFData *)object; if ([data itemSize] != _itemSize) Index: src/OFDate.m ================================================================== --- src/OFDate.m +++ src/OFDate.m @@ -395,15 +395,15 @@ - (id)copy { return [self retain]; } -- (of_comparison_result_t)compare: (id )object +- (of_comparison_result_t)compare: (id )object { OFDate *otherDate; - if (![object isKindOfClass: [OFDate class]]) + if (![(id)object isKindOfClass: [OFDate class]]) @throw [OFInvalidArgumentException exception]; otherDate = (OFDate *)object; if (_seconds < otherDate->_seconds) Index: src/OFNumber.m ================================================================== --- src/OFNumber.m +++ src/OFNumber.m @@ -761,15 +761,15 @@ return ([number intMaxValue] == [self intMaxValue]); return ([number uIntMaxValue] == [self uIntMaxValue]); } -- (of_comparison_result_t)compare: (id )object +- (of_comparison_result_t)compare: (id )object { OFNumber *number; - if (![object isKindOfClass: [OFNumber class]]) + if (![(id)object isKindOfClass: [OFNumber class]]) @throw [OFInvalidArgumentException exception]; number = (OFNumber *)object; if (_type & OF_NUMBER_TYPE_FLOAT || Index: src/OFStream.m ================================================================== --- src/OFStream.m +++ src/OFStream.m @@ -23,14 +23,10 @@ #include #include #include #include -#ifdef HAVE_FCNTL_H -# include -#endif - #include "platform.h" #if !defined(OF_WINDOWS) && !defined(OF_MORPHOS) # include #endif @@ -1639,71 +1635,11 @@ return _blocking; } - (void)setBlocking: (bool)enable { -#ifdef HAVE_FCNTL - bool readImplemented = false, writeImplemented = false; - - @try { - int readFlags; - - readFlags = fcntl([self fileDescriptorForReading], F_GETFL); - - readImplemented = true; - - if (readFlags == -1) - @throw [OFSetOptionFailedException - exceptionWithStream: self - errNo: errno]; - - if (enable) - readFlags &= ~O_NONBLOCK; - else - readFlags |= O_NONBLOCK; - - if (fcntl([self fileDescriptorForReading], F_SETFL, - readFlags) == -1) - @throw [OFSetOptionFailedException - exceptionWithStream: self - errNo: errno]; - } @catch (OFNotImplementedException *e) { - } - - @try { - int writeFlags; - - writeFlags = fcntl([self fileDescriptorForWriting], F_GETFL); - - writeImplemented = true; - - if (writeFlags == -1) - @throw [OFSetOptionFailedException - exceptionWithStream: self - errNo: errno]; - - if (enable) - writeFlags &= ~O_NONBLOCK; - else - writeFlags |= O_NONBLOCK; - - if (fcntl([self fileDescriptorForWriting], F_SETFL, - writeFlags) == -1) - @throw [OFSetOptionFailedException - exceptionWithStream: self - errNo: errno]; - } @catch (OFNotImplementedException *e) { - } - - if (!readImplemented && !writeImplemented) - @throw [OFNotImplementedException exceptionWithSelector: _cmd - object: self]; - - _blocking = enable; -#else OF_UNRECOGNIZED_SELECTOR -#endif } - (int)fileDescriptorForReading { OF_UNRECOGNIZED_SELECTOR @@ -1748,8 +1684,7 @@ _writeBuffer = NULL; _writeBufferLength = 0; _writeBuffered = false; _waitingForDelimiter = false; - _blocking = false; } @end Index: src/OFStreamSocket.m ================================================================== --- src/OFStreamSocket.m +++ src/OFStreamSocket.m @@ -18,14 +18,19 @@ #include "config.h" #include #include + +#ifdef HAVE_FCNTL_H +# include +#endif #import "OFStreamSocket.h" #import "OFInitializationFailedException.h" +#import "OFNotImplementedException.h" #import "OFNotOpenException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFSetOptionFailedException.h" #import "OFWriteFailedException.h" @@ -120,22 +125,83 @@ #endif return (size_t)bytesWritten; } -#ifdef OF_WINDOWS - (void)setBlocking: (bool)enable { - u_long v = enable; +#if defined(HAVE_FCNTL) + bool readImplemented = false, writeImplemented = false; + + @try { + int readFlags; + + readFlags = fcntl([self fileDescriptorForReading], F_GETFL); + + readImplemented = true; + + if (readFlags == -1) + @throw [OFSetOptionFailedException + exceptionWithStream: self + errNo: errno]; + + if (enable) + readFlags &= ~O_NONBLOCK; + else + readFlags |= O_NONBLOCK; + + if (fcntl([self fileDescriptorForReading], F_SETFL, + readFlags) == -1) + @throw [OFSetOptionFailedException + exceptionWithStream: self + errNo: errno]; + } @catch (OFNotImplementedException *e) { + } + + @try { + int writeFlags; + + writeFlags = fcntl([self fileDescriptorForWriting], F_GETFL); + + writeImplemented = true; + + if (writeFlags == -1) + @throw [OFSetOptionFailedException + exceptionWithStream: self + errNo: errno]; + + if (enable) + writeFlags &= ~O_NONBLOCK; + else + writeFlags |= O_NONBLOCK; + + if (fcntl([self fileDescriptorForWriting], F_SETFL, + writeFlags) == -1) + @throw [OFSetOptionFailedException + exceptionWithStream: self + errNo: errno]; + } @catch (OFNotImplementedException *e) { + } + + if (!readImplemented && !writeImplemented) + @throw [OFNotImplementedException exceptionWithSelector: _cmd + object: self]; + _blocking = enable; +#elif defined(OF_WINDOWS) + u_long v = enable; if (ioctlsocket(_socket, FIONBIO, &v) == SOCKET_ERROR) @throw [OFSetOptionFailedException exceptionWithStream: self errNo: of_socket_errno()]; -} + + _blocking = enable; +#else + OF_UNRECOGNIZED_SELECTOR #endif +} - (int)fileDescriptorForReading { #ifndef OF_WINDOWS return _socket; Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -1550,21 +1550,21 @@ - (id)mutableCopy { return [[OFMutableString alloc] initWithString: self]; } -- (of_comparison_result_t)compare: (id )object +- (of_comparison_result_t)compare: (id )object { void *pool; OFString *otherString; const of_unichar_t *characters, *otherCharacters; size_t minimumLength; if (object == self) return OF_ORDERED_SAME; - if (![object isKindOfClass: [OFString class]]) + if (![(id)object isKindOfClass: [OFString class]]) @throw [OFInvalidArgumentException exception]; otherString = (OFString *)object; minimumLength = ([self length] > [otherString length] ? [otherString length] : [self length]); Index: src/OFString_UTF8.m ================================================================== --- src/OFString_UTF8.m +++ src/OFString_UTF8.m @@ -806,20 +806,20 @@ return false; return true; } -- (of_comparison_result_t)compare: (id )object +- (of_comparison_result_t)compare: (id )object { OFString *otherString; size_t otherCStringLength, minimumCStringLength; int compare; if (object == self) return OF_ORDERED_SAME; - if (![object isKindOfClass: [OFString class]]) + if (![(id)object isKindOfClass: [OFString class]]) @throw [OFInvalidArgumentException exception]; otherString = (OFString *)object; otherCStringLength = [otherString UTF8StringLength]; minimumCStringLength = (_s->cStringLength > otherCStringLength Index: src/OFTimer.m ================================================================== --- src/OFTimer.m +++ src/OFTimer.m @@ -504,15 +504,15 @@ #endif [super dealloc]; } -- (of_comparison_result_t)compare: (id )object +- (of_comparison_result_t)compare: (id )object { OFTimer *timer; - if (![object isKindOfClass: [OFTimer class]]) + if (![(id)object isKindOfClass: [OFTimer class]]) @throw [OFInvalidArgumentException exception]; timer = (OFTimer *)object; return [_fireDate compare: timer->_fireDate];