mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 16:30:41 +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
e41faab415
commit
1a3698162b
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>
|
||||
|
||||
* Source/Additions/GSMime.m:
|
||||
|
|
|
@ -330,10 +330,12 @@ pathSepMember(unichar c)
|
|||
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
|
||||
* 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
|
||||
pathSepChar()
|
||||
|
@ -4762,14 +4764,20 @@ static NSFileManager *fm = nil;
|
|||
s = AUTORELEASE([self mutableCopy]);
|
||||
}
|
||||
|
||||
if (GSPathHandlingUnix() == YES)
|
||||
{
|
||||
[s replaceString: @"\\" withString: @"/"];
|
||||
}
|
||||
else if (GSPathHandlingWindows() == YES)
|
||||
/* We must always use the standard path separator unless specifically set
|
||||
* to use the mswindows one. That 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.
|
||||
*/
|
||||
if (GSPathHandlingWindows() == YES)
|
||||
{
|
||||
[s replaceString: @"/" withString: @"\\"];
|
||||
}
|
||||
else
|
||||
{
|
||||
[s replaceString: @"\\" withString: @"/"];
|
||||
}
|
||||
|
||||
l = [s length];
|
||||
root = rootOf(s, l);
|
||||
|
|
|
@ -23,5 +23,5 @@ include $(GNUSTEP_MAKEFILES)/test-tool.make
|
|||
-include GNUmakefile.postamble
|
||||
|
||||
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
|
||||
|
||||
PASS_EQUAL([@"//home/user/" stringByStandardizingPath], @"//home/user/",
|
||||
"//home/user/ stringByStandardizingPath == //home/user/");
|
||||
GSPathHandling("windows");
|
||||
|
||||
PASS_EQUAL([@"\\\\home\\user\\" stringByStandardizingPath],
|
||||
@"\\\\home\\user\\",
|
||||
|
@ -226,10 +225,26 @@ NSLog(@"Developer: %@", NSSearchPathForDirectoriesInDomains(NSDeveloperDirectory
|
|||
|
||||
PASS_EQUAL([@"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,
|
||||
"'c:/home' isAbsolutePath == YES");
|
||||
|
||||
|
||||
PASS([@"//host/share/" isAbsolutePath] == YES,
|
||||
"'//host/share/' isAbsolutePath == YES");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue