OSX compatibility tweaks

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@28727 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2009-09-23 10:07:13 +00:00
parent 04e3fff827
commit c81da3592a
2 changed files with 58 additions and 35 deletions

View file

@ -1,3 +1,8 @@
2009-09-23 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSURL.m: OSX compatibility tweaks ... allows initialisation
using a string containing a simple path without any scheme.
2009-09-17 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSIndexSet.m:

View file

@ -664,6 +664,7 @@ static unsigned urlAlign;
* Initialised using aUrlString and aBaseUrl. The value of aBaseUrl
* may be nil, but aUrlString must be non-nil.<br />
* Accepts RFC2732 style IPv6 host addresses.<br />
* Parses a string wihthout a scheme as a simple path.<br />
* If the string cannot be parsed the method returns nil.
*/
- (id) initWithString: (NSString*)aUrlString
@ -762,25 +763,22 @@ static unsigned urlAlign;
/*
* Set up scheme specific parsing options.
*/
if (buf->scheme == 0)
if (buf->scheme != 0)
{
DESTROY(self); // Not a valid URL
NS_VALRETURN(nil);
}
if (strcmp(buf->scheme, "file") == 0)
{
usesFragments = NO;
usesParameters = NO;
usesQueries = NO;
buf->isFile = YES;
}
else if (strcmp(buf->scheme, "mailto") == 0)
{
usesFragments = NO;
usesParameters = NO;
usesQueries = NO;
}
if (strcmp(buf->scheme, "file") == 0)
{
usesFragments = NO;
usesParameters = NO;
usesQueries = NO;
buf->isFile = YES;
}
else if (strcmp(buf->scheme, "mailto") == 0)
{
usesFragments = NO;
usesParameters = NO;
usesQueries = NO;
}
}
if (canBeGeneric == YES)
{
@ -1253,11 +1251,17 @@ static unsigned urlAlign;
{
*tmp++ = '/';
}
strcpy(tmp, myData->path);
if (myData->path != 0)
{
strcpy(tmp, myData->path);
}
}
else if (_baseURL == nil)
{
strcpy(tmp, myData->path);
if (myData->path != 0)
{
strcpy(tmp, myData->path);
}
}
else if (*myData->path == 0)
{
@ -1265,12 +1269,15 @@ static unsigned urlAlign;
{
*tmp++ = '/';
}
strcpy(tmp, baseData->path);
if (baseData->path != 0)
{
strcpy(tmp, baseData->path);
}
}
else
{
char *start = baseData->path;
char *end = strrchr(start, '/');
char *end = (start == 0) ? 0 : strrchr(start, '/');
if (end != 0)
{
@ -1279,7 +1286,10 @@ static unsigned urlAlign;
tmp += end - start;
}
*tmp++ = '/';
strcpy(tmp, myData->path);
if (myData->path != 0)
{
strcpy(tmp, myData->path);
}
}
unescape(buf, buf);
@ -1311,14 +1321,18 @@ static unsigned urlAlign;
- (NSString*) fullPath
{
NSString *path = nil;
unsigned int len = 3;
/*
* If this scheme is from a URL without generic format, there is no path.
*/
if (myData->isGeneric == YES)
if (_baseURL != nil && baseData->path != 0)
{
len += strlen(baseData->path);
}
if (myData->path != 0)
{
len += strlen(myData->path);
}
if (len > 3)
{
unsigned int len = (_baseURL ? strlen(baseData->path) : 0)
+ strlen(myData->path) + 3;
char buf[len];
char *ptr;
@ -1489,14 +1503,18 @@ static unsigned urlAlign;
- (NSString*) path
{
NSString *path = nil;
unsigned int len = 3;
/*
* If this scheme is from a URL without generic format, there is no path.
*/
if (myData->isGeneric == YES)
if (_baseURL != nil && baseData->path != 0)
{
len += strlen(baseData->path);
}
if (myData->path != 0)
{
len += strlen(myData->path);
}
if (len > 3)
{
unsigned int len = (_baseURL ? strlen(baseData->path) : 0)
+ strlen(myData->path) + 3;
char buf[len];
char *ptr;
char *tmp;