summaryrefslogtreecommitdiff
path: root/idlc
diff options
context:
space:
mode:
authorJürgen Schmidt <jsc@apache.org>2014-06-10 13:18:31 +0000
committerCaolán McNamara <caolanm@redhat.com>2014-06-10 16:26:08 +0100
commit2c5b3e7764d7d3213d3448c3c6c424a19d0c837c (patch)
tree3e5c7f7f4d3498936717e836f5bdbd1232baf8b3 /idlc
parent4dbeadb9c1e46ac0008f076cd6f9c5d0a38a4d40 (diff)
Resolves: #i122368# convert inc paths into short form on windows...
to avoid problem with ucpp (cherry picked from commit 6e370ddd6b532e7bf12df3aa52f93913f4ea8348) Conflicts: idlc/source/options.cxx Change-Id: Ia8c7dc3a9a7df68a483dd106cd47c8624952aeae
Diffstat (limited to 'idlc')
-rw-r--r--idlc/source/options.cxx52
1 files changed, 51 insertions, 1 deletions
diff --git a/idlc/source/options.cxx b/idlc/source/options.cxx
index c04603d118b7..9a15ea795ca9 100644
--- a/idlc/source/options.cxx
+++ b/idlc/source/options.cxx
@@ -24,6 +24,28 @@
#include <rtl/string.hxx>
#include <rtl/strbuf.hxx>
+#include "rtl/ustring.hxx"
+#include "osl/file.hxx"
+
+#ifdef WNT
+# include <windows.h>
+#endif
+
+/*
+#ifndef WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN
+# ifdef _MSC_VER
+# pragma warning(push,1)
+# endif
+# include <windows.h>
+# ifdef _MSC_VER
+# pragma warning(pop)
+# endif
+# include <tchar.h>
+# undef WIN32_LEAN_AND_MEAN
+#endif
+*/
+
#include <stdio.h>
#include <string.h>
@@ -169,6 +191,29 @@ bool Options::setOption(char const * option, std::string const & rArg)
return (result);
}
+#ifdef WNT
+/* Helper functiopn to convert windows paths including spaces, brackets etc. into
+ a windows short Url. The ucpp preprocessor has problems with such paths and returns
+ with error.
+*/
+OString convertIncPathtoShortWindowsPath(const OString& incPath) {
+ OUString path = OStringToOUString(incPath, RTL_TEXTENCODING_UTF8);
+
+ std::vector<sal_Unicode> vec(path.getLength() + 1);
+ //GetShortPathNameW only works if the file can be found!
+ const DWORD len = GetShortPathNameW(
+ reinterpret_cast<LPCWSTR>(path.getStr()), reinterpret_cast<LPWSTR>(&vec[0]), path.getLength() + 1);
+
+ if (len > 0)
+ {
+ OUString ret(&vec[0], len);
+ return OUStringToOString(ret, RTL_TEXTENCODING_UTF8);
+ }
+
+ return incPath;
+}
+#endif
+
bool Options::initOptions(std::vector< std::string > & rArgs) throw(IllegalArgument)
{
std::vector< std::string >::const_iterator first = rArgs.begin(), last = rArgs.end();
@@ -225,7 +270,12 @@ bool Options::initOptions(std::vector< std::string > & rArgs) throw(IllegalArgum
if (!buffer.isEmpty())
buffer.append(' ');
// buffer.append("-I\"");
- buffer.append(param.getToken(0, ';', k));
+#ifdef WNT
+ OString incpath = convertIncPathtoShortWindowsPath(param.getToken(0, ';', k));
+#else
+ OString incpath = param.getToken(0, ';', k);
+#endif
+ buffer.append(incpath);
// buffer.append("\"");
} while (k != -1);
param = buffer.makeStringAndClear();