KWSys 2016-01-11 (e8bf616e)

Code extracted from:

    http://public.kitware.com/KWSys.git

at commit e8bf616e3556368bf19dbebcd3529a89011ebacb (master).

Upstream Shortlog
-----------------

Brad King (1):
      e8bf616e SystemTools: Fix GetShortPath buffer sizing

Jan van Dorsten (1):
      cfb2477d SystemTools: Simplify GetShortPath de-quoting step

Robert Maynard (1):
      8ef9773d Don't use clang diagnostic pragma's when compiling with ICC on OSX.
This commit is contained in:
KWSys Upstream 2016-01-11 09:01:00 -05:00 committed by Brad King
parent f2b0bf6e3f
commit 8e7356a292
3 changed files with 10 additions and 19 deletions

4
MD5.c
View File

@ -29,7 +29,7 @@
it in a single source file instead of a separate header and it in a single source file instead of a separate header and
implementation file. */ implementation file. */
#if defined(__clang__) #if defined(__clang__) && !defined(__INTEL_COMPILER)
# pragma clang diagnostic push # pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wcast-align" # pragma clang diagnostic ignored "-Wcast-align"
#endif #endif
@ -433,7 +433,7 @@ static void md5_finish(md5_state_t *pms, md5_byte_t digest[16])
digest[i] = (md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3)); digest[i] = (md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3));
} }
#if defined(__clang__) #if defined(__clang__) && !defined(__INTEL_COMPILER)
# pragma clang diagnostic pop # pragma clang diagnostic pop
#endif #endif

View File

@ -1595,12 +1595,12 @@ static void kwsysProcessVolatileFree(volatile void* p)
{ {
/* clang has made it impossible to free memory that points to volatile /* clang has made it impossible to free memory that points to volatile
without first using special pragmas to disable a warning... */ without first using special pragmas to disable a warning... */
#if defined(__clang__) #if defined(__clang__) && !defined(__INTEL_COMPILER)
# pragma clang diagnostic push # pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wcast-qual" # pragma clang diagnostic ignored "-Wcast-qual"
#endif #endif
free((void*)p); /* The cast will silence most compilers, but not clang. */ free((void*)p); /* The cast will silence most compilers, but not clang. */
#if defined(__clang__) #if defined(__clang__) && !defined(__INTEL_COMPILER)
# pragma clang diagnostic pop # pragma clang diagnostic pop
#endif #endif
} }

View File

@ -4491,36 +4491,27 @@ bool SystemTools::FileIsFullPath(const char* in_name, size_t len)
bool SystemTools::GetShortPath(const std::string& path, std::string& shortPath) bool SystemTools::GetShortPath(const std::string& path, std::string& shortPath)
{ {
#if defined(_WIN32) && !defined(__CYGWIN__) #if defined(_WIN32) && !defined(__CYGWIN__)
const int size = int(path.size()) +1; // size of return std::string tempPath = path; // create a buffer
char *tempPath = new char[size]; // create a buffer
DWORD ret;
// if the path passed in has quotes around it, first remove the quotes // if the path passed in has quotes around it, first remove the quotes
if (!path.empty() && path[0] == '"' && *path.rbegin() == '"') if (!path.empty() && path[0] == '"' && *path.rbegin() == '"')
{ {
strcpy(tempPath,path.c_str()+1); tempPath = path.substr(1, path.length()-2);
tempPath[size-2] = '\0';
}
else
{
strcpy(tempPath,path.c_str());
} }
std::wstring wtempPath = Encoding::ToWide(tempPath); std::wstring wtempPath = Encoding::ToWide(tempPath);
std::vector<wchar_t> buffer(wtempPath.size()+1); DWORD ret = GetShortPathNameW(wtempPath.c_str(), NULL, 0);
buffer[0] = 0; std::vector<wchar_t> buffer(ret);
ret = GetShortPathNameW(wtempPath.c_str(), ret = GetShortPathNameW(wtempPath.c_str(),
&buffer[0], static_cast<DWORD>(wtempPath.size())); &buffer[0], static_cast<DWORD>(buffer.size()));
if(buffer[0] == 0 || ret > wtempPath.size()) if (ret == 0)
{ {
delete [] tempPath;
return false; return false;
} }
else else
{ {
shortPath = Encoding::ToNarrow(&buffer[0]); shortPath = Encoding::ToNarrow(&buffer[0]);
delete [] tempPath;
return true; return true;
} }
#else #else