From ca205223da31fcda6d9f59d831f98786111c2742 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 15 Feb 2005 16:03:14 -0500 Subject: [PATCH] BUG: Preserve trailing slash state when translating paths. --- Source/kwsys/SystemTools.cxx | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 6d95af89f..16f93bcc2 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::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,