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
This commit is contained in:
parent
4dbeadb9c1
commit
2c5b3e7764
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user