mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 08:41:03 +00:00
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:
parent
a02a4e9e88
commit
120673e03a
9 changed files with 163 additions and 117 deletions
17
ChangeLog
17
ChangeLog
|
@ -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>
|
||||
|
||||
* checks/Makefile: Add variables to create bundle example.
|
||||
|
|
|
@ -612,9 +612,9 @@ static id long_month[12] = {@"January",
|
|||
case 'y':
|
||||
++i;
|
||||
if (ycent)
|
||||
k = sprintf(&(buf[j]), "%04d", yd);
|
||||
k = VSPRINTF_LENGTH(sprintf(&(buf[j]), "%04d", yd));
|
||||
else
|
||||
k = sprintf(&(buf[j]), "%02d", (yd - 1900));
|
||||
k = VSPRINTF_LENGTH(sprintf(&(buf[j]), "%02d", (yd - 1900)));
|
||||
j += k;
|
||||
break;
|
||||
|
||||
|
@ -629,12 +629,12 @@ static id long_month[12] = {@"January",
|
|||
{
|
||||
// +++ Translate to locale character string
|
||||
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
|
||||
k = sprintf(&(buf[j]), "%s", [long_month[md-1] cString]);
|
||||
k = VSPRINTF_LENGTH(sprintf(&(buf[j]), "%s", [long_month[md-1] cString]));
|
||||
}
|
||||
else
|
||||
k = sprintf(&(buf[j]), "%02d", md);
|
||||
k = VSPRINTF_LENGTH(sprintf(&(buf[j]), "%02d", md));
|
||||
j += k;
|
||||
break;
|
||||
|
||||
|
@ -654,7 +654,7 @@ static id long_month[12] = {@"January",
|
|||
k = 0;
|
||||
}
|
||||
else
|
||||
k = sprintf(&(buf[j]), "%02d", dd);
|
||||
k = VSPRINTF_LENGTH(sprintf(&(buf[j]), "%02d", dd));
|
||||
j += k;
|
||||
break;
|
||||
|
||||
|
@ -665,21 +665,21 @@ static id long_month[12] = {@"January",
|
|||
nhd = 12; // 12pm not 0pm
|
||||
case 'H':
|
||||
++i;
|
||||
k = sprintf(&(buf[j]), "%02d", nhd);
|
||||
k = VSPRINTF_LENGTH(sprintf(&(buf[j]), "%02d", nhd));
|
||||
j += k;
|
||||
break;
|
||||
|
||||
// is it the minute
|
||||
case 'M':
|
||||
++i;
|
||||
k = sprintf(&(buf[j]), "%02d", mnd);
|
||||
k = VSPRINTF_LENGTH(sprintf(&(buf[j]), "%02d", mnd));
|
||||
j += k;
|
||||
break;
|
||||
|
||||
// is it the second
|
||||
case 'S':
|
||||
++i;
|
||||
k = sprintf(&(buf[j]), "%02d", sd);
|
||||
k = VSPRINTF_LENGTH(sprintf(&(buf[j]), "%02d", sd));
|
||||
j += k;
|
||||
break;
|
||||
|
||||
|
@ -687,17 +687,17 @@ static id long_month[12] = {@"January",
|
|||
case 'p':
|
||||
++i;
|
||||
if (hd >= 12)
|
||||
k = sprintf(&(buf[j]), "PM");
|
||||
k = VSPRINTF_LENGTH(sprintf(&(buf[j]), "PM"));
|
||||
else
|
||||
k = sprintf(&(buf[j]), "AM");
|
||||
k = VSPRINTF_LENGTH(sprintf(&(buf[j]), "AM"));
|
||||
j += k;
|
||||
break;
|
||||
|
||||
// is it the zone name
|
||||
case 'Z':
|
||||
++i;
|
||||
k = sprintf(&(buf[j]), "%s",
|
||||
[[time_zone timeZoneAbbreviation] cStringNoCopy]);
|
||||
k = VSPRINTF_LENGTH(sprintf(&(buf[j]), "%s",
|
||||
[[time_zone timeZoneAbbreviation] cStringNoCopy]));
|
||||
j += k;
|
||||
break;
|
||||
|
||||
|
|
|
@ -1626,7 +1626,12 @@ readContentsOfFile(NSString* path, void** buf, unsigned* len)
|
|||
{
|
||||
if (size != capacity)
|
||||
{
|
||||
void* tmp = objc_realloc(bytes, size);
|
||||
void* tmp;
|
||||
|
||||
if (bytes)
|
||||
tmp = realloc(bytes, size);
|
||||
else
|
||||
tmp = malloc(size);
|
||||
|
||||
if (tmp == 0)
|
||||
[NSException raise:NSMallocException
|
||||
|
|
|
@ -109,7 +109,7 @@ static NSMutableDictionary *_hostCache = nil;
|
|||
for (i = 0, ptr = entry->h_addr_list[0]; ptr != NULL; 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);
|
||||
[addresses addObject:[NSString
|
||||
stringWithCString:inet_ntoa(in)]];
|
||||
|
|
|
@ -186,11 +186,12 @@ static BOOL debug_connected_coder = NO;
|
|||
{
|
||||
BOOL old = _is_by_copy;
|
||||
id obj;
|
||||
Class cls;
|
||||
|
||||
_is_by_copy = YES;
|
||||
obj = [anObj classForPortCoder];
|
||||
[self encodeClass: obj];
|
||||
obj = [anObj replacementObjectForPortCoder: (NSPortCoder*)self];
|
||||
cls = [obj classForPortCoder];
|
||||
[self encodeClass: cls];
|
||||
[obj encodeWithCoder: (NSCoder*)self];
|
||||
_is_by_copy = old;
|
||||
}
|
||||
|
|
|
@ -31,9 +31,9 @@
|
|||
time and such for every entry in the dictionary.
|
||||
|
||||
The local time zone can be specified with the user defaults
|
||||
database (when it's properly implemented, that is), the TZ
|
||||
environment variable, or the fallback local time zone, with the
|
||||
ones listed first having precedence.
|
||||
database, the TZ environment variable, the file LOCAL_TIME_FILE, or
|
||||
the fallback local time zone, with the ones listed first having
|
||||
precedence.
|
||||
|
||||
Any time zone must be a file name in ZONES_DIR.
|
||||
|
||||
|
@ -85,6 +85,9 @@
|
|||
whitespace, and each line must not be longer than 80 characters. */
|
||||
#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. */
|
||||
#define ZONES_DIR TIME_ZONE_DIR "zones/"
|
||||
|
||||
|
@ -170,6 +173,7 @@ decode (const void *ptr)
|
|||
@interface NSConcreteAbsoluteTimeZone : NSTimeZone
|
||||
{
|
||||
NSString *name;
|
||||
id detail;
|
||||
int offset; // Offset from UTC in seconds.
|
||||
}
|
||||
|
||||
|
@ -357,8 +361,6 @@ decode (const void *ptr)
|
|||
{
|
||||
id newName, zone;
|
||||
|
||||
|
||||
|
||||
newName = [NSString stringWithFormat: @"%d", anOffset];
|
||||
zone = [zoneDictionary objectForKey: newName];
|
||||
if (zone == nil)
|
||||
|
@ -373,6 +375,8 @@ decode (const void *ptr)
|
|||
{
|
||||
[super init];
|
||||
name = [aName retain];
|
||||
detail = [[NSConcreteTimeZoneDetail alloc]
|
||||
initWithAbbrev: name withOffset: offset withDST: NO];
|
||||
offset = anOffset;
|
||||
return self;
|
||||
}
|
||||
|
@ -380,6 +384,7 @@ decode (const void *ptr)
|
|||
- (void)dealloc
|
||||
{
|
||||
[name release];
|
||||
[detail release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
@ -404,9 +409,7 @@ decode (const void *ptr)
|
|||
|
||||
- (NSTimeZoneDetail*)timeZoneDetailForDate: (NSDate*)date
|
||||
{
|
||||
return [[[NSConcreteTimeZoneDetail alloc]
|
||||
initWithAbbrev: name withOffset: offset withDST: NO]
|
||||
autorelease];
|
||||
return detail;
|
||||
}
|
||||
|
||||
- (NSString*)timeZoneName
|
||||
|
@ -416,7 +419,7 @@ decode (const void *ptr)
|
|||
|
||||
- (NSArray*)timeZoneDetailArray
|
||||
{
|
||||
return [NSArray arrayWithObject: [self timeZoneDetailForDate: nil]];
|
||||
return [NSArray arrayWithObject: detail];
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -491,14 +494,26 @@ decode (const void *ptr)
|
|||
|
||||
zone_mutex = [NSLock new];
|
||||
|
||||
/* Don't use this for now. */
|
||||
#if 0
|
||||
localZoneString = [[NSUserDefaults standardUserDefaults]
|
||||
stringForKey: @LOCALDBKEY];
|
||||
#endif
|
||||
if (localZoneString == nil)
|
||||
/* Try to get timezone from environment. */
|
||||
localZoneString = [[[NSProcessInfo processInfo]
|
||||
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)
|
||||
localTimeZone = [NSTimeZone timeZoneWithName: localZoneString];
|
||||
else
|
||||
|
@ -510,10 +525,8 @@ decode (const void *ptr)
|
|||
if (localTimeZone == nil)
|
||||
localTimeZone = [NSTimeZone timeZoneForSecondsFromGMT: 0];
|
||||
|
||||
[localTimeZone retain];
|
||||
|
||||
fake_abbrev_dict = [[NSInternalAbbrevDict alloc] init];
|
||||
zoneDictionary = [[NSMutableDictionary dictionary] retain];
|
||||
zoneDictionary = [[NSMutableDictionary alloc] init];
|
||||
[zoneDictionary setObject: localTimeZone
|
||||
forKey: [localTimeZone timeZoneName]];
|
||||
}
|
||||
|
@ -653,7 +666,7 @@ decode (const void *ptr)
|
|||
NSZoneFree(NSDefaultMallocZone(), zone_abbrevs);
|
||||
|
||||
/* Create time zone details. */
|
||||
detailsArray = [NSMutableArray array];
|
||||
detailsArray = [[NSMutableArray alloc] init];
|
||||
for (i = 0; i < n_types; i++)
|
||||
[detailsArray
|
||||
addObject: [[NSConcreteTimeZoneDetail alloc]
|
||||
|
@ -663,7 +676,7 @@ decode (const void *ptr)
|
|||
NSZoneFree(NSDefaultMallocZone(), abbrevsArray);
|
||||
NSZoneFree(NSDefaultMallocZone(), types);
|
||||
zone = [[NSConcreteTimeZone alloc]
|
||||
initWithName: aTimeZoneName
|
||||
initWithName: [aTimeZoneName copy]
|
||||
withTransitions: transArray
|
||||
withDetails: detailsArray];
|
||||
[zoneDictionary setObject: zone forKey: aTimeZoneName];
|
||||
|
@ -713,12 +726,12 @@ decode (const void *ptr)
|
|||
return abbreviationDictionary;
|
||||
|
||||
/* Read dictionary from file. */
|
||||
abbreviationDictionary = [[NSMutableDictionary dictionary] retain];
|
||||
abbreviationDictionary = [[NSMutableDictionary alloc] init];
|
||||
file = fopen(ABBREV_DICT, "r");
|
||||
if (file == NULL)
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
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;
|
||||
|
||||
|
@ -727,7 +740,7 @@ decode (const void *ptr)
|
|||
a = [abbreviationDictionary objectForKey: the_abbrev];
|
||||
if (a == nil)
|
||||
{
|
||||
a = [NSMutableArray array];
|
||||
a = [[NSMutableArray alloc] init];
|
||||
[abbreviationDictionary setObject: a forKey: the_abbrev];
|
||||
}
|
||||
[a addObject: the_name];
|
||||
|
@ -756,14 +769,14 @@ decode (const void *ptr)
|
|||
return regionsArray;
|
||||
|
||||
for (i = 0; i < 24; i++)
|
||||
temp_array[i] = [NSMutableArray array];
|
||||
temp_array[i] = [[NSMutableArray alloc] init];
|
||||
|
||||
file = fopen(REGIONS_FILE, "r");
|
||||
if (file == NULL)
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Failed to open regions array file"];
|
||||
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);
|
||||
regionsArray = [[NSArray alloc] initWithObjects: temp_array count: 24];
|
||||
return regionsArray;
|
||||
|
@ -800,3 +813,11 @@ decode (const void *ptr)
|
|||
[self subclassResponsibility: _cmd];
|
||||
return 0;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin)
|
|||
name = [host address];
|
||||
|
||||
#ifndef HAVE_INET_ATON
|
||||
sin->sin_addr.s_addr = htonl(inet_addr([name cStringNoCopy]));
|
||||
sin->sin_addr.s_addr = inet_addr([name cStringNoCopy]);
|
||||
#else
|
||||
if (inet_aton([name cStringNoCopy], &sin->sin_addr.s_addr) == 0)
|
||||
return NO;
|
||||
|
|
|
@ -143,7 +143,7 @@ MyCategory.h \
|
|||
SecondClass.h
|
||||
|
||||
DIST_FILES = $(SRCS) $(HDRS) $(DYNAMIC_MFILES) $(DYNAMIC_HFILES) \
|
||||
Makefile Makefile.preamble Makefile.postamble NXStringTable.example
|
||||
Makefile Makefile.preamble Makefile.postamble
|
||||
|
||||
-include Makefile.preamble
|
||||
|
||||
|
|
|
@ -76,3 +76,5 @@ copy-dist: $(DIST_FILES)
|
|||
for f in $(DIST_FILES); do \
|
||||
cp $$f ../snap/checks ; \
|
||||
done
|
||||
mkdir ../snap/checks/English.lproj
|
||||
cp English.lproj/NXStringTable.example ../snap/checks/English.lproj
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue