summaryrefslogtreecommitdiffstats
path: root/Source/cmSystemTools.cxx
diff options
context:
space:
mode:
authorKen Martin <ken.martin@kitware.com>2002-05-31 12:39:49 (GMT)
committerKen Martin <ken.martin@kitware.com>2002-05-31 12:39:49 (GMT)
commit993aebb7482c99ab1149f23b981ef83410e1af2e (patch)
tree658ad657d7bab840dde562ec9dda6c4c38d93bd3 /Source/cmSystemTools.cxx
parentc24c2cca18c9bdf03de7e165259e3b87251ef1fe (diff)
downloadCMake-993aebb7482c99ab1149f23b981ef83410e1af2e.zip
CMake-993aebb7482c99ab1149f23b981ef83410e1af2e.tar.gz
CMake-993aebb7482c99ab1149f23b981ef83410e1af2e.tar.bz2
fixed bug in get short path for quoted paths
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r--Source/cmSystemTools.cxx19
1 files changed, 18 insertions, 1 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 37404c2..6db6e7a 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -1960,8 +1960,23 @@ bool cmSystemTools::GetShortPath(const char* path, std::string& shortPath)
#if defined(WIN32) && !defined(__CYGWIN__)
const int size = int(strlen(path)) +1; // size of return
char *buffer = new char[size]; // create a buffer
+ char *tempPath = new char[size]; // create a buffer
+ int ret;
+
+ // if the path passed in has quotes around it, first remove the quotes
+ if (path[0] == '"' && path[strlen(path)-1] == '"')
+ {
+ strcpy(tempPath,path+1);
+ tempPath[strlen(tempPath)-1] = '\0';
+ }
+ else
+ {
+ strcpy(tempPath,path);
+ }
+
buffer[0] = 0;
- int ret = GetShortPathName(path, buffer, size);
+ ret = GetShortPathName(tempPath, buffer, size);
+
if(buffer[0] == 0 || ret > size)
{
if(ret < size)
@@ -1982,12 +1997,14 @@ bool cmSystemTools::GetShortPath(const char* path, std::string& shortPath)
LocalFree( lpMsgBuf );
}
cmSystemTools::Error("Unable to get a short path: ", path);
+ delete [] tempPath;
return false;
}
else
{
shortPath = buffer;
delete [] buffer;
+ delete [] tempPath;
return true;
}
#else