diff --git a/ChangeLog b/ChangeLog index eb370e9ea3..4edcae75ed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15,6 +15,18 @@ * Source/NSFileManager.m: Fixed NSFileManager thread safety. +2023-07-17 Yavor Doganov + + * Tests/base/NSTimeZone/localtime.m (testTZDB): Skip tests relying + on 64bit time_t on all 32bit architectures. + * Source/NSTimeZone.m: Move #include "tzdb.h" a bit earlier so + that the POSIX_TZONES preprocessor conditional is correct. + ([GSTimeZoneDetail + initWithTimeZone:withAbbrev:withOffset:withDST:]): Retain abbrev. + ([GSTimeZoneDetail dealloc]): Release abbrev. + ([NSTimeZone timeZoneArray]): Skip files *.zi, *.list and + leapseconds which are not zone files. + 2023-06-10 Riccardo Mottola * Tests/base/NSURL/Helpers/Launch.h: diff --git a/Source/NSTimeZone.m b/Source/NSTimeZone.m index c1c4135d5c..13630b6a66 100644 --- a/Source/NSTimeZone.m +++ b/Source/NSTimeZone.m @@ -153,6 +153,11 @@ Default place for the NSTimeZone directory is _time_zone_path(): /* Many systems have this file */ #define SYSTEM_TIME_FILE @"/etc/localtime" +/* Include public domain code (modified for use here) to parse standard + * posix time zone files. + */ +#include "tzdb.h" + /* If TZDIR told us where the zoneinfo files are, don't append anything else */ #ifdef TZDIR #define POSIX_TZONES @"" @@ -163,11 +168,6 @@ Default place for the NSTimeZone directory is _time_zone_path(): #define BUFFER_SIZE 512 #define WEEK_MILLISECONDS (7.0*24.0*60.0*60.0*1000.0) -/* Include public domain code (modified for use here) to parse standard - * posix time zone files. - */ -#include "tzdb.h" - #if GS_USE_ICU == 1 static inline int _NSToICUTZDisplayStyle(NSTimeZoneNameStyle style) @@ -806,6 +806,7 @@ @implementation GSTimeZoneDetail - (void) dealloc { + RELEASE(abbrev); RELEASE(timeZone); DEALLOC } @@ -824,7 +825,7 @@ - (id) initWithTimeZone: (NSTimeZone*)aZone withDST: (BOOL)isDST { timeZone = RETAIN(aZone); - abbrev = anAbbrev; // NB. Depend on this being retained in aZone + abbrev = RETAIN(anAbbrev); offset = anOffset; is_dst = isDST; return self; @@ -1849,12 +1850,17 @@ + (NSArray*) timeZoneArray while ((name = [enumerator nextObject]) != nil) { NSTimeZone *zone = nil; + NSString *ext; BOOL isDir; path = [zonedir stringByAppendingPathComponent: name]; + ext = [path pathExtension]; if ([mgr fileExistsAtPath: path isDirectory: &isDir] && isDir == NO - && [[path pathExtension] isEqual: @"tab"] == NO) + && [ext isEqual: @"tab"] == NO + && [ext isEqual: @"zi"] == NO + && [ext isEqual: @"list"] == NO + && [ext isEqual: @"leapseconds"] == NO) { zone = [zoneDictionary objectForKey: name]; if (zone == nil) diff --git a/Tests/base/NSTimeZone/localtime.m b/Tests/base/NSTimeZone/localtime.m index 37b5924276..f94be7991f 100644 --- a/Tests/base/NSTimeZone/localtime.m +++ b/Tests/base/NSTimeZone/localtime.m @@ -41,6 +41,7 @@ "post-1996 DST time offset vs UTC found for user-supplied %s", message); +#if __LP64__ /* After 32bit value seconds-since-1970 using TZDB v2+ file */ if (beyond2038) { date = [NSDate dateWithString: @"2039-01-16 23:59:59 -0200"]; @@ -48,6 +49,7 @@ "post-2038 standard time offset vs UTC found for user-supplied %s", message); } +#endif return; }