check argument to setRootNode: and avoid unnecessary read on http connection.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@24125 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2006-11-18 08:03:05 +00:00
parent e79db74f01
commit 7a1453fd68
3 changed files with 25 additions and 12 deletions

View file

@ -1,3 +1,10 @@
2006-11-18 Richard Frith-Macdonald <rfm@gnu.org>
* Source/Additions/GSXML.m: ([setRootNode:]) Add checks for invalid
argument and improve documentation.
* Source/GSHTTPURLHandle.m: don't keep unecessary read operation in
progress on idle connection.
2006-11-15 Nicola Pero <nicola.pero@meta-innovation.com>
Notice: you should now use 'make DESTDIR=/tmp/xxx install' if you

View file

@ -470,20 +470,27 @@ static NSMapTable *attrNames = 0;
}
/**
* Sets the root node of the document.
* Sets the root of the document.<br />
* NB. The node must have been created as part of the receiving document
* (eg. using the -makeNodeWithNamespace:name:content: method).
*/
- (GSXMLNode*) setRoot: (GSXMLNode*)node
{
void *nodeLib = [node lib];
void *oldRoot = xmlDocSetRootElement(lib, nodeLib);
GSXMLNode *n;
xmlNodePtr nodeLib = (xmlNodePtr)[node lib];
xmlNodePtr selfLib = (xmlNodePtr)[self lib];
if (oldRoot == NULL)
return nil;
n = [GSXMLNode alloc];
n = [n _initFrom: nodeLib parent: self];
return AUTORELEASE(n);
if (node == nil)
{
[NSException raise: NSInvalidArgumentException
format: @"Attempt to set root of document to nil"];
}
if (nodeLib->doc != selfLib->doc)
{
[NSException raise: NSInvalidArgumentException
format: @"Attempt to set root to node from other document"];
}
xmlDocSetRootElement(lib, nodeLib);
return node;
}
/**

View file

@ -734,8 +734,7 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
[self backgroundLoadDidFailWithReason: @"Response parse failed"];
}
if (sock != nil
&& (connectionState == reading || connectionState == idle))
if (sock != nil && connectionState == reading)
{
if ([sock readInProgress] == NO)
{