From fadff337910f1c6faf5a2e36afe54b6ea1aee0e8 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Thu, 7 Apr 2005 13:03:47 -0400 Subject: [PATCH] BUG: fix for bug 1717 incorrect path sent to dart server --- Source/CTest/cmCTestBuildHandler.cxx | 24 +++++++++++++++++++++++- Source/kwsys/SystemTools.cxx | 20 ++++++++++++++++++++ Source/kwsys/SystemTools.hxx.in | 8 ++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index 110ab564b..b6f4e38ee 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -463,7 +463,11 @@ void cmCTestBuildHandler::GenerateDartBuildOutput( // only report the first 50 warnings and first 50 errors unsigned short numErrorsAllowed = 50; unsigned short numWarningsAllowed = 50; - + std::string srcdir = m_CTest->GetDartConfiguration("SourceDirectory"); + // make sure the source dir is in the correct case on windows + // via a call to collapse full path. + srcdir = cmSystemTools::CollapseFullPath(srcdir.c_str()); + srcdir += "/"; for ( it = ew.begin(); it != ew.end() && (numErrorsAllowed || numWarningsAllowed); it++ ) { @@ -491,6 +495,24 @@ void cmCTestBuildHandler::GenerateDartBuildOutput( if ( re->find(cm->m_Text.c_str() ) ) { cm->m_SourceFile = re->match(rit->m_FileIndex); + // At this point we need to make m_SourceFile relative to + // the source root of the project, so cvs links will work + cmSystemTools::ConvertToUnixSlashes(cm->m_SourceFile); + if(cm->m_SourceFile.find("/.../") != cm->m_SourceFile.npos) + { + cmSystemTools::ReplaceString(cm->m_SourceFile, "/.../", ""); + std::string::size_type p = cm->m_SourceFile.find("/"); + if(p != cm->m_SourceFile.npos) + { + cm->m_SourceFile = cm->m_SourceFile.substr(p+1, cm->m_SourceFile.size()-p); + } + } + else + { + // make sure it is a full path with the correct case + cm->m_SourceFile = cmSystemTools::CollapseFullPath(cm->m_SourceFile.c_str()); + cmSystemTools::ReplaceString(cm->m_SourceFile, srcdir.c_str(), ""); + } cm->m_LineNumber = atoi(re->match(rit->m_LineIndex).c_str()); break; } diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index c40d4c5c0..a0e5e7e3d 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -2228,10 +2228,30 @@ kwsys_stl::string SystemTools::CollapseFullPath(const char* in_path, // Update the translation table with this potentially new path. SystemTools::AddTranslationPath(newPath.c_str(), in_path); SystemTools::CheckTranslationPath(newPath); +#ifdef _WIN32 + newPath = SystemTools::GetActualCaseForPath(newPath.c_str()); +#endif // Return the reconstructed path. return newPath; } +//---------------------------------------------------------------------------- +kwsys_stl::string SystemTools::GetActualCaseForPath(const char* p) +{ +#ifndef _WIN32 + return p; +#else + std::string path; + if(!SystemTools::GetShortPath(p, path)) + { + return path; + } + char buffer[MAX_PATH+1]; + ::GetLongPathName(path.c_str(), buffer, MAX_PATH+1); + return buffer; +#endif +} + //---------------------------------------------------------------------------- void SystemTools::SplitPath(const char* p, kwsys_stl::vector& components) diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in index 0a1d6db69..eec2617ad 100644 --- a/Source/kwsys/SystemTools.hxx.in +++ b/Source/kwsys/SystemTools.hxx.in @@ -241,6 +241,14 @@ public: */ static const char* GetExecutableExtension(); + /** + * Given a path that exists on a windows machine, return the + * actuall case of the path as it was created. If the file + * does not exist path is returned unchanged. This does nothing + * on unix but return path. + */ + static kwsys_stl::string GetActualCaseForPath(const char* path); + /** * Given the path to a program executable, get the directory part of * the path with the file stripped off. If there is no directory