From 3bdbce0bdec78257f54a2400ad535e3e6dd41e97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 11 Sep 2016 20:27:57 +0200 Subject: [PATCH] bump simplecpp 2917a13fbda2df9742d5f45d33f40f58217b6708 --- externals/simplecpp/simplecpp.cpp | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/externals/simplecpp/simplecpp.cpp b/externals/simplecpp/simplecpp.cpp index d06480286..aeaf0a0f3 100644 --- a/externals/simplecpp/simplecpp.cpp +++ b/externals/simplecpp/simplecpp.cpp @@ -1565,19 +1565,33 @@ private: namespace simplecpp { #ifdef SIMPLECPP_WINDOWS -std::string realFilename(const std::string &f) { + +static bool realFileName(const std::vector &buf, std::ostream &ostr) { WIN32_FIND_DATA FindFileData; - TCHAR buf[4096] = {0}; + HANDLE hFind = FindFirstFile(&buf[0], &FindFileData); + if (hFind == INVALID_HANDLE_VALUE) + return false; + for (const TCHAR *c = FindFileData.cFileName; *c; c++) + ostr << (char)*c; + FindClose(hFind); + return true; +} + +std::string realFilename(const std::string &f) { + std::vector buf(f.size()+1U, 0); for (unsigned int i = 0; i < f.size(); ++i) buf[i] = f[i]; - HANDLE hFind = FindFirstFile(buf, &FindFileData); - if (hFind == INVALID_HANDLE_VALUE) - return f; std::ostringstream ostr; - for (const TCHAR *c = FindFileData.cFileName; *c; c++) { - ostr << (char)*c; + std::string::size_type sep = 0; + while ((sep = f.find_first_of("\\/", sep + 1U)) != std::string::npos) { + buf[sep] = 0; + if (!realFileName(buf,ostr)) + return f; + ostr << '/'; + buf[sep] = '/'; } - FindClose(hFind); + if (!realFileName(buf, ostr)) + return f; return ostr.str(); } #else