mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 16:50:58 +00:00
make string standardisation more consistent
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@37675 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
4980155210
commit
a0c0b25aa8
4 changed files with 40 additions and 10 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2014-02-03 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/NSString.m: Fix standardising a path to use unix separators
|
||||||
|
consistently with appending a pathc component ... paths should be
|
||||||
|
(as far as possible) portable, and the filesystem representation
|
||||||
|
methods convert to backslashes as necessary on windows anyway.
|
||||||
|
|
||||||
2014-02-03 Richard Frith-Macdonald <rfm@gnu.org>
|
2014-02-03 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/Additions/GSMime.m:
|
* Source/Additions/GSMime.m:
|
||||||
|
|
|
@ -330,10 +330,12 @@ pathSepMember(unichar c)
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* For cross-platform portability we always use slash as the separator
|
||||||
* For cross-platform portability we always use slash as the separator
|
|
||||||
* when building paths ... unless specific windows path handling is
|
* when building paths ... unless specific windows path handling is
|
||||||
* required.
|
* required.
|
||||||
|
* This ensures that standardised paths and anything built by adding path
|
||||||
|
* components to them use a consistent separator character anad can be
|
||||||
|
* compared readily using standard string comparisons.
|
||||||
*/
|
*/
|
||||||
inline static unichar
|
inline static unichar
|
||||||
pathSepChar()
|
pathSepChar()
|
||||||
|
@ -4762,14 +4764,20 @@ static NSFileManager *fm = nil;
|
||||||
s = AUTORELEASE([self mutableCopy]);
|
s = AUTORELEASE([self mutableCopy]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GSPathHandlingUnix() == YES)
|
/* We must always use the standard path separator unless specifically set
|
||||||
{
|
* to use the mswindows one. That ensures that standardised paths and
|
||||||
[s replaceString: @"\\" withString: @"/"];
|
* anything built by adding path components to them use a consistent
|
||||||
}
|
* separator character anad can be compared readily using standard string
|
||||||
else if (GSPathHandlingWindows() == YES)
|
* comparisons.
|
||||||
|
*/
|
||||||
|
if (GSPathHandlingWindows() == YES)
|
||||||
{
|
{
|
||||||
[s replaceString: @"/" withString: @"\\"];
|
[s replaceString: @"/" withString: @"\\"];
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[s replaceString: @"\\" withString: @"/"];
|
||||||
|
}
|
||||||
|
|
||||||
l = [s length];
|
l = [s length];
|
||||||
root = rootOf(s, l);
|
root = rootOf(s, l);
|
||||||
|
|
|
@ -23,5 +23,5 @@ include $(GNUSTEP_MAKEFILES)/test-tool.make
|
||||||
-include GNUmakefile.postamble
|
-include GNUmakefile.postamble
|
||||||
|
|
||||||
after-clean::
|
after-clean::
|
||||||
rm -f core tests.log tests.sum oldtests.log oldtests.sum
|
rm -f core core.* *.core tests.log tests.sum oldtests.log oldtests.sum
|
||||||
|
|
||||||
|
|
|
@ -214,8 +214,7 @@ NSLog(@"Developer: %@", NSSearchPathForDirectoriesInDomains(NSDeveloperDirectory
|
||||||
|
|
||||||
#ifdef GNUSTEP_BASE_LIBRARY
|
#ifdef GNUSTEP_BASE_LIBRARY
|
||||||
|
|
||||||
PASS_EQUAL([@"//home/user/" stringByStandardizingPath], @"//home/user/",
|
GSPathHandling("windows");
|
||||||
"//home/user/ stringByStandardizingPath == //home/user/");
|
|
||||||
|
|
||||||
PASS_EQUAL([@"\\\\home\\user\\" stringByStandardizingPath],
|
PASS_EQUAL([@"\\\\home\\user\\" stringByStandardizingPath],
|
||||||
@"\\\\home\\user\\",
|
@"\\\\home\\user\\",
|
||||||
|
@ -226,10 +225,26 @@ NSLog(@"Developer: %@", NSSearchPathForDirectoriesInDomains(NSDeveloperDirectory
|
||||||
|
|
||||||
PASS_EQUAL([@"c:\\..." stringByStandardizingPath], @"c:\\...",
|
PASS_EQUAL([@"c:\\..." stringByStandardizingPath], @"c:\\...",
|
||||||
"'c:\\...' stringByStandardizingPath == 'c:\\...'");
|
"'c:\\...' stringByStandardizingPath == 'c:\\...'");
|
||||||
|
|
||||||
|
PASS([@"c:\\home" isAbsolutePath] == YES,
|
||||||
|
"'c:\\home' isAbsolutePath == YES");
|
||||||
|
|
||||||
|
GSPathHandling("right");
|
||||||
|
|
||||||
|
PASS_EQUAL([@"//home/user/" stringByStandardizingPath],
|
||||||
|
@"//home/user/",
|
||||||
|
"//home/user/ stringByStandardizingPath == //home/user/");
|
||||||
|
|
||||||
|
PASS_EQUAL([@"c:/." stringByStandardizingPath], @"c:/.",
|
||||||
|
"'c:/.' stringByStandardizingPath == 'c:/.'");
|
||||||
|
|
||||||
|
PASS_EQUAL([@"c:/..." stringByStandardizingPath], @"c:/...",
|
||||||
|
"'c:/...' stringByStandardizingPath == 'c:/...'");
|
||||||
|
|
||||||
PASS([@"c:/home" isAbsolutePath] == YES,
|
PASS([@"c:/home" isAbsolutePath] == YES,
|
||||||
"'c:/home' isAbsolutePath == YES");
|
"'c:/home' isAbsolutePath == YES");
|
||||||
|
|
||||||
|
|
||||||
PASS([@"//host/share/" isAbsolutePath] == YES,
|
PASS([@"//host/share/" isAbsolutePath] == YES,
|
||||||
"'//host/share/' isAbsolutePath == YES");
|
"'//host/share/' isAbsolutePath == YES");
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue