Updated patch from Frith-MacDonald.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@2704 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Adam Fedor 1998-01-21 14:56:24 +00:00
parent ca8df7d583
commit 99321bb9e7
11 changed files with 147 additions and 70 deletions

View file

@ -1,4 +1,9 @@
Wed Jan 7 20:25:00 1997 Richard Frith-Macdonald <richard@brainstorm.co.uk>
Wed Jan 21 09:41:46 1998 Adam Fedor <fedor@spanky.doc.com>
* src/Makefile.postamble: Change $(LEX) to $(FLEX) and $(YACC) to
$(BISON). Add $(GNUSTEP_OBJC_DIR) to targets with ${OEXT}.
Tue Jan 20 19:05:00 1997 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Tools/GNUmakefile: Added defaults.m
@ -11,11 +16,18 @@ Wed Jan 7 20:25:00 1997 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Tools/dwrite.m: Added -u flag and made numerous bug fixes.
* checks/GNUmakefile (TEST_TOOL_NAME): Add nstask.
* checks/nsdate.m: Added some year-2000 tests.
* checks/nstask.m: New file.
* src/Dictionary.m: Removed ([-descriptionWithIndent:]) and the
([-description]) methods - no longer needed for property lists.
* src/GNUmakefile: Added NSTask
* src/GetDefEncoding.m: Fixed so that the encoding that is read from
the environment is accepted.
* src/Heap.m: Added implementation of ([-minObject]) to take
advantage of the known ordering of a heap - fixes performance
problem with large numbers of timers in NSRunLoop.
@ -41,10 +53,17 @@ Wed Jan 7 20:25:00 1997 Richard Frith-Macdonald <richard@brainstorm.co.uk>
([+dataWithData:]), ([-setData:])
Modified ([-description]) to give tidier output.
* src/NSCalendarDate.m: Changed initialisation and creation methods to
return type id as in the Rhapsody docs, also changed default format for
description to use numeric timezone values as per Rhapsody docs.
* src/NSData.m: Implemented new methods for OPENSTEP -
([+dataWithData:]), ([-setData:])
Modified ([-description]) to give tidier output.
* NSDate.m: Changed initialisation and creation methods to return type
id as in the Rhapsody docs.
* src/NSDictionary.m: Implemented new methods for OPENSTEP -
([-keysSortedByValueUsingSelector:]),
([-objectsForKeys:notFoundMarker:]), ([-description]),
@ -56,6 +75,8 @@ Wed Jan 7 20:25:00 1997 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* src/NSString.m: Removed ([-quotedCString]) and added new method
([-descriptionForPropertyList]) to do things more neatly.
Fixed ([-initWithContentsOfFile:]) to avoid crash when given a bad
file name.
* src/NSTask.m: Added this OPENSTEP/Rhapsody class.
@ -74,6 +95,9 @@ Wed Jan 7 20:25:00 1997 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* src/include/NSData.h: Changes to reflect the changes in methods
implemented in NSData.m
* src/include/NSDate.h: Changed return tpes of initialisation methods
to be (id) as in Rhapsody documentation.
* src/include/NSDictionary.h: Changes to reflect the changes in methods
implemented in NSData.m

View file

@ -45,18 +45,19 @@ typedef double NSTimeInterval;
// Allocation and initializing
+ (NSDate*) date;
+ (NSDate*) dateWithTimeIntervalSinceNow: (NSTimeInterval)seconds;
+ (NSDate*) dateWithTimeIntervalSince1970: (NSTimeInterval)seconds;
+ (NSDate*) dateWithTimeIntervalSinceReferenceDate: (NSTimeInterval)seconds;
+ (NSDate*) distantFuture;
+ (NSDate*) distantPast;
+ (id) date;
+ (id) dateWithString: (NSString*)description;
+ (id) dateWithTimeIntervalSinceNow: (NSTimeInterval)seconds;
+ (id) dateWithTimeIntervalSince1970: (NSTimeInterval)seconds;
+ (id) dateWithTimeIntervalSinceReferenceDate: (NSTimeInterval)seconds;
+ (id) distantFuture;
+ (id) distantPast;
- (id) initWithString: (NSString*)description;
- (NSDate*) initWithTimeInterval: (NSTimeInterval)secsToBeAdded
sinceDate: (NSDate*)anotherDate;
- (NSDate*) initWithTimeIntervalSinceNow: (NSTimeInterval)secsToBeAdded;
- (NSDate*) initWithTimeIntervalSince1970: (NSTimeInterval)seconds;
- (id) initWithTimeInterval: (NSTimeInterval)secsToBeAdded
sinceDate: (NSDate*)anotherDate;
- (id) initWithTimeIntervalSinceNow: (NSTimeInterval)secsToBeAdded;
- (id) initWithTimeIntervalSince1970: (NSTimeInterval)seconds;
- (id) initWithTimeIntervalSinceReferenceDate: (NSTimeInterval)secs;
// Converting to NSCalendar
@ -73,7 +74,7 @@ typedef double NSTimeInterval;
// Adding and getting intervals
- (NSDate*) addTimeInterval: (NSTimeInterval)seconds;
- (id) addTimeInterval: (NSTimeInterval)seconds;
- (NSTimeInterval) timeIntervalSince1970;
- (NSTimeInterval) timeIntervalSinceDate: (NSDate*)otherDate;
- (NSTimeInterval) timeIntervalSinceNow;
@ -136,19 +137,19 @@ typedef double NSTimeInterval;
}
// Getting an NSCalendar Date
+ (NSCalendarDate *)calendarDate;
+ (NSCalendarDate *)dateWithString:(NSString *)description
calendarFormat:(NSString *)format;
+ (NSCalendarDate *)dateWithString:(NSString *)description
calendarFormat:(NSString *)format
locale:(NSDictionary *)dictionary;
+ (NSCalendarDate *)dateWithYear:(int)year
month:(unsigned int)month
day:(unsigned int)day
hour:(unsigned int)hour
minute:(unsigned int)minute
second:(unsigned int)second
timeZone:(NSTimeZone *)aTimeZone;
+ (id)calendarDate;
+ (id)dateWithString:(NSString *)description
calendarFormat:(NSString *)format;
+ (id)dateWithString:(NSString *)description
calendarFormat:(NSString *)format
locale:(NSDictionary *)dictionary;
+ (id)dateWithYear:(int)year
month:(unsigned int)month
day:(unsigned int)day
hour:(unsigned int)hour
minute:(unsigned int)minute
second:(unsigned int)second
timeZone:(NSTimeZone *)aTimeZone;
// Initializing an NSCalendar Date
- (id)initWithString:(NSString *)description;

View file

@ -86,7 +86,10 @@ NSStringEncoding GetDefEncoding()
if(!(ret==_availableEncodings[count]))
tmp=0;
else
{
tmp=ret;
break;
}
count++;
};
if(!tmp)

View file

@ -118,26 +118,26 @@ gdomap: gdomap.c gdomap.h
$(CC) $(ALL_CPPFLAGS) $(DEFS) $(ALL_OBJCFLAGS) -w -o $@ $< $(LIBS)
NXStringTable_scan.c: NXStringTable_scan.l
$(LEX) $(LEXFLAGS) -t $(srcdir)/NXStringTable_scan.l \
$(FLEX) $(LEXFLAGS) -t $(srcdir)/NXStringTable_scan.l \
> NXStringTable_scan.temp
sed "s/yy/NXlex_/g" < NXStringTable_scan.temp \
> NXStringTable_scan.c
$(RM) -f NXStringTable_scan.temp
proplist.tab.m proplist.tab.h: proplist.y
rm -f proplist.tab.m.h
$(YACC) -d -p pl proplist.y -o proplist.tab.m
$(BISON) -d -p pl proplist.y -o proplist.tab.m
mv proplist.tab.m.h proplist.tab.h
lex.pl.m: proplist.l proplist.tab.h
$(LEX) -t -B -Ppl proplist.l > $@
$(FLEX) -t -B -Ppl proplist.l > $@
stringsfile.tab.m stringsfile.tab.h: stringsfile.y
rm -f stringsfile.tab.m.h
$(YACC) -d -p sf stringsfile.y -o stringsfile.tab.m
$(BISON) -d -p sf stringsfile.y -o stringsfile.tab.m
mv stringsfile.tab.m.h stringsfile.tab.h
lex.sf.m: stringsfile.l stringsfile.tab.h
$(LEX) -t -B -Psf stringsfile.l > $@
$(FLEX) -t -B -Psf stringsfile.l > $@
objc-load${OEXT}: dynamic-load.h
$(GNUSTEP_OBJ_DIR)/objc-load${OEXT}: dynamic-load.h
dynamic-load.h: ../config.status
rm -f dynamic-load.h
@ -154,7 +154,7 @@ include/preface.h: $(srcdir)/include/preface.h.in ../Version
sed -e "s/@LIBRARY_NAME@/$(LIBRARY_VAR)_LIBRARY_NAME $(LIBRARY_NAME)/" | \
sed -e "s/@PACKAGE_NAME@/$(LIBRARY_VAR)_PACKAGE_NAME $(PACKAGE_NAME)/" \
> $@
preface${OEXT}: include/preface.h
$(GNUSTEP_OBJ_DIR)/preface${OEXT}: include/preface.h
#
# The config.h file is specific to a target
@ -164,12 +164,6 @@ $(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS)/config.h: ../config.status
$(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS)
-mv include/config.h $(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS)
# Turn off warnings for o_vscanf.c, it generates a bunch of unimportant ones.
o_vscanf${OEXT}: o_vscanf.c
$(CC) -c $(ALL_CPPFLAGS) $(DEFS) $(ALL_OBJCFLAGS) -w -o $@ $<
o_vscanf_pic${OEXT}: o_vscanf.c
$(CC) -c $(ALL_CPPFLAGS) $(DEFS) $(ALL_OBJCFLAGS) -w -o $@ $<
include/o_%_bas.h: include/o_x_bas.h.in
sed -e "s/@XX@/$*/g" $< > $@

View file

@ -494,7 +494,7 @@ static Class NSMutableArray_concrete_class;
{
return [self descriptionWithLocale: locale indent: 0];
}
- (NSString*) descriptionWithLocale: (NSDictionary*)locale
indent: (unsigned int)level
{
@ -566,7 +566,7 @@ static Class NSMutableArray_concrete_class;
item = [self objectAtIndex: i];
if ([item isKindOfClass: [NSString class]]) {
item = [item descriptionForPropertyList];
}
}
else if ([item respondsToSelector:
@selector(descriptionWithLocale:indent:)]) {
item = [item descriptionWithLocale: locale indent: level];

View file

@ -104,22 +104,22 @@ static id long_day[7] = {@"Sunday",
//
// Getting an NSCalendar Date
//
+ (NSCalendarDate *)calendarDate
+ (id)calendarDate
{
return [[[self alloc] init] autorelease];
}
+ (NSCalendarDate *)dateWithString:(NSString *)description
calendarFormat:(NSString *)format
+ (id)dateWithString:(NSString *)description
calendarFormat:(NSString *)format
{
NSCalendarDate *d = [[NSCalendarDate alloc] initWithString: description
calendarFormat: format];
return [d autorelease];
}
+ (NSCalendarDate *)dateWithString:(NSString *)description
calendarFormat:(NSString *)format
locale:(NSDictionary *)dictionary
+ (id)dateWithString:(NSString *)description
calendarFormat:(NSString *)format
locale:(NSDictionary *)dictionary
{
NSCalendarDate *d = [[NSCalendarDate alloc] initWithString: description
calendarFormat: format
@ -127,13 +127,13 @@ static id long_day[7] = {@"Sunday",
return [d autorelease];
}
+ (NSCalendarDate *)dateWithYear:(int)year
month:(unsigned int)month
day:(unsigned int)day
hour:(unsigned int)hour
minute:(unsigned int)minute
second:(unsigned int)second
timeZone:(NSTimeZone *)aTimeZone
+ (id)dateWithYear:(int)year
month:(unsigned int)month
day:(unsigned int)day
hour:(unsigned int)hour
minute:(unsigned int)minute
second:(unsigned int)second
timeZone:(NSTimeZone *)aTimeZone
{
NSCalendarDate *d = [[NSCalendarDate alloc] initWithYear: year
month: month
@ -150,7 +150,7 @@ static id long_day[7] = {@"Sunday",
{
// +++ What is the locale?
return [self initWithString: description
calendarFormat: @"%Y-%m-%d %H:%M:%S %Z"
calendarFormat: @"%Y-%m-%d %H:%M:%S %z"
locale: nil];
}
@ -179,6 +179,7 @@ static id long_day[7] = {@"Sunday",
BOOL mtag = NO, dtag = NO, ycent = NO;
BOOL fullm = NO;
char ms[80] = "", ds[80] = "", timez[80] = "", ampm[80] = "";
int tznum = 0;
int yd = 0, md = 0, dd = 0, hd = 0, mnd = 0, sd = 0;
void *pntr[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int order;
@ -186,6 +187,7 @@ static id long_day[7] = {@"Sunday",
int ampmord = 0;
int i;
NSTimeZone *tz;
BOOL zoneByAbbreviation = YES;
// If either the string or format is nil then raise exception
if (!description)
@ -327,6 +329,16 @@ static id long_day[7] = {@"Sunday",
pntr[tzord] = (void *)timez;
break;
// the time zone in numeric format
case 'z':
tzord = order;
++order;
++i;
newf[i] = 'd';
pntr[tzord] = (void *)&tznum;
zoneByAbbreviation = NO;
break;
// AM PM indicator
case 'p':
ampmord = order;
@ -401,12 +413,30 @@ static id long_day[7] = {@"Sunday",
// +++ then there is the time zone
if (tzord)
if (zoneByAbbreviation)
{
tz = [NSTimeZone timeZoneWithAbbreviation:
[NSString stringWithCString: timez]];
if (!tz)
tz = [NSTimeZone localTimeZone];
}
else
{
int tzm, tzh, sign;
if (tznum < 0)
{
sign = -1;
tznum = -tznum;
}
else
sign = 1;
tzm = tznum % 100;
tzh = tznum / 100;
tz = [NSTimeZone timeZoneForSecondsFromGMT: (tzh * 60 + tzm) * 60 * sign];
if (!tz)
tz = [NSTimeZone localTimeZone];
}
else
tz = [NSTimeZone localTimeZone];
@ -513,7 +543,7 @@ static id long_day[7] = {@"Sunday",
{
[super initWithTimeIntervalSinceReferenceDate: seconds];
if (!calendar_format)
calendar_format = @"%Y-%m-%d %H:%M:%S %Z";
calendar_format = @"%Y-%m-%d %H:%M:%S %z";
if (!time_zone)
time_zone = [[NSTimeZone localTimeZone] timeZoneDetailForDate: self];
return self;

View file

@ -106,30 +106,34 @@
// Allocation and initializing
+ (NSDate*) date
+ (id) date
{
return [[[self alloc] init] autorelease];
}
+ (NSDate*) dateWithTimeIntervalSinceNow: (NSTimeInterval)seconds
+ (id) dateWithString: (NSString*)description
{
return [[[self alloc] initWithTimeIntervalSinceNow: seconds]
autorelease];
return [[[self alloc] initWithString: description] autorelease];
}
+ (NSDate *)dateWithTimeIntervalSince1970:(NSTimeInterval)seconds
+ (id) dateWithTimeIntervalSinceNow: (NSTimeInterval)seconds
{
return [[[self alloc] initWithTimeIntervalSinceNow: seconds] autorelease];
}
+ (id)dateWithTimeIntervalSince1970:(NSTimeInterval)seconds
{
return [[[self alloc] initWithTimeIntervalSinceReferenceDate:
UNIX_REFERENCE_INTERVAL + seconds] autorelease];
}
+ (NSDate*) dateWithTimeIntervalSinceReferenceDate: (NSTimeInterval)seconds
+ (id) dateWithTimeIntervalSinceReferenceDate: (NSTimeInterval)seconds
{
return [[[self alloc] initWithTimeIntervalSinceReferenceDate: seconds]
autorelease];
}
+ (NSDate*) distantFuture
+ (id) distantFuture
{
static id df = nil;
if (!df)
@ -137,7 +141,7 @@
return df;
}
+ (NSDate*) distantPast
+ (id) distantPast
{
static id dp = nil;
if (!dp)
@ -199,7 +203,7 @@
return self;
}
- (NSDate*) initWithTimeInterval: (NSTimeInterval)secsToBeAdded
- (id) initWithTimeInterval: (NSTimeInterval)secsToBeAdded
sinceDate: (NSDate*)anotherDate;
{
// Get the other date's time, add the secs and init thyself
@ -207,14 +211,14 @@
[anotherDate timeIntervalSinceReferenceDate] + secsToBeAdded];
}
- (NSDate*) initWithTimeIntervalSinceNow: (NSTimeInterval)secsToBeAdded;
- (id) initWithTimeIntervalSinceNow: (NSTimeInterval)secsToBeAdded;
{
// Get the current time, add the secs and init thyself
return [self initWithTimeIntervalSinceReferenceDate:
[[self class] timeIntervalSinceReferenceDate] + secsToBeAdded];
}
- (NSDate *)initWithTimeIntervalSince1970:(NSTimeInterval)seconds
- (id)initWithTimeIntervalSince1970:(NSTimeInterval)seconds
{
return [self initWithTimeIntervalSinceReferenceDate:
UNIX_REFERENCE_INTERVAL + seconds];
@ -288,7 +292,7 @@
// Adding and getting intervals
- (NSDate*) addTimeInterval: (NSTimeInterval)seconds
- (id) addTimeInterval: (NSTimeInterval)seconds
{
/* xxx We need to check for overflow? */
return [[self class] dateWithTimeIntervalSinceReferenceDate:

View file

@ -521,6 +521,7 @@ handle_printf_atsign (FILE *stream,
const unsigned char *test=[d bytes];
unsigned int len = [d length];
if (d == nil) return nil;
if(((test[0]==0xFF) && (test[1]==0xFE)) || ((test[1]==0xFF) && (test[0]==0xFE)))
enc = NSUnicodeStringEncoding;
else

View file

@ -47,10 +47,9 @@
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/fcntl.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <unistd.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
/*

21
Testing/nstask.m Normal file
View file

@ -0,0 +1,21 @@
#include <Foundation/NSAutoreleasePool.h>
#include <Foundation/NSTask.h>
int
main()
{
id pool;
NSTask *task;
pool = [[NSAutoreleasePool alloc] init];
task = [NSTask launchedTaskWithLaunchPath: @"/bin/ls"
arguments: nil];
[task waitUntilExit];
printf("Exit status - %d\n", [task terminationStatus]);
[pool release];
exit(0);
}

View file

@ -36,7 +36,7 @@ dread_OBJC_FILES = dread.m
dremove_OBJC_FILES = dremove.m
dwrite_OBJC_FILES = dwrite.m
SOURCES = gdomap.c dread.m dremove.m dwrite.m
SOURCES = gdomap.c defaults.m dread.m dremove.m dwrite.m
HEADERS = gdomap.h