mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-18 11:41:06 +00:00
fix bug appending path to empty string on windows
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@35462 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
d4e6a1d1fd
commit
bdec3a0c48
2 changed files with 63 additions and 51 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2012-08-27 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/NSSstring.m: ([-stringByAppendingPathComponent:]) fix for
|
||||||
|
append to an empty string with a windows path as an argument.
|
||||||
|
|
||||||
2012-08-26 Niels Grewe <niels.grewe@halbordnung.de>
|
2012-08-26 Niels Grewe <niels.grewe@halbordnung.de>
|
||||||
|
|
||||||
* configure.ac: Check for sys/filio.h and whether we need to
|
* configure.ac: Check for sys/filio.h and whether we need to
|
||||||
|
|
|
@ -3846,10 +3846,18 @@ static NSFileManager *fm = nil;
|
||||||
unsigned root;
|
unsigned root;
|
||||||
unichar buf[length+aLength+1];
|
unichar buf[length+aLength+1];
|
||||||
|
|
||||||
|
root = rootOf(aString, aLength);
|
||||||
|
|
||||||
|
if (length == 0)
|
||||||
|
{
|
||||||
|
[aString getCharacters: buf range: ((NSRange){0, aLength})];
|
||||||
|
length = aLength;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
/* If the 'component' has a leading path separator (or drive spec
|
/* If the 'component' has a leading path separator (or drive spec
|
||||||
* in windows) then we need to find its length so we can strip it.
|
* in windows) then we need to find its length so we can strip it.
|
||||||
*/
|
*/
|
||||||
root = rootOf(aString, aLength);
|
|
||||||
if (root > 0)
|
if (root > 0)
|
||||||
{
|
{
|
||||||
unichar c = [aString characterAtIndex: 0];
|
unichar c = [aString characterAtIndex: 0];
|
||||||
|
@ -3874,13 +3882,6 @@ static NSFileManager *fm = nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (length == 0)
|
|
||||||
{
|
|
||||||
[aString getCharacters: buf range: ((NSRange){0, aLength})];
|
|
||||||
length = aLength;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
[self getCharacters: buf range: ((NSRange){0, length})];
|
[self getCharacters: buf range: ((NSRange){0, length})];
|
||||||
|
|
||||||
/* We strip back trailing path separators, and replace them with
|
/* We strip back trailing path separators, and replace them with
|
||||||
|
@ -3912,9 +3913,15 @@ static NSFileManager *fm = nil;
|
||||||
root = rootOf(self, originalLength);
|
root = rootOf(self, originalLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trim trailing path separators
|
if (length > 0)
|
||||||
while (length > 1 && pathSepMember(buf[length-1]) == YES)
|
|
||||||
{
|
{
|
||||||
|
/* Trim trailing path separators as long as they are not part of
|
||||||
|
* the root.
|
||||||
|
*/
|
||||||
|
aLength = length - 1;
|
||||||
|
while (aLength > root && pathSepMember(buf[aLength]) == YES)
|
||||||
|
{
|
||||||
|
aLength--;
|
||||||
length--;
|
length--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3923,7 +3930,6 @@ static NSFileManager *fm = nil;
|
||||||
*/
|
*/
|
||||||
if (length > 0)
|
if (length > 0)
|
||||||
{
|
{
|
||||||
aLength = length - 1;
|
|
||||||
while (aLength > root)
|
while (aLength > root)
|
||||||
{
|
{
|
||||||
if (pathSepMember(buf[aLength]) == YES)
|
if (pathSepMember(buf[aLength]) == YES)
|
||||||
|
@ -3944,6 +3950,7 @@ static NSFileManager *fm = nil;
|
||||||
aLength--;
|
aLength--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return [NSStringClass stringWithCharacters: buf length: length];
|
return [NSStringClass stringWithCharacters: buf length: length];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue