mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
Merge branch 'master' of github.com:gnustep/libs-base into NSSecureCoding_branch
This commit is contained in:
commit
264811b3d0
13 changed files with 809 additions and 596 deletions
|
@ -172,6 +172,19 @@ setupCache()
|
|||
}
|
||||
}
|
||||
|
||||
static int xmlNSInputStreamReadCallback(void *context, char *buffer, int len)
|
||||
{
|
||||
NSInputStream *stream = (NSInputStream *)context;
|
||||
return [stream read: (uint8_t *)buffer maxLength: len];
|
||||
}
|
||||
|
||||
static int xmlNSInputStreamCloseCallback (void *context)
|
||||
{
|
||||
NSInputStream *stream = (NSInputStream *)context;
|
||||
[stream close];
|
||||
return 0;
|
||||
}
|
||||
|
||||
static xmlParserInputPtr
|
||||
loadEntityFunction(const unsigned char *url, const unsigned char *eid,
|
||||
void *ctx);
|
||||
|
@ -2102,6 +2115,31 @@ static NSString *endMarker = @"At end of incremental parse";
|
|||
return self;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Initialisation of a new Parser with SAX handler (if not nil)
|
||||
* by calling -initWithSAXHandler:
|
||||
* </p>
|
||||
* <p>
|
||||
* Sets the input source for the parser to be the specified input stream,
|
||||
* so parsing of the entire document will be performed rather than
|
||||
* incremental parsing.
|
||||
* </p>
|
||||
*/
|
||||
- (id) initWithSAXHandler: (GSSAXHandler*)handler
|
||||
withInputStream: (NSInputStream*)stream
|
||||
{
|
||||
if (stream == nil || [stream isKindOfClass: [NSInputStream class]] == NO)
|
||||
{
|
||||
NSLog(@"Bad NSInputStream passed to initialize GSXMLParser");
|
||||
DESTROY(self);
|
||||
return nil;
|
||||
}
|
||||
src = RETAIN(stream);
|
||||
self = [self initWithSAXHandler: handler];
|
||||
return self;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set and return the previous value for blank text nodes support.
|
||||
* ignorableWhitespace nodes are only generated when running
|
||||
|
@ -2167,7 +2205,8 @@ static NSString *endMarker = @"At end of incremental parse";
|
|||
return NO;
|
||||
}
|
||||
|
||||
if ([src isKindOfClass: [NSData class]])
|
||||
if ([src isKindOfClass: [NSData class]]
|
||||
|| [src isKindOfClass: [NSInputStream class]])
|
||||
{
|
||||
}
|
||||
else if ([src isKindOfClass: NSString_class])
|
||||
|
@ -2194,14 +2233,22 @@ static NSString *endMarker = @"At end of incremental parse";
|
|||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"source for [-parse] must be NSString, NSData or NSURL type");
|
||||
NSLog(@"Source for [-parse] must be NSString, NSData, NSInputStream, or"
|
||||
@" NSURL type");
|
||||
return NO;
|
||||
}
|
||||
|
||||
tmp = RETAIN(src);
|
||||
ASSIGN(src, endMarker);
|
||||
[self _parseChunk: tmp];
|
||||
[self _parseChunk: nil];
|
||||
if ([tmp isKindOfClass: [NSInputStream class]])
|
||||
{
|
||||
xmlParseDocument(lib);
|
||||
}
|
||||
else
|
||||
{
|
||||
[self _parseChunk: tmp];
|
||||
[self _parseChunk: nil];
|
||||
}
|
||||
RELEASE(tmp);
|
||||
|
||||
if (((xmlParserCtxtPtr)lib)->wellFormed != 0
|
||||
|
@ -2382,7 +2429,19 @@ static NSString *endMarker = @"At end of incremental parse";
|
|||
{
|
||||
file = ".";
|
||||
}
|
||||
lib = (void*)xmlCreatePushParserCtxt([saxHandler lib], NULL, 0, 0, file);
|
||||
|
||||
if ([src isKindOfClass: [NSInputStream class]])
|
||||
{
|
||||
[(NSInputStream*)src open];
|
||||
lib = (void*)xmlCreateIOParserCtxt([saxHandler lib], NULL,
|
||||
xmlNSInputStreamReadCallback, xmlNSInputStreamCloseCallback,
|
||||
(void*)src, XML_CHAR_ENCODING_NONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
lib = (void*)xmlCreatePushParserCtxt([saxHandler lib], NULL, 0, 0, file);
|
||||
}
|
||||
|
||||
if (lib == NULL)
|
||||
{
|
||||
NSLog(@"Failed to create libxml parser context");
|
||||
|
|
|
@ -691,7 +691,7 @@ static NSRecursiveLock *classLock = nil;
|
|||
#endif
|
||||
}
|
||||
|
||||
- (NSString *) displayNameForKey: (id) key value: (id) value
|
||||
- (NSString *) displayNameForKey: (NSString *) key value: (id) value
|
||||
{
|
||||
#if GS_USE_ICU == 1
|
||||
int32_t length = 0;
|
||||
|
|
|
@ -2116,17 +2116,33 @@ GS_PRIVATE_INTERNAL(NSURLQueryItem)
|
|||
return AUTORELEASE(newQueryItem);
|
||||
}
|
||||
|
||||
- (instancetype)initWithName:(NSString *)name
|
||||
- (instancetype) init
|
||||
{
|
||||
self = [self initWithName:nil value:nil];
|
||||
if(self != nil)
|
||||
{
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithName:(NSString *)name
|
||||
value:(NSString *)value
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil)
|
||||
{
|
||||
GS_CREATE_INTERNAL(NSURLQueryItem);
|
||||
|
||||
ASSIGNCOPY(internal->_name, name);
|
||||
ASSIGNCOPY(internal->_value, value);
|
||||
}
|
||||
if(self != nil)
|
||||
{
|
||||
GS_CREATE_INTERNAL(NSURLQueryItem);
|
||||
if(name)
|
||||
{
|
||||
ASSIGNCOPY(internal->_name, name);
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSIGN(internal->_name, @""); //OSX behaviour is to set an empty string for nil name property
|
||||
}
|
||||
ASSIGNCOPY(internal->_value, value);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -2225,14 +2241,14 @@ static NSCharacterSet *queryItemCharSet = nil;
|
|||
// Creating URL components...
|
||||
+ (instancetype) componentsWithString: (NSString *)urlString
|
||||
{
|
||||
return [[NSURLComponents alloc] initWithString: urlString];
|
||||
return AUTORELEASE([[NSURLComponents alloc] initWithString: urlString]);
|
||||
}
|
||||
|
||||
+ (instancetype) componentsWithURL: (NSURL *)url
|
||||
resolvingAgainstBaseURL: (BOOL)resolve
|
||||
{
|
||||
return [[NSURLComponents alloc] initWithURL: url
|
||||
resolvingAgainstBaseURL: resolve];
|
||||
return AUTORELEASE([[NSURLComponents alloc] initWithURL: url
|
||||
resolvingAgainstBaseURL: resolve]);
|
||||
}
|
||||
|
||||
- (instancetype) init
|
||||
|
@ -2256,12 +2272,16 @@ static NSCharacterSet *queryItemCharSet = nil;
|
|||
|
||||
- (instancetype) initWithString: (NSString *)URLString
|
||||
{
|
||||
self = [self init];
|
||||
if (self != nil)
|
||||
//OSX behavior is to return nil for a string which cannot be used to initialize valid NSURL object
|
||||
NSURL* url = [NSURL URLWithString:URLString];
|
||||
if(url)
|
||||
{
|
||||
[self setString: URLString];
|
||||
return [self initWithURL:url resolvingAgainstBaseURL:NO];
|
||||
}
|
||||
else
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype) initWithURL: (NSURL *)url
|
||||
|
@ -2454,7 +2474,7 @@ static NSCharacterSet *queryItemCharSet = nil;
|
|||
[self setUser: [url user]];
|
||||
[self setPassword: [url password]];
|
||||
[self setPath: [url path]];
|
||||
[self setQuery: [url query]];
|
||||
[self setPercentEncodedQuery:[url query]];
|
||||
[self setFragment: [url fragment]];
|
||||
}
|
||||
|
||||
|
|
1103
Source/NSXMLParser.m
1103
Source/NSXMLParser.m
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue