diff --git a/ChangeLog b/ChangeLog index 25fc0658b..17b541c27 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2010-12-27 Richard Frith-Macdonald + + * Source/GSPrivate.h: + * Source/NSCalendarDate.m: + * Source/NSDate.m: + * Source/NSProcessInfo.m: + * Source/NSRunLoop.m: + Change GSTimeNow() to GSPrivateTimeNow() to indicate scope of function. + * Source/NSThread.m: + Remove duplicate declaration of obbjc thread callback. + * Source/NSXMLParser.m: + Try to duplicate OSX behavior in handling start of document. + 2010-12-26 Richard Frith-Macdonald * Source/NSString.m: diff --git a/Source/GSPrivate.h b/Source/GSPrivate.h index 86ad70e52..042db7462 100644 --- a/Source/GSPrivate.h +++ b/Source/GSPrivate.h @@ -49,6 +49,7 @@ */ #define GREGORIAN_REFERENCE 730486 +NSTimeInterval GSPrivateTimeNow() GS_ATTRIB_PRIVATE; #include "GNUstepBase/GSObjCRuntime.h" diff --git a/Source/NSCalendarDate.m b/Source/NSCalendarDate.m index 060bee480..702c9e1f2 100644 --- a/Source/NSCalendarDate.m +++ b/Source/NSCalendarDate.m @@ -284,7 +284,7 @@ GSBreakTime(NSTimeInterval when, int *year, int *month, int *day, * Returns the current time (seconds since reference date) as an NSTimeInterval. */ NSTimeInterval -GSTimeNow(void) +GSPrivateTimeNow(void) { NSTimeInterval t; #if !defined(__MINGW__) @@ -321,7 +321,7 @@ GSTimeNow(void) diff, ctime(&now)); /* Get time again ... should be OK now. */ - t = GSTimeNow(); + t = GSPrivateTimeNow(); } } } diff --git a/Source/NSDate.m b/Source/NSDate.m index 10a826540..5c07af19c 100644 --- a/Source/NSDate.m +++ b/Source/NSDate.m @@ -54,8 +54,6 @@ const NSTimeInterval NSTimeIntervalSince1970 = 978307200.0; -extern NSTimeInterval GSTimeNow(); // In NSCalendarDate.m - static BOOL debug = NO; static Class abstractClass = nil; static Class concreteClass = nil; @@ -160,7 +158,7 @@ otherTime(NSDate* other) */ + (NSTimeInterval) timeIntervalSinceReferenceDate { - return GSTimeNow(); + return GSPrivateTimeNow(); } /** @@ -169,7 +167,7 @@ otherTime(NSDate* other) + (id) date { return AUTORELEASE([[self allocWithZone: NSDefaultMallocZone()] - initWithTimeIntervalSinceReferenceDate: GSTimeNow()]); + initWithTimeIntervalSinceReferenceDate: GSPrivateTimeNow()]); } /** @@ -1060,7 +1058,7 @@ otherTime(NSDate* other) */ - (id) init { - return [self initWithTimeIntervalSinceReferenceDate: GSTimeNow()]; + return [self initWithTimeIntervalSinceReferenceDate: GSPrivateTimeNow()]; } /** @@ -1111,7 +1109,7 @@ otherTime(NSDate* other) { // Get the current time, add the secs and init thyself return [self initWithTimeIntervalSinceReferenceDate: - GSTimeNow() + secsToBeAdded]; + GSPrivateTimeNow() + secsToBeAdded]; } /** @@ -1248,7 +1246,7 @@ otherTime(NSDate* other) */ - (NSTimeInterval) timeIntervalSinceNow { - return otherTime(self) - GSTimeNow(); + return otherTime(self) - GSPrivateTimeNow(); } /** @@ -1416,7 +1414,7 @@ otherTime(NSDate* other) - (NSTimeInterval) timeIntervalSinceNow { - return _seconds_since_ref - GSTimeNow(); + return _seconds_since_ref - GSPrivateTimeNow(); } - (NSTimeInterval) timeIntervalSinceReferenceDate diff --git a/Source/NSProcessInfo.m b/Source/NSProcessInfo.m index 8953d4842..aa3b6894b 100644 --- a/Source/NSProcessInfo.m +++ b/Source/NSProcessInfo.m @@ -1013,10 +1013,8 @@ int main(int argc, char *argv[], char *env[]) [gnustep_global_lock lock]; if (host == nil) { - extern NSTimeInterval GSTimeNow(void); - pid = [self processIdentifier]; - start = (unsigned long)GSTimeNow(); + start = (unsigned long)GSPrivateTimeNow(); host = [[self hostName] stringByReplacingString: @"." withString: @"_"]; IF_NO_GC(RETAIN(host);) } diff --git a/Source/NSRunLoop.m b/Source/NSRunLoop.m index 40d23900d..7b7187f36 100644 --- a/Source/NSRunLoop.m +++ b/Source/NSRunLoop.m @@ -947,7 +947,6 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now) _currentMode = mode; NS_DURING { - extern NSTimeInterval GSTimeNow(void); GSIArray timers = context->timers; NSTimeInterval now; NSDate *earliest; @@ -969,7 +968,7 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now) * just keep firing the timer repeatedly and never return from * this method. */ - now = GSTimeNow(); + now = GSPrivateTimeNow(); /* Fire housekeeping timer as necessary */ diff --git a/Source/NSThread.m b/Source/NSThread.m index 83ace45cf..b30d8eb04 100644 --- a/Source/NSThread.m +++ b/Source/NSThread.m @@ -88,12 +88,6 @@ #define PTHREAD_MIN_PRIORITY 0 #endif -#if !defined(__GNUSTEP_RUNTIME__) && !defined(NeXT_RUNTIME) -typedef void (*objc_thread_callback) (void); -objc_thread_callback objc_set_thread_callback (objc_thread_callback func); -#endif - -extern NSTimeInterval GSTimeNow(void); @interface NSAutoreleasePool (NSThread) + (void) _endThread: (NSThread*)thread; @@ -157,7 +151,7 @@ GSSleepUntilIntervalSinceReferenceDate(NSTimeInterval when) NSTimeInterval delay; // delay is always the number of seconds we still need to wait - delay = when - GSTimeNow(); + delay = when - GSPrivateTimeNow(); if (delay <= 0.0) { sched_yield(); @@ -173,7 +167,7 @@ GSSleepUntilIntervalSinceReferenceDate(NSTimeInterval when) request.tv_sec = (time_t)32768; request.tv_nsec = (long)0; nanosleep(&request, 0); - delay = when - GSTimeNow(); + delay = when - GSPrivateTimeNow(); } if (delay > 0) { @@ -212,7 +206,7 @@ GSSleepUntilIntervalSinceReferenceDate(NSTimeInterval when) #else sleep (30*60); #endif - delay = when - GSTimeNow(); + delay = when - GSPrivateTimeNow(); } /* @@ -244,7 +238,7 @@ GSSleepUntilIntervalSinceReferenceDate(NSTimeInterval when) sleep ((NSInteger)delay); #endif /* HAVE_USLEEP */ #endif /* __MINGW__ */ - delay = when - GSTimeNow(); + delay = when - GSPrivateTimeNow(); } #endif /* HAVE_NANOSLEEP */ } @@ -600,7 +594,7 @@ unregisterActiveThread(NSThread *thread) + (void) sleepForTimeInterval: (NSTimeInterval)ti { - GSSleepUntilIntervalSinceReferenceDate(GSTimeNow() + ti); + GSSleepUntilIntervalSinceReferenceDate(GSPrivateTimeNow() + ti); } /** diff --git a/Source/NSXMLParser.m b/Source/NSXMLParser.m index 345113093..3751d8a60 100644 --- a/Source/NSXMLParser.m +++ b/Source/NSXMLParser.m @@ -632,6 +632,7 @@ typedef struct NSXMLParserIvarsType BOOL shouldReportNamespacePrefixes; BOOL shouldResolveExternalEntities; BOOL acceptHTML; // be lazy with bad tag nesting + BOOL hasStarted; IMP didEndElement; IMP didEndMappingPrefix; IMP didStartElement; @@ -925,15 +926,14 @@ static SEL foundIgnorableSel; if (this->didEndElement != 0) { - NSString *qualified = nil; - NSString *uri = nil; + NSString *qualified = tag; + NSString *uri = @""; if (this->shouldProcessNamespaces) { NSRange r = [tag rangeOfString: @":"]; NSString *p = @""; - qualified = tag; if (r.length > 0) { p = [tag substringToIndex: r.location]; @@ -979,15 +979,19 @@ static SEL foundIgnorableSel; } if (!flag) { - if ([tag isEqualToString: @"?xml"]) + if (NO == this->hasStarted) { #if EXTRA_DEBUG NSLog(@"parserDidStartDocument: "); #endif + this->hasStarted = YES; if ([_del respondsToSelector: @selector(parserDidStartDocument:)]) { [_del parserDidStartDocument: self]; } + } + if ([tag isEqualToString: @"?xml"]) + { return; } else if ([tag hasPrefix: @"?"]) @@ -1069,12 +1073,12 @@ NSLog(@"_processTag <%@%@ %@>", flag?@"/": @"", tag, attributes); if (this->didStartElement != 0) { + qualified = tag; if (this->shouldProcessNamespaces) { NSRange r = [tag rangeOfString: @":"]; NSString *p = @""; - qualified = tag; if (r.length > 0) { p = [tag substringToIndex: r.location]; @@ -1084,8 +1088,7 @@ NSLog(@"_processTag <%@%@ %@>", flag?@"/": @"", tag, attributes); } else { - qualified = nil; - uri = nil; + uri = @""; } (*this->didStartElement)(_del, didStartElementSel, self, tag, uri, qualified, attributes); @@ -1262,14 +1265,6 @@ NSLog(@"_processTag <%@%@ %@>", flag?@"/": @"", tag, attributes); const unsigned char *vp = this->cp; // value pointer int c; - if (!this->acceptHTML - && (this->cend - this->cp < 6 - || strncmp((char *)this->cp, " preamble" - code: NSXMLParserDocumentStartError]; - } /* Start by accumulating ignorable whitespace. */ this->ignorable = YES; @@ -1570,6 +1565,12 @@ NSLog(@"_processTag <%@%@ %@>", flag?@"/": @"", tag, attributes); code: NSXMLParserGTRequiredError]; } // process + if ([tag isEqualToString: @"xml"] + && tp != [this->data bytes]) + { + return [self _parseError: @"bad preamble" + code: NSXMLParserDocumentStartError]; + } [self _processTag: tag isEnd: NO withAttributes: parameters]; // single