summaryrefslogtreecommitdiffstats
path: root/Source/kwsys
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2005-02-15 21:03:14 (GMT)
committerBrad King <brad.king@kitware.com>2005-02-15 21:03:14 (GMT)
commitca205223da31fcda6d9f59d831f98786111c2742 (patch)
treefbd130b98857557b6063e40eb65845c3be637148 /Source/kwsys
parent3675a6e3a7a31856e4c5d160fd58eb45bc5e10eb (diff)
downloadCMake-ca205223da31fcda6d9f59d831f98786111c2742.zip
CMake-ca205223da31fcda6d9f59d831f98786111c2742.tar.gz
CMake-ca205223da31fcda6d9f59d831f98786111c2742.tar.bz2
BUG: Preserve trailing slash state when translating paths.
Diffstat (limited to 'Source/kwsys')
-rw-r--r--Source/kwsys/SystemTools.cxx25
1 files changed, 15 insertions, 10 deletions
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index 6d95af8..16f93bc 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -1565,6 +1565,18 @@ void SystemTools::AddKeepPath(const char* dir)
void SystemTools::CheckTranslationPath(kwsys_stl::string & path)
{
+ // Do not translate paths that are too short to have meaningful
+ // translations.
+ if(path.size() < 2)
+ {
+ return;
+ }
+
+ // Always add a trailing slash before translation. It does not
+ // matter if this adds an extra slash, but we do not want to
+ // translate part of a directory (like the foo part of foo-dir).
+ path += "/";
+
// In case a file was specified we still have to go through this:
// Now convert any path found in the table back to the one desired:
kwsys_stl::map<kwsys_stl::string,kwsys_stl::string>::const_iterator it;
@@ -1573,21 +1585,14 @@ void SystemTools::CheckTranslationPath(kwsys_stl::string & path)
++it )
{
// We need to check of the path is a substring of the other path
- // But also check that the last character is a '/' otherwise we could
- // have some weird case such as /tmp/VTK and /tmp/VTK-bin
- if(path.size() > 1 && path[path.size()-1] != '/')
- {
- // Do not append '/' on a program name:
- if( SystemTools::FileIsDirectory( path.c_str() ) )
- {
- path += "/";
- }
- }
if(path.find( it->first ) == 0)
{
path = path.replace( 0, it->first.size(), it->second);
}
}
+
+ // Remove the trailing slash we added before.
+ path.erase(path.end()-1, path.end());
}
kwsys_stl::string SystemTools::CollapseFullPath(const char* in_relative,