From 86a247947387ded56f80533ff006c3747dc25030 Mon Sep 17 00:00:00 2001
From: Brad King <brad.king@kitware.com>
Date: Thu, 9 Jul 2015 15:42:12 -0400
Subject: [PATCH] SystemTools: Fix GetActualCaseForPath drive letter case
 handling

Convert the drive letter to upper case in the actual output value
instead of just our internal memoization map key.  This was broken by
commit 08b2dcff (Fix GetActualCaseForPath for UNC paths, 2010-08-16).

CMake-Issue: 15642
Change-Id: Iee7148616370d1be4be052c74b7a5d802ad47d93
---
 SystemTools.cxx | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/SystemTools.cxx b/SystemTools.cxx
index fed1c9c..c171727 100644
--- a/SystemTools.cxx
+++ b/SystemTools.cxx
@@ -3690,6 +3690,11 @@ static int GetCasePathName(const kwsys_stl::string & pathIn,
   // Start with root component.
   kwsys_stl::vector<kwsys_stl::string>::size_type idx = 0;
   casePath = path_components[idx++];
+  // make sure drive letter is always upper case
+  if(casePath.size() > 1 && casePath[1] == ':')
+    {
+    casePath[0] = toupper(casePath[0]);
+    }
   const char* sep = "";
 
   // If network path, fill casePath with server/share so FindFirstFile
@@ -3745,21 +3750,15 @@ kwsys_stl::string SystemTools::GetActualCaseForPath(const kwsys_stl::string& p)
 #ifndef _WIN32
   return p;
 #else
-  kwsys_stl::string casePath = p;
-  // make sure drive letter is always upper case
-  if(casePath.size() > 1 && casePath[1] == ':')
-    {
-    casePath[0] = toupper(casePath[0]);
-    }
-
   // Check to see if actual case has already been called
   // for this path, and the result is stored in the LongPathMap
   SystemToolsTranslationMap::iterator i =
-    SystemTools::LongPathMap->find(casePath);
+    SystemTools::LongPathMap->find(p);
   if(i != SystemTools::LongPathMap->end())
     {
     return i->second;
     }
+  kwsys_stl::string casePath;
   int len = GetCasePathName(p, casePath);
   if(len == 0 || len > MAX_PATH+1)
     {
-- 
GitLab