Changes from richard and wacko.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@2521 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fedor 1997-10-17 13:35:52 +00:00
parent a02a4e9e88
commit 120673e03a
9 changed files with 163 additions and 117 deletions

View file

@ -1,3 +1,20 @@
Fri Oct 17 09:16:36 1997 Adam Fedor <fedor@doc.com>
* checks/Makefile.postamble: Add English.lproj dir to copy-dist.
* src/NSCalendarDate.m (-descriptionWithCalendarFormat:locale):
Use VSPRINTF_LENGTH macro to return string length.
* src/NSData.m ([NSMutableDataMalloc -setCapacity:): Use realloc
instead of objc_realloc.
* src/NSHost.m (-_initWithHostEntry:): Use memcpy instead of
memmove.
* src/UnixFileHandle.m (getAddr): Remove uneeded htonl.
Changes from Richard Frith-Macdonald <richard@brainstorm.co.uk>.
* src/NSTimeZone.m: Reformat with better spacing.
([NSTimeZone +initialize]): Find local time zone.
Changes from Yoo C. Chung <wacko@laplace.snu.ac.kr>.
Thu Oct 16 16:14:31 1997 Scott Christley <scottc@net-community.com> Thu Oct 16 16:14:31 1997 Scott Christley <scottc@net-community.com>
* checks/Makefile: Add variables to create bundle example. * checks/Makefile: Add variables to create bundle example.

View file

@ -612,9 +612,9 @@ static id long_month[12] = {@"January",
case 'y': case 'y':
++i; ++i;
if (ycent) if (ycent)
k = sprintf(&(buf[j]), "%04d", yd); k = VSPRINTF_LENGTH(sprintf(&(buf[j]), "%04d", yd));
else else
k = sprintf(&(buf[j]), "%02d", (yd - 1900)); k = VSPRINTF_LENGTH(sprintf(&(buf[j]), "%02d", (yd - 1900)));
j += k; j += k;
break; break;
@ -629,12 +629,12 @@ static id long_month[12] = {@"January",
{ {
// +++ Translate to locale character string // +++ Translate to locale character string
if (mname) if (mname)
k = sprintf(&(buf[j]), "%s", [short_month[md-1] cString]); k = VSPRINTF_LENGTH(sprintf(&(buf[j]), "%s", [short_month[md-1] cString]));
else else
k = sprintf(&(buf[j]), "%s", [long_month[md-1] cString]); k = VSPRINTF_LENGTH(sprintf(&(buf[j]), "%s", [long_month[md-1] cString]));
} }
else else
k = sprintf(&(buf[j]), "%02d", md); k = VSPRINTF_LENGTH(sprintf(&(buf[j]), "%02d", md));
j += k; j += k;
break; break;
@ -654,7 +654,7 @@ static id long_month[12] = {@"January",
k = 0; k = 0;
} }
else else
k = sprintf(&(buf[j]), "%02d", dd); k = VSPRINTF_LENGTH(sprintf(&(buf[j]), "%02d", dd));
j += k; j += k;
break; break;
@ -665,21 +665,21 @@ static id long_month[12] = {@"January",
nhd = 12; // 12pm not 0pm nhd = 12; // 12pm not 0pm
case 'H': case 'H':
++i; ++i;
k = sprintf(&(buf[j]), "%02d", nhd); k = VSPRINTF_LENGTH(sprintf(&(buf[j]), "%02d", nhd));
j += k; j += k;
break; break;
// is it the minute // is it the minute
case 'M': case 'M':
++i; ++i;
k = sprintf(&(buf[j]), "%02d", mnd); k = VSPRINTF_LENGTH(sprintf(&(buf[j]), "%02d", mnd));
j += k; j += k;
break; break;
// is it the second // is it the second
case 'S': case 'S':
++i; ++i;
k = sprintf(&(buf[j]), "%02d", sd); k = VSPRINTF_LENGTH(sprintf(&(buf[j]), "%02d", sd));
j += k; j += k;
break; break;
@ -687,17 +687,17 @@ static id long_month[12] = {@"January",
case 'p': case 'p':
++i; ++i;
if (hd >= 12) if (hd >= 12)
k = sprintf(&(buf[j]), "PM"); k = VSPRINTF_LENGTH(sprintf(&(buf[j]), "PM"));
else else
k = sprintf(&(buf[j]), "AM"); k = VSPRINTF_LENGTH(sprintf(&(buf[j]), "AM"));
j += k; j += k;
break; break;
// is it the zone name // is it the zone name
case 'Z': case 'Z':
++i; ++i;
k = sprintf(&(buf[j]), "%s", k = VSPRINTF_LENGTH(sprintf(&(buf[j]), "%s",
[[time_zone timeZoneAbbreviation] cStringNoCopy]); [[time_zone timeZoneAbbreviation] cStringNoCopy]));
j += k; j += k;
break; break;

View file

@ -1626,7 +1626,12 @@ readContentsOfFile(NSString* path, void** buf, unsigned* len)
{ {
if (size != capacity) if (size != capacity)
{ {
void* tmp = objc_realloc(bytes, size); void* tmp;
if (bytes)
tmp = realloc(bytes, size);
else
tmp = malloc(size);
if (tmp == 0) if (tmp == 0)
[NSException raise:NSMallocException [NSException raise:NSMallocException

View file

@ -109,7 +109,7 @@ static NSMutableDictionary *_hostCache = nil;
for (i = 0, ptr = entry->h_addr_list[0]; ptr != NULL; i++, for (i = 0, ptr = entry->h_addr_list[0]; ptr != NULL; i++,
ptr = entry->h_addr_list[i]) ptr = entry->h_addr_list[i])
{ {
memmove((void *)&in.s_addr, (const void *)ptr, memcpy((void *)&in.s_addr, (const void *)ptr,
entry->h_length); entry->h_length);
[addresses addObject:[NSString [addresses addObject:[NSString
stringWithCString:inet_ntoa(in)]]; stringWithCString:inet_ntoa(in)]];

View file

@ -184,13 +184,14 @@ static BOOL debug_connected_coder = NO;
- (void) _doEncodeBycopyObject: anObj - (void) _doEncodeBycopyObject: anObj
{ {
BOOL old = _is_by_copy; BOOL old = _is_by_copy;
id obj; id obj;
Class cls;
_is_by_copy = YES; _is_by_copy = YES;
obj = [anObj classForPortCoder];
[self encodeClass: obj];
obj = [anObj replacementObjectForPortCoder: (NSPortCoder*)self]; obj = [anObj replacementObjectForPortCoder: (NSPortCoder*)self];
cls = [obj classForPortCoder];
[self encodeClass: cls];
[obj encodeWithCoder: (NSCoder*)self]; [obj encodeWithCoder: (NSCoder*)self];
_is_by_copy = old; _is_by_copy = old;
} }

View file

@ -6,17 +6,17 @@
This file is part of the GNUstep Base Library. This file is part of the GNUstep Base Library.
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License modify it under the terms of the GNU Library General Public License
as published by the Free Software Foundation; either version 2 of as published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version. the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details. Library General Public License for more details.
You should have received a copy of the GNU Library General Public You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free Software License along with this library; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
@ -31,9 +31,9 @@
time and such for every entry in the dictionary. time and such for every entry in the dictionary.
The local time zone can be specified with the user defaults The local time zone can be specified with the user defaults
database (when it's properly implemented, that is), the TZ database, the TZ environment variable, the file LOCAL_TIME_FILE, or
environment variable, or the fallback local time zone, with the the fallback local time zone, with the ones listed first having
ones listed first having precedence. precedence.
Any time zone must be a file name in ZONES_DIR. Any time zone must be a file name in ZONES_DIR.
@ -46,13 +46,13 @@
#include <string.h> #include <string.h>
#include <Foundation/NSArray.h> #include <Foundation/NSArray.h>
#include <Foundation/NSCoder.h> #include <Foundation/NSCoder.h>
#include <Foundation/NSDate.h> #include <Foundation/NSDate.h>
#include <Foundation/NSDictionary.h> #include <Foundation/NSDictionary.h>
#include <Foundation/NSException.h> #include <Foundation/NSException.h>
#include <Foundation/NSLock.h> #include <Foundation/NSLock.h>
#include <Foundation/NSObject.h> #include <Foundation/NSObject.h>
#include <Foundation/NSProcessInfo.h> #include <Foundation/NSProcessInfo.h>
#include <Foundation/NSString.h> #include <Foundation/NSString.h>
#include <Foundation/NSUserDefaults.h> #include <Foundation/NSUserDefaults.h>
#include <Foundation/NSUtilities.h> #include <Foundation/NSUtilities.h>
#include <Foundation/NSZone.h> #include <Foundation/NSZone.h>
@ -85,6 +85,9 @@
whitespace, and each line must not be longer than 80 characters. */ whitespace, and each line must not be longer than 80 characters. */
#define REGIONS_FILE TIME_ZONE_DIR "regions" #define REGIONS_FILE TIME_ZONE_DIR "regions"
/* Name of the file that contains the name of the local time zone. */
#define LOCAL_TIME_FILE TIME_ZONE_DIR "localtime"
/* Directory that contains the actual time zones. */ /* Directory that contains the actual time zones. */
#define ZONES_DIR TIME_ZONE_DIR "zones/" #define ZONES_DIR TIME_ZONE_DIR "zones/"
@ -144,10 +147,10 @@ decode (const void *ptr)
@interface NSInternalTimeTransition : NSObject @interface NSInternalTimeTransition : NSObject
{ {
int trans_time; // When the transition occurs int trans_time; // When the transition occurs
char detail_index; // Index of time zone detail char detail_index; // Index of time zone detail
} }
- initWithTime: (int)aTime withIndex: (char)anIndex; - initWithTime: (int)aTime withIndex: (char)anIndex;
- (int)transTime; - (int)transTime;
@ -164,19 +167,20 @@ decode (const void *ptr)
- initWithName: (NSString*)aName withTransitions: (NSArray*)trans - initWithName: (NSString*)aName withTransitions: (NSArray*)trans
withDetails: (NSArray*)zoneDetails; withDetails: (NSArray*)zoneDetails;
@end @end
@interface NSConcreteAbsoluteTimeZone : NSTimeZone @interface NSConcreteAbsoluteTimeZone : NSTimeZone
{ {
NSString *name; NSString *name;
id detail;
int offset; // Offset from UTC in seconds. int offset; // Offset from UTC in seconds.
} }
+ timeZoneWithOffset: (int)anOffset; + timeZoneWithOffset: (int)anOffset;
- initWithOffset: (int)anOffset withName: (NSString*)aName; - initWithOffset: (int)anOffset withName: (NSString*)aName;
@end @end
@interface NSConcreteTimeZoneDetail : NSTimeZoneDetail @interface NSConcreteTimeZoneDetail : NSTimeZoneDetail
@ -188,7 +192,7 @@ decode (const void *ptr)
- initWithAbbrev: (NSString*)anAbbrev withOffset: (int)anOffset - initWithAbbrev: (NSString*)anAbbrev withOffset: (int)anOffset
withDST: (BOOL)isDST; withDST: (BOOL)isDST;
@end @end
@implementation NSInternalAbbrevDict @implementation NSInternalAbbrevDict
@ -196,25 +200,25 @@ decode (const void *ptr)
+ allocWithZone: (NSZone*)zone + allocWithZone: (NSZone*)zone
{ {
return NSAllocateObject(self, 0, zone); return NSAllocateObject(self, 0, zone);
} }
- init - init
{ {
return self; return self;
} }
- (unsigned)count - (unsigned)count
{ {
return [[NSTimeZone abbreviationMap] count]; return [[NSTimeZone abbreviationMap] count];
} }
- (NSEnumerator*)keyEnumerator - (NSEnumerator*)keyEnumerator
{ {
return [[NSTimeZone abbreviationMap] keyEnumerator]; return [[NSTimeZone abbreviationMap] keyEnumerator];
} }
- (NSEnumerator*)objectEnumerator - (NSEnumerator*)objectEnumerator
{ {
/* FIXME: this is a memory hungry implementation */ /* FIXME: this is a memory hungry implementation */
id e, name, a; id e, name, a;
@ -224,20 +228,20 @@ decode (const void *ptr)
[a addObject: [[[NSTimeZone abbreviationMap] objectForKey: name] [a addObject: [[[NSTimeZone abbreviationMap] objectForKey: name]
objectAtIndex: 0]]; objectAtIndex: 0]];
return [a objectEnumerator]; return [a objectEnumerator];
} }
- objectForKey: key - objectForKey: key
{ {
return [[[NSTimeZone abbreviationMap] objectForKey: key] objectAtIndex: 0]; return [[[NSTimeZone abbreviationMap] objectForKey: key] objectAtIndex: 0];
} }
@end @end
@implementation NSInternalTimeTransition @implementation NSInternalTimeTransition
- (NSString*)description - (NSString*)description
{ {
return [NSString return [NSString
stringWithFormat: @"(trans: %d, idx: %d)", stringWithFormat: @"(trans: %d, idx: %d)",
trans_time, (int)detail_index]; trans_time, (int)detail_index];
@ -249,40 +253,40 @@ decode (const void *ptr)
trans_time = aTime; trans_time = aTime;
detail_index = anIndex; detail_index = anIndex;
return self; return self;
} }
- (int)transTime - (int)transTime
{ {
return trans_time; return trans_time;
} }
- (char)detailIndex - (char)detailIndex
{ {
return detail_index; return detail_index;
} }
@end @end
@implementation NSConcreteTimeZone @implementation NSConcreteTimeZone
- initWithName: (NSString*)aName withTransitions: (NSArray*)trans - initWithName: (NSString*)aName withTransitions: (NSArray*)trans
withDetails: (NSArray*)zoneDetails withDetails: (NSArray*)zoneDetails
{ {
[super init]; [super init];
name = [aName retain]; name = [aName retain];
transitions = [trans retain]; transitions = [trans retain];
details = [zoneDetails retain]; details = [zoneDetails retain];
return self; return self;
} }
- (void)dealloc - (void)dealloc
{ {
[name release]; [name release];
[transitions release]; [transitions release];
[details release]; [details release];
[super dealloc]; [super dealloc];
} }
- (void)encodeWithCoder: aCoder - (void)encodeWithCoder: aCoder
{ {
@ -291,14 +295,14 @@ decode (const void *ptr)
} }
- initWithDecoder: aDecoder - initWithDecoder: aDecoder
{ {
/* FIXME?: is this right? */ /* FIXME?: is this right? */
self = [super initWithCoder: aDecoder]; self = [super initWithCoder: aDecoder];
return (self = (id)[NSTimeZone timeZoneWithName: [aDecoder decodeObject]]); return (self = (id)[NSTimeZone timeZoneWithName: [aDecoder decodeObject]]);
} }
- (NSString*)description - (NSString*)description
{ {
return [NSString stringWithFormat: @"(trans: %@, details: %@)", return [NSString stringWithFormat: @"(trans: %@, details: %@)",
[transitions description], [details description]]; [transitions description], [details description]];
} }
@ -341,24 +345,22 @@ decode (const void *ptr)
- (NSArray*)timeZoneDetailArray - (NSArray*)timeZoneDetailArray
{ {
return details; return details;
} }
- (NSString*)timeZoneName - (NSString*)timeZoneName
{ {
return name; return name;
} }
@end @end
@implementation NSConcreteAbsoluteTimeZone @implementation NSConcreteAbsoluteTimeZone
+ timeZoneWithOffset: (int)anOffset + timeZoneWithOffset: (int)anOffset
{ {
id newName, zone; id newName, zone;
newName = [NSString stringWithFormat: @"%d", anOffset]; newName = [NSString stringWithFormat: @"%d", anOffset];
zone = [zoneDictionary objectForKey: newName]; zone = [zoneDictionary objectForKey: newName];
if (zone == nil) if (zone == nil)
@ -373,15 +375,18 @@ decode (const void *ptr)
{ {
[super init]; [super init];
name = [aName retain]; name = [aName retain];
detail = [[NSConcreteTimeZoneDetail alloc]
initWithAbbrev: name withOffset: offset withDST: NO];
offset = anOffset; offset = anOffset;
return self; return self;
} }
- (void)dealloc - (void)dealloc
{ {
[name release]; [name release];
[detail release];
[super dealloc]; [super dealloc];
} }
- (void)encodeWithCoder: aCoder - (void)encodeWithCoder: aCoder
{ {
@ -390,7 +395,7 @@ decode (const void *ptr)
} }
- initWithCoder: aDecoder - initWithCoder: aDecoder
{ {
self = [super initWithCoder: aDecoder]; self = [super initWithCoder: aDecoder];
name = [aDecoder decodeObject]; name = [aDecoder decodeObject];
offset = [name intValue]; offset = [name intValue];
@ -400,23 +405,21 @@ decode (const void *ptr)
- (NSString*)description - (NSString*)description
{ {
return [NSString stringWithFormat: @"(offset: %d)", offset]; return [NSString stringWithFormat: @"(offset: %d)", offset];
} }
- (NSTimeZoneDetail*)timeZoneDetailForDate: (NSDate*)date - (NSTimeZoneDetail*)timeZoneDetailForDate: (NSDate*)date
{ {
return [[[NSConcreteTimeZoneDetail alloc] return detail;
initWithAbbrev: name withOffset: offset withDST: NO]
autorelease];
} }
- (NSString*)timeZoneName - (NSString*)timeZoneName
{ {
return name; return name;
} }
- (NSArray*)timeZoneDetailArray - (NSArray*)timeZoneDetailArray
{ {
return [NSArray arrayWithObject: [self timeZoneDetailForDate: nil]]; return [NSArray arrayWithObject: detail];
} }
@end @end
@ -426,16 +429,16 @@ decode (const void *ptr)
- initWithAbbrev: (NSString*)anAbbrev withOffset: (int)anOffset - initWithAbbrev: (NSString*)anAbbrev withOffset: (int)anOffset
withDST: (BOOL)isDST withDST: (BOOL)isDST
{ {
[super init]; [super init];
abbrev = [anAbbrev retain]; abbrev = [anAbbrev retain];
offset = anOffset; offset = anOffset;
is_dst = isDST; is_dst = isDST;
return self; return self;
} }
- (void)dealloc - (void)dealloc
{ {
[abbrev release]; [abbrev release];
[super dealloc]; [super dealloc];
} }
@ -455,16 +458,16 @@ decode (const void *ptr)
[aDecoder decodeValueOfObjCType: @encode(int) at: &offset]; [aDecoder decodeValueOfObjCType: @encode(int) at: &offset];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &is_dst]; [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &is_dst];
return self; return self;
} }
- (NSString*)description - (NSString*)description
{ {
return [NSString stringWithFormat: @"(abbrev: %@, offset: %d, is_dst: %d)", return [NSString stringWithFormat: @"(abbrev: %@, offset: %d, is_dst: %d)",
abbrev, offset, (int)is_dst]; abbrev, offset, (int)is_dst];
} }
- (BOOL)isDaylightSavingTimeZone - (BOOL)isDaylightSavingTimeZone
{ {
return is_dst; return is_dst;
} }
@ -476,7 +479,7 @@ decode (const void *ptr)
- (int)timeZoneSecondsFromGMT - (int)timeZoneSecondsFromGMT
{ {
return offset; return offset;
} }
@end @end
@ -484,21 +487,33 @@ decode (const void *ptr)
@implementation NSTimeZone @implementation NSTimeZone
+ (void)initialize + (void)initialize
{ {
if (self == [NSTimeZone class]) if (self == [NSTimeZone class])
{ {
id localZoneString = nil; id localZoneString = nil;
zone_mutex = [NSLock new]; zone_mutex = [NSLock new];
/* Don't use this for now. */
#if 0
localZoneString = [[NSUserDefaults standardUserDefaults] localZoneString = [[NSUserDefaults standardUserDefaults]
stringForKey: @LOCALDBKEY]; stringForKey: @LOCALDBKEY];
#endif
if (localZoneString == nil) if (localZoneString == nil)
/* Try to get timezone from environment. */
localZoneString = [[[NSProcessInfo processInfo] localZoneString = [[[NSProcessInfo processInfo]
environment] objectForKey: @"TZ"]; environment] objectForKey: @"TZ"];
if (localZoneString == nil)
/* Try to get timezone from LOCAL_TIME_FILE. */
{
char zone_name[80];
FILE *fp;
fp = fopen(LOCAL_TIME_FILE, "r");
if (fp != NULL)
{
fscanf(fp, "%79s", zone_name);
localZoneString = [NSString stringWithCString: zone_name];
fclose(fp);
}
}
if (localZoneString != nil) if (localZoneString != nil)
localTimeZone = [NSTimeZone timeZoneWithName: localZoneString]; localTimeZone = [NSTimeZone timeZoneWithName: localZoneString];
else else
@ -510,10 +525,8 @@ decode (const void *ptr)
if (localTimeZone == nil) if (localTimeZone == nil)
localTimeZone = [NSTimeZone timeZoneForSecondsFromGMT: 0]; localTimeZone = [NSTimeZone timeZoneForSecondsFromGMT: 0];
[localTimeZone retain];
fake_abbrev_dict = [[NSInternalAbbrevDict alloc] init]; fake_abbrev_dict = [[NSInternalAbbrevDict alloc] init];
zoneDictionary = [[NSMutableDictionary dictionary] retain]; zoneDictionary = [[NSMutableDictionary alloc] init];
[zoneDictionary setObject: localTimeZone [zoneDictionary setObject: localTimeZone
forKey: [localTimeZone timeZoneName]]; forKey: [localTimeZone timeZoneName]];
} }
@ -653,7 +666,7 @@ decode (const void *ptr)
NSZoneFree(NSDefaultMallocZone(), zone_abbrevs); NSZoneFree(NSDefaultMallocZone(), zone_abbrevs);
/* Create time zone details. */ /* Create time zone details. */
detailsArray = [NSMutableArray array]; detailsArray = [[NSMutableArray alloc] init];
for (i = 0; i < n_types; i++) for (i = 0; i < n_types; i++)
[detailsArray [detailsArray
addObject: [[NSConcreteTimeZoneDetail alloc] addObject: [[NSConcreteTimeZoneDetail alloc]
@ -663,7 +676,7 @@ decode (const void *ptr)
NSZoneFree(NSDefaultMallocZone(), abbrevsArray); NSZoneFree(NSDefaultMallocZone(), abbrevsArray);
NSZoneFree(NSDefaultMallocZone(), types); NSZoneFree(NSDefaultMallocZone(), types);
zone = [[NSConcreteTimeZone alloc] zone = [[NSConcreteTimeZone alloc]
initWithName: aTimeZoneName initWithName: [aTimeZoneName copy]
withTransitions: transArray withTransitions: transArray
withDetails: detailsArray]; withDetails: detailsArray];
[zoneDictionary setObject: zone forKey: aTimeZoneName]; [zoneDictionary setObject: zone forKey: aTimeZoneName];
@ -713,12 +726,12 @@ decode (const void *ptr)
return abbreviationDictionary; return abbreviationDictionary;
/* Read dictionary from file. */ /* Read dictionary from file. */
abbreviationDictionary = [[NSMutableDictionary dictionary] retain]; abbreviationDictionary = [[NSMutableDictionary alloc] init];
file = fopen(ABBREV_DICT, "r"); file = fopen(ABBREV_DICT, "r");
if (file == NULL) if (file == NULL)
[NSException raise: NSInternalInconsistencyException [NSException raise: NSInternalInconsistencyException
format: @"Failed to open time zone abbreviation dictionary"]; format: @"Failed to open time zone abbreviation dictionary"];
while (fscanf(file, "%s %s", abbrev, name) == 2) while (fscanf(file, "%79s %79s", abbrev, name) == 2)
{ {
id a, the_name, the_abbrev; id a, the_name, the_abbrev;
@ -727,7 +740,7 @@ decode (const void *ptr)
a = [abbreviationDictionary objectForKey: the_abbrev]; a = [abbreviationDictionary objectForKey: the_abbrev];
if (a == nil) if (a == nil)
{ {
a = [NSMutableArray array]; a = [[NSMutableArray alloc] init];
[abbreviationDictionary setObject: a forKey: the_abbrev]; [abbreviationDictionary setObject: a forKey: the_abbrev];
} }
[a addObject: the_name]; [a addObject: the_name];
@ -735,15 +748,15 @@ decode (const void *ptr)
fclose(file); fclose(file);
return abbreviationDictionary; return abbreviationDictionary;
} }
- (NSString*)timeZoneName - (NSString*)timeZoneName
{ {
return [self subclassResponsibility: _cmd]; return [self subclassResponsibility: _cmd];
} }
+ (NSArray*)timeZoneArray + (NSArray*)timeZoneArray
{ {
/* We create the array only when we need it to reduce overhead. */ /* We create the array only when we need it to reduce overhead. */
static NSArray *regionsArray = nil; static NSArray *regionsArray = nil;
@ -756,25 +769,25 @@ decode (const void *ptr)
return regionsArray; return regionsArray;
for (i = 0; i < 24; i++) for (i = 0; i < 24; i++)
temp_array[i] = [NSMutableArray array]; temp_array[i] = [[NSMutableArray alloc] init];
file = fopen(REGIONS_FILE, "r"); file = fopen(REGIONS_FILE, "r");
if (file == NULL) if (file == NULL)
[NSException raise: NSInternalInconsistencyException [NSException raise: NSInternalInconsistencyException
format: @"Failed to open regions array file"]; format: @"Failed to open regions array file"];
while (fscanf(file, "%d %s", &index, name) == 2) while (fscanf(file, "%d %s", &index, name) == 2)
[temp_array[index] addObject: [NSString stringWithCString: name]]; [temp_array[index] addObject: [[NSString alloc] initWithCString: name]];
fclose(file); fclose(file);
regionsArray = [[NSArray alloc] initWithObjects: temp_array count: 24]; regionsArray = [[NSArray alloc] initWithObjects: temp_array count: 24];
return regionsArray; return regionsArray;
} }
- (NSArray*)timeZoneDetailArray - (NSArray*)timeZoneDetailArray
{ {
return [self subclassResponsibility: _cmd]; return [self subclassResponsibility: _cmd];
} }
@end @end
@implementation NSTimeZoneDetail @implementation NSTimeZoneDetail
@ -785,18 +798,26 @@ decode (const void *ptr)
} }
- (BOOL)isDaylightSavingTimeZone - (BOOL)isDaylightSavingTimeZone
{ {
[self subclassResponsibility: _cmd]; [self subclassResponsibility: _cmd];
return NO; return NO;
} }
- (NSString*)timeZoneAbbreviation - (NSString*)timeZoneAbbreviation
{ {
return [self subclassResponsibility: _cmd]; return [self subclassResponsibility: _cmd];
} }
- (int)timeZoneSecondsFromGMT - (int)timeZoneSecondsFromGMT
{ {
[self subclassResponsibility: _cmd]; [self subclassResponsibility: _cmd];
return 0; return 0;
} }
@end

View file

@ -90,7 +90,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin)
name = [host address]; name = [host address];
#ifndef HAVE_INET_ATON #ifndef HAVE_INET_ATON
sin->sin_addr.s_addr = htonl(inet_addr([name cStringNoCopy])); sin->sin_addr.s_addr = inet_addr([name cStringNoCopy]);
#else #else
if (inet_aton([name cStringNoCopy], &sin->sin_addr.s_addr) == 0) if (inet_aton([name cStringNoCopy], &sin->sin_addr.s_addr) == 0)
return NO; return NO;

View file

@ -143,7 +143,7 @@ MyCategory.h \
SecondClass.h SecondClass.h
DIST_FILES = $(SRCS) $(HDRS) $(DYNAMIC_MFILES) $(DYNAMIC_HFILES) \ DIST_FILES = $(SRCS) $(HDRS) $(DYNAMIC_MFILES) $(DYNAMIC_HFILES) \
Makefile Makefile.preamble Makefile.postamble NXStringTable.example Makefile Makefile.preamble Makefile.postamble
-include Makefile.preamble -include Makefile.preamble

View file

@ -76,3 +76,5 @@ copy-dist: $(DIST_FILES)
for f in $(DIST_FILES); do \ for f in $(DIST_FILES); do \
cp $$f ../snap/checks ; \ cp $$f ../snap/checks ; \
done done
mkdir ../snap/checks/English.lproj
cp English.lproj/NXStringTable.example ../snap/checks/English.lproj