diff --git a/ChangeLog b/ChangeLog index 53a7f4eb5..15e523c2b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,9 @@ -Wed Jan 7 20:25:00 1997 Richard Frith-Macdonald +Wed Jan 21 09:41:46 1998 Adam Fedor + + * 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 * Tools/GNUmakefile: Added defaults.m @@ -11,11 +16,18 @@ Wed Jan 7 20:25:00 1997 Richard Frith-Macdonald * 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 ([+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 * 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 * 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 diff --git a/Headers/gnustep/base/NSDate.h b/Headers/gnustep/base/NSDate.h index 0b92ee4fd..4936224fc 100644 --- a/Headers/gnustep/base/NSDate.h +++ b/Headers/gnustep/base/NSDate.h @@ -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; diff --git a/Source/GetDefEncoding.m b/Source/GetDefEncoding.m index 83c978078..37bcdde1c 100644 --- a/Source/GetDefEncoding.m +++ b/Source/GetDefEncoding.m @@ -86,7 +86,10 @@ NSStringEncoding GetDefEncoding() if(!(ret==_availableEncodings[count])) tmp=0; else + { tmp=ret; + break; + } count++; }; if(!tmp) diff --git a/Source/Makefile.postamble b/Source/Makefile.postamble index 0a1950b56..e0e12aa89 100644 --- a/Source/Makefile.postamble +++ b/Source/Makefile.postamble @@ -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" $< > $@ diff --git a/Source/NSArray.m b/Source/NSArray.m index c1804d900..a3b4e1937 100644 --- a/Source/NSArray.m +++ b/Source/NSArray.m @@ -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]; diff --git a/Source/NSCalendarDate.m b/Source/NSCalendarDate.m index 6fbaa3847..7fa72d40a 100644 --- a/Source/NSCalendarDate.m +++ b/Source/NSCalendarDate.m @@ -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; diff --git a/Source/NSDate.m b/Source/NSDate.m index 9ad1ef525..4affb4e7b 100644 --- a/Source/NSDate.m +++ b/Source/NSDate.m @@ -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: diff --git a/Source/NSString.m b/Source/NSString.m index 0e5637c48..7fbc008f5 100644 --- a/Source/NSString.m +++ b/Source/NSString.m @@ -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 diff --git a/Source/UnixFileHandle.m b/Source/UnixFileHandle.m index 41e82d939..f947f7749 100644 --- a/Source/UnixFileHandle.m +++ b/Source/UnixFileHandle.m @@ -47,10 +47,9 @@ #include #include #include -#include #include -#include #include +#include #include /* diff --git a/Testing/nstask.m b/Testing/nstask.m new file mode 100644 index 000000000..db3d1548b --- /dev/null +++ b/Testing/nstask.m @@ -0,0 +1,21 @@ +#include +#include + +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); +} + diff --git a/Tools/GNUmakefile b/Tools/GNUmakefile index 44ecc4a52..9741276c1 100644 --- a/Tools/GNUmakefile +++ b/Tools/GNUmakefile @@ -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