Skip to content

Commit

Permalink
Add Yavor Doganov's patches
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Frith-Macdonald committed Aug 1, 2023
1 parent 0aaa530 commit ef9ad60
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
12 changes: 12 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@
* Source/NSFileManager.m:
Fixed NSFileManager thread safety.

2023-07-17 Yavor Doganov <[email protected]>

* 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 <[email protected]>

* Tests/base/NSURL/Helpers/Launch.h:
Expand Down
20 changes: 13 additions & 7 deletions Source/NSTimeZone.m
Original file line number Diff line number Diff line change
Expand Up @@ -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 @""
Expand All @@ -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)
Expand Down Expand Up @@ -806,6 +806,7 @@ @implementation GSTimeZoneDetail

- (void) dealloc
{
RELEASE(abbrev);
RELEASE(timeZone);
DEALLOC
}
Expand All @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions Tests/base/NSTimeZone/localtime.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@
"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"];
PASS([timeZone secondsFromGMTForDate: date] == 3600,
"post-2038 standard time offset vs UTC found for user-supplied %s",
message);
}
#endif

return;
}
Expand Down

0 comments on commit ef9ad60

Please sign in to comment.