Patches from Yoo C. Chung

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@2546 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fedor 1997-10-24 16:58:20 +00:00
parent 1780b2805c
commit 08467501bc
3 changed files with 70 additions and 34 deletions

View file

@ -1,3 +1,23 @@
Fri Oct 24 20:16:14 1997 Yoo C. Chung <wacko@laplace.snu.ac.kr>
* src/StdioStream.m ([StdioStream -dealloc]): Check fp before
closing.
Wed Oct 22 19:54:07 1997 Yoo C. Chung <wacko@laplace.snu.ac.kr>
* src/NSTimeZone.m ([NSTimeZone +initialize]): Fallback time zone
now only set to UTC.
(NSConcreteTimeZoneDetail): Changed method.
([NSConcreteTimeZoneDetail -timeZoneDetailForDate:]): New method.
([NSConcreteTimeZoneDetail -timeZoneName]): Likewise.
([NSConcreteTimeZoneDetail -timeZoneDetailArray]): Likewise.
([NSTimeZone +timeZoneWithName:]): Updated for changed methods in
NSTimeZoneDetail.
([NSInternalTimeTransition -description]): Print class name.
([NSConcreteTimeZone -description]): Likewise.
([NSConcreteAbsoluteTimeZone -description]): Likewise.
([NSConcreteTimeZoneDetail -description]): Likewise.
Mon Oct 20 09:51:53 1997 Adam Fedor <fedor@doc.com> Mon Oct 20 09:51:53 1997 Adam Fedor <fedor@doc.com>
* Version: Update ftp sites. * Version: Update ftp sites.

View file

@ -32,8 +32,8 @@
The local time zone can be specified with the user defaults The local time zone can be specified with the user defaults
database, the TZ environment variable, the file LOCAL_TIME_FILE, or database, the TZ environment variable, the file LOCAL_TIME_FILE, or
the fallback local time zone, with the ones listed first having the fallback time zone (which is UTC), with the ones listed first
precedence. having precedence.
Any time zone must be a file name in ZONES_DIR. Any time zone must be a file name in ZONES_DIR.
@ -65,11 +65,6 @@
/* Key for local time zone in user defaults. */ /* Key for local time zone in user defaults. */
#define LOCALDBKEY "Local Time Zone" #define LOCALDBKEY "Local Time Zone"
/* Fallback local time zone. */
#ifndef LOCAL_TIME_ZONE
#define LOCAL_TIME_ZONE "Universal"
#endif
/* Directory that contains the time zone data. */ /* Directory that contains the time zone data. */
#define TIME_ZONE_DIR @"gnustep/NSTimeZones" #define TIME_ZONE_DIR @"gnustep/NSTimeZones"
@ -195,13 +190,14 @@ decode (const void *ptr)
@interface NSConcreteTimeZoneDetail : NSTimeZoneDetail @interface NSConcreteTimeZoneDetail : NSTimeZoneDetail
{ {
NSTimeZone *timeZone; // Time zone which created this object.
NSString *abbrev; // Abbreviation for time zone detail. NSString *abbrev; // Abbreviation for time zone detail.
int offset; // Offset from UTC in seconds. int offset; // Offset from UTC in seconds.
BOOL is_dst; // Is it daylight savings time? BOOL is_dst; // Is it daylight savings time?
} }
- initWithAbbrev: (NSString*)anAbbrev withOffset: (int)anOffset - initWithTimeZone: (NSTimeZone*)aZone withAbbrev: (NSString*)anAbbrev
withDST: (BOOL)isDST; withOffset: (int)anOffset withDST: (BOOL)isDST;
@end @end
@ -253,8 +249,8 @@ decode (const void *ptr)
- (NSString*)description - (NSString*)description
{ {
return [NSString return [NSString
stringWithFormat: @"(trans: %d, idx: %d)", stringWithFormat: @"%@(%d, %d)",
trans_time, (int)detail_index]; [self class], trans_time, (int)detail_index];
} }
- initWithTime: (int)aTime withIndex: (char)anIndex - initWithTime: (int)aTime withIndex: (char)anIndex
@ -313,8 +309,9 @@ decode (const void *ptr)
- (NSString*)description - (NSString*)description
{ {
return [NSString stringWithFormat: @"(trans: %@, details: %@)", return [NSString
[transitions description], [details description]]; stringWithFormat: @"%@(%@, %@)",
[self class], transitions, details];
} }
- (NSTimeZoneDetail*)timeZoneDetailForDate: (NSDate*)date - (NSTimeZoneDetail*)timeZoneDetailForDate: (NSDate*)date
@ -386,7 +383,8 @@ decode (const void *ptr)
[super init]; [super init];
name = [aName retain]; name = [aName retain];
detail = [[NSConcreteTimeZoneDetail alloc] detail = [[NSConcreteTimeZoneDetail alloc]
initWithAbbrev: name withOffset: offset withDST: NO]; initWithTimeZone: self withAbbrev: name
withOffset: offset withDST: NO];
offset = anOffset; offset = anOffset;
return self; return self;
} }
@ -414,7 +412,7 @@ decode (const void *ptr)
- (NSString*)description - (NSString*)description
{ {
return [NSString stringWithFormat: @"(offset: %d)", offset]; return [NSString stringWithFormat: @"%@(%d)", [self class], offset];
} }
- (NSTimeZoneDetail*)timeZoneDetailForDate: (NSDate*)date - (NSTimeZoneDetail*)timeZoneDetailForDate: (NSDate*)date
@ -437,10 +435,11 @@ decode (const void *ptr)
@implementation NSConcreteTimeZoneDetail @implementation NSConcreteTimeZoneDetail
- initWithAbbrev: (NSString*)anAbbrev withOffset: (int)anOffset - initWithTimeZone: (NSTimeZone*)aZone withAbbrev: (NSString*)anAbbrev
withDST: (BOOL)isDST withOffset: (int)anOffset withDST: (BOOL)isDST
{ {
[super init]; [super init];
timeZone = [aZone retain];
abbrev = [anAbbrev retain]; abbrev = [anAbbrev retain];
offset = anOffset; offset = anOffset;
is_dst = isDST; is_dst = isDST;
@ -470,10 +469,27 @@ decode (const void *ptr)
return self; return self;
} }
- (NSTimeZoneDetail*)timeZoneDetailForDate: (NSDate*)date
{
return [timeZone timeZoneDetailForDate: date];
}
- (NSString*)timeZoneName
{
return [timeZone timeZoneName];
}
- (NSArray*)timeZoneDetailArray
{
return [timeZone timeZoneDetailArray];
}
- (NSString*)description - (NSString*)description
{ {
return [NSString stringWithFormat: @"(abbrev: %@, offset: %d, is_dst: %d)", return [NSString
abbrev, offset, (int)is_dst]; stringWithFormat: @"%@(%@, %@, %d, %d)",
[self class], [timeZone timeZoneName],
abbrev, offset, (int)is_dst];
} }
- (BOOL)isDaylightSavingTimeZone - (BOOL)isDaylightSavingTimeZone
@ -522,8 +538,8 @@ decode (const void *ptr)
fp = fopen([f cStringNoCopy], "r"); fp = fopen([f cStringNoCopy], "r");
if (fp != NULL) if (fp != NULL)
{ {
fscanf(fp, "%79s", zone_name); if (fscanf(fp, "%79s", zone_name) == 1)
localZoneString = [NSString stringWithCString: zone_name]; localZoneString = [NSString stringWithCString: zone_name];
fclose(fp); fclose(fp);
} }
} }
@ -533,13 +549,16 @@ decode (const void *ptr)
if (localZoneString != nil) if (localZoneString != nil)
localTimeZone = [NSTimeZone timeZoneWithName: localZoneString]; localTimeZone = [NSTimeZone timeZoneWithName: localZoneString];
else else
localTimeZone = [NSTimeZone timeZoneWithName: @LOCAL_TIME_ZONE]; NSLog(@"No local time zone specified.");
/* If local time zone fails to allocate, then allocate something /* If local time zone fails to allocate, then allocate something
that is sure to succeed (unless we run out of memory, of that is sure to succeed (unless we run out of memory, of
course). */ course). */
if (localTimeZone == nil) if (localTimeZone == nil)
localTimeZone = [NSTimeZone timeZoneForSecondsFromGMT: 0]; {
NSLog(@"Local time zone either not specified or incorrect.");
localTimeZone = [NSTimeZone timeZoneForSecondsFromGMT: 0];
}
fake_abbrev_dict = [[NSInternalAbbrevDict alloc] init]; fake_abbrev_dict = [[NSInternalAbbrevDict alloc] init];
zoneDictionary = [[NSMutableDictionary alloc] init]; zoneDictionary = [[NSMutableDictionary alloc] init];
@ -632,6 +651,8 @@ decode (const void *ptr)
} }
NS_DURING NS_DURING
zone = [NSConcreteTimeZone alloc];
/* Read header. */ /* Read header. */
if (fread(&header, sizeof(struct tzhead), 1, file) != 1) if (fread(&header, sizeof(struct tzhead), 1, file) != 1)
[NSException raise: fileException format: nil]; [NSException raise: fileException format: nil];
@ -687,15 +708,14 @@ decode (const void *ptr)
for (i = 0; i < n_types; i++) for (i = 0; i < n_types; i++)
[detailsArray [detailsArray
addObject: [[NSConcreteTimeZoneDetail alloc] addObject: [[NSConcreteTimeZoneDetail alloc]
initWithAbbrev: abbrevsArray[types[i].abbr_idx] initWithTimeZone: zone
withAbbrev: abbrevsArray[types[i].abbr_idx]
withOffset: types[i].offset withOffset: types[i].offset
withDST: (types[i].isdst > 0)]]; withDST: (types[i].isdst > 0)]];
NSZoneFree(NSDefaultMallocZone(), abbrevsArray); NSZoneFree(NSDefaultMallocZone(), abbrevsArray);
NSZoneFree(NSDefaultMallocZone(), types); NSZoneFree(NSDefaultMallocZone(), types);
zone = [[NSConcreteTimeZone alloc] [zone initWithName: [aTimeZoneName copy] withTransitions: transArray
initWithName: [aTimeZoneName copy] withDetails: detailsArray];
withTransitions: transArray
withDetails: detailsArray];
[zoneDictionary setObject: zone forKey: aTimeZoneName]; [zoneDictionary setObject: zone forKey: aTimeZoneName];
fclose(file); fclose(file);
NS_HANDLER NS_HANDLER
@ -813,11 +833,6 @@ decode (const void *ptr)
@implementation NSTimeZoneDetail @implementation NSTimeZoneDetail
- (NSString*)timeZoneName
{
return [self shouldNotImplement: _cmd];
}
- (BOOL)isDaylightSavingTimeZone - (BOOL)isDaylightSavingTimeZone
{ {
[self subclassResponsibility: _cmd]; [self subclassResponsibility: _cmd];

View file

@ -290,7 +290,8 @@ stdio_unchar_func(void *s, int c)
- (void) dealloc - (void) dealloc
{ {
fclose(fp); if (fp != 0)
fclose(fp);
[super dealloc]; [super dealloc];
} }