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:
fedor 1998-01-21 14:56:24 +00:00
parent 02d2c9b813
commit baf22d947f
11 changed files with 147 additions and 70 deletions

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>
/*