@@ -46,90 +46,92 @@ defined(OF_THREADS) static OFMutex *mutex; #endif #ifdef HAVE_GMTIME_R -# define GMTIME_RET(field) \ - time_t seconds_ = (time_t)seconds; \ - struct tm tm; \ - \ - if (seconds_ != floor(seconds)) \ - @throw [OFOutOfRangeException newWithClass: isa]; \ - \ - if (gmtime_r(&seconds_, &tm) == NULL) \ - @throw [OFOutOfRangeException newWithClass: isa]; \ - \ +# define GMTIME_RET(field) \ + time_t seconds_ = (time_t)seconds; \ + struct tm tm; \ + \ + if (seconds_ != floor(seconds)) \ + @throw [OFOutOfRangeException exceptionWithClass: isa]; \ + \ + if (gmtime_r(&seconds_, &tm) == NULL) \ + @throw [OFOutOfRangeException exceptionWithClass: isa]; \ + \ return tm.field; -# define LOCALTIME_RET(field) \ - time_t seconds_ = (time_t)seconds; \ - struct tm tm; \ - \ - if (seconds_ != floor(seconds)) \ - @throw [OFOutOfRangeException newWithClass: isa]; \ - \ - if (localtime_r(&seconds_, &tm) == NULL) \ - @throw [OFOutOfRangeException newWithClass: isa]; \ - \ +# define LOCALTIME_RET(field) \ + time_t seconds_ = (time_t)seconds; \ + struct tm tm; \ + \ + if (seconds_ != floor(seconds)) \ + @throw [OFOutOfRangeException exceptionWithClass: isa]; \ + \ + if (localtime_r(&seconds_, &tm) == NULL) \ + @throw [OFOutOfRangeException exceptionWithClass: isa]; \ + \ return tm.field; #else # ifdef OF_THREADS -# define GMTIME_RET(field) \ - time_t seconds_ = (time_t)seconds; \ - struct tm *tm; \ - \ - if (seconds_ != floor(seconds)) \ - @throw [OFOutOfRangeException newWithClass: isa]; \ - \ - [mutex lock]; \ - \ - @try { \ - if ((tm = gmtime(&seconds_)) == NULL) \ - @throw [OFOutOfRangeException newWithClass: isa]; \ - \ - return tm->field; \ - } @finally { \ - [mutex unlock]; \ - } -# define LOCALTIME_RET(field) \ - time_t seconds_ = (time_t)seconds; \ - struct tm *tm; \ - \ - if (seconds_ != floor(seconds)) \ - @throw [OFOutOfRangeException newWithClass: isa]; \ - \ - [mutex lock]; \ - \ - @try { \ - if ((tm = localtime(&seconds_)) == NULL) \ - @throw [OFOutOfRangeException newWithClass: isa]; \ - \ - return tm->field; \ - } @finally { \ - [mutex unlock]; \ +# define GMTIME_RET(field) \ + time_t seconds_ = (time_t)seconds; \ + struct tm *tm; \ + \ + if (seconds_ != floor(seconds)) \ + @throw [OFOutOfRangeException exceptionWithClass: isa]; \ + \ + [mutex lock]; \ + \ + @try { \ + if ((tm = gmtime(&seconds_)) == NULL) \ + @throw [OFOutOfRangeException \ + exceptionWithClass: isa]; \ + \ + return tm->field; \ + } @finally { \ + [mutex unlock]; \ + } +# define LOCALTIME_RET(field) \ + time_t seconds_ = (time_t)seconds; \ + struct tm *tm; \ + \ + if (seconds_ != floor(seconds)) \ + @throw [OFOutOfRangeException exceptionWithClass: isa]; \ + \ + [mutex lock]; \ + \ + @try { \ + if ((tm = localtime(&seconds_)) == NULL) \ + @throw [OFOutOfRangeException \ + exceptionWithClass: isa]; \ + \ + return tm->field; \ + } @finally { \ + [mutex unlock]; \ } # else -# define GMTIME_RET(field) \ - time_t seconds_ = (time_t)seconds; \ - struct tm *tm; \ - \ - if (seconds_ != floor(seconds)) \ - @throw [OFOutOfRangeException newWithClass: isa]; \ - \ - if ((tm = gmtime(&seconds_)) == NULL) \ - @throw [OFOutOfRangeException newWithClass: isa]; \ - \ +# define GMTIME_RET(field) \ + time_t seconds_ = (time_t)seconds; \ + struct tm *tm; \ + \ + if (seconds_ != floor(seconds)) \ + @throw [OFOutOfRangeException exceptionWithClass: isa]; \ + \ + if ((tm = gmtime(&seconds_)) == NULL) \ + @throw [OFOutOfRangeException exceptionWithClass: isa]; \ + \ return tm->field; -# define LOCALTIME_RET(field) \ - time_t seconds_ = (time_t)seconds; \ - struct tm *tm; \ - \ - if (seconds_ != floor(seconds)) \ - @throw [OFOutOfRangeException newWithClass: isa]; \ - \ - if ((tm = localtime(&seconds_)) == NULL) \ - @throw [OFOutOfRangeException newWithClass: isa]; \ - \ +# define LOCALTIME_RET(field) \ + time_t seconds_ = (time_t)seconds; \ + struct tm *tm; \ + \ + if (seconds_ != floor(seconds)) \ + @throw [OFOutOfRangeException exceptionWithClass: isa]; \ + \ + if ((tm = localtime(&seconds_)) == NULL) \ + @throw [OFOutOfRangeException exceptionWithClass: isa]; \ + \ return tm->field; # endif #endif @implementation OFDate @@ -227,17 +229,20 @@ tm.tm_isdst = -1; if (strptime([string UTF8String], [format UTF8String], &tm) == NULL) - @throw [OFInvalidFormatException newWithClass: isa]; + @throw [OFInvalidFormatException + exceptionWithClass: isa]; if (tm.tm_gmtoff) - @throw [OFInvalidFormatException newWithClass: isa]; + @throw [OFInvalidFormatException + exceptionWithClass: isa]; if ((seconds = mktime(&tm)) == -1) - @throw [OFInvalidFormatException newWithClass: isa]; + @throw [OFInvalidFormatException + exceptionWithClass: isa]; seconds += tm.tm_gmtoff; } @catch (id e) { [self release]; @throw e; @@ -256,14 +261,16 @@ tm.tm_isdst = -1; if (strptime([string UTF8String], [format UTF8String], &tm) == NULL) - @throw [OFInvalidFormatException newWithClass: isa]; + @throw [OFInvalidFormatException + exceptionWithClass: isa]; if ((seconds = mktime(&tm)) == -1) - @throw [OFInvalidFormatException newWithClass: isa]; + @throw [OFInvalidFormatException + exceptionWithClass: isa]; } @catch (id e) { [self release]; @throw e; } @@ -277,12 +284,13 @@ @try { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; if (![[element name] isEqual: [self className]] || ![[element namespace] isEqual: OF_SERIALIZATION_NS]) - @throw [OFInvalidArgumentException newWithClass: isa - selector: _cmd]; + @throw [OFInvalidArgumentException + exceptionWithClass: isa + selector: _cmd]; seconds = [element doubleValue]; [pool release]; } @catch (id e) { @@ -337,12 +345,12 @@ - (of_comparison_result_t)compare: (id)object { OFDate *otherDate; if (![object isKindOfClass: [OFDate class]]) - @throw [OFInvalidArgumentException newWithClass: isa - selector: _cmd]; + @throw [OFInvalidArgumentException exceptionWithClass: isa + selector: _cmd]; otherDate = object; if (seconds < otherDate->seconds) return OF_ORDERED_ASCENDING; @@ -454,25 +462,25 @@ time_t seconds_ = (time_t)seconds; struct tm tm; char *buffer; if (seconds_ != floor(seconds)) - @throw [OFOutOfRangeException newWithClass: isa]; + @throw [OFOutOfRangeException exceptionWithClass: isa]; #ifdef HAVE_GMTIME_R if (gmtime_r(&seconds_, &tm) == NULL) - @throw [OFOutOfRangeException newWithClass: isa]; + @throw [OFOutOfRangeException exceptionWithClass: isa]; #else # ifdef OF_THREADS [mutex lock]; @try { # endif struct tm *tmp; if ((tmp = gmtime(&seconds_)) == NULL) - @throw [OFOutOfRangeException newWithClass: isa]; + @throw [OFOutOfRangeException exceptionWithClass: isa]; tm = *tmp; # ifdef OF_THREADS } @finally { [mutex unlock]; @@ -482,11 +490,11 @@ buffer = [self allocMemoryWithSize: of_pagesize]; @try { if (!strftime(buffer, of_pagesize, [format UTF8String], &tm)) - @throw [OFOutOfRangeException newWithClass: isa]; + @throw [OFOutOfRangeException exceptionWithClass: isa]; ret = [OFString stringWithUTF8String: buffer]; } @finally { [self freeMemory: buffer]; } @@ -500,25 +508,25 @@ time_t seconds_ = (time_t)seconds; struct tm tm; char *buffer; if (seconds_ != floor(seconds)) - @throw [OFOutOfRangeException newWithClass: isa]; + @throw [OFOutOfRangeException exceptionWithClass: isa]; #ifdef HAVE_LOCALTIME_R if (localtime_r(&seconds_, &tm) == NULL) - @throw [OFOutOfRangeException newWithClass: isa]; + @throw [OFOutOfRangeException exceptionWithClass: isa]; #else # ifdef OF_THREADS [mutex lock]; @try { # endif struct tm *tmp; if ((tmp = localtime(&seconds_)) == NULL) - @throw [OFOutOfRangeException newWithClass: isa]; + @throw [OFOutOfRangeException exceptionWithClass: isa]; tm = *tmp; # ifdef OF_THREADS } @finally { [mutex unlock]; @@ -528,11 +536,11 @@ buffer = [self allocMemoryWithSize: of_pagesize]; @try { if (!strftime(buffer, of_pagesize, [format UTF8String], &tm)) - @throw [OFOutOfRangeException newWithClass: isa]; + @throw [OFOutOfRangeException exceptionWithClass: isa]; ret = [OFString stringWithUTF8String: buffer]; } @finally { [self freeMemory: buffer]; }