mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Cleanups plus minor OSX compatibility tweak
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@31781 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
3f3fa66078
commit
b6f476a7eb
8 changed files with 45 additions and 41 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
2010-12-27 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* 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 <rfm@gnu.org>
|
||||
|
||||
* Source/NSString.m:
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
*/
|
||||
#define GREGORIAN_REFERENCE 730486
|
||||
|
||||
NSTimeInterval GSPrivateTimeNow() GS_ATTRIB_PRIVATE;
|
||||
|
||||
#include "GNUstepBase/GSObjCRuntime.h"
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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, "<?xml ", 6) != 0))
|
||||
{
|
||||
// not a valid XML document start
|
||||
return [self _parseError: @"missing <?xml > 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 <?xml > preamble"
|
||||
code: NSXMLParserDocumentStartError];
|
||||
}
|
||||
[self _processTag: tag
|
||||
isEnd: NO
|
||||
withAttributes: parameters]; // single <?tag ...?>
|
||||
|
|
Loading…
Reference in a new issue