Author: jsc Date: Tue Jun 10 13:18:31 2014 New Revision: 1601629 URL: http://svn.apache.org/r1601629 Log: #122368# convert inc paths into short form on windows to avoid problem with ucpp
Modified: openoffice/trunk/main/idlc/source/options.cxx Modified: openoffice/trunk/main/idlc/source/options.cxx URL: http://svn.apache.org/viewvc/openoffice/trunk/main/idlc/source/options.cxx?rev=1601629&r1=1601628&r2=1601629&view=diff ============================================================================== --- openoffice/trunk/main/idlc/source/options.cxx (original) +++ openoffice/trunk/main/idlc/source/options.cxx Tue Jun 10 13:18:31 2014 @@ -30,6 +30,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> @@ -182,6 +204,28 @@ bool Options::setOption(char const * opt 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) { + rtl::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); + + rtl::OUString ret = rtl::OUString(&vec[0], len); + + if (len > 0) + 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 +269,15 @@ bool Options::initOptions(std::vector< s sal_Int32 k = 0; do { - OStringBuffer token; token.append("-I"); token.append(param.getToken(0, ';', k)); + OStringBuffer token; + token.append("-I"); +#ifdef WNT + rtl::OString incpath = convertIncPathtoShortWindowsPath(param.getToken(0, ';', k)); +#else + rtl::OString incpath = param.getToken(0, ';', k); +#endif + token.append(incpath); + //token.append(param.getToken(0, ';', k)); if (buffer.getLength() > 0) buffer.append(' '); buffer.append(token);