# HG changeset patch # User thomas_-_s # Date 1242227413 0 # Node ID aa29b98f52427837e09de9e2badafc17df23545d # Parent e141699be970a7455b54acc67259869faf5c905e [fix] Bug ID 2791229: If UiGUI was located in a path containing Unicode characters or such a path needed to be handed over to a called indenter, the indenter could get confused on Windows. So using the Windows 8.3 short path notation. git-svn-id: svn://svn.code.sf.net/p/universalindent/code/trunk@952 59b1889a-e5ac-428c-b0c7-476e01d41282 diff -r e141699be970 -r aa29b98f5242 src/IndentHandler.cpp --- a/src/IndentHandler.cpp Wed May 13 09:50:12 2009 +0000 +++ b/src/IndentHandler.cpp Wed May 13 15:10:13 2009 +0000 @@ -21,6 +21,10 @@ #include "UiGuiSettings.h" +#ifdef Q_OS_WIN32 +#include +#endif + //! \defgroup grp_Indenter All concerning handling of the indenter. /*! @@ -422,6 +426,37 @@ parameterOuputFile = " " + outputFileParameter + outputFileName + inputFileExtension; } +#ifdef Q_OS_WIN32 + // Paths may contain Unicode or other foreign characters. Windows commands line tools will + // receive als falsely encoded path string by QProcess or they connot correctly handle + // the Unicode path on their own. + // Because of this the path gets converted to Windows short paths using the 8.3 notation. + + // At first convert the temp path to Windows like separators. + QString tempDirctoryStrHelper = QDir::toNativeSeparators(tempDirctoryStr).replace("\\", "\\\\"); + // Then convert the QString to a WCHAR array and NULL terminate it. + WCHAR *tempDirctoryWindowsStr = new WCHAR[ tempDirctoryStrHelper.length()+1 ]; + tempDirctoryStrHelper.toWCharArray( tempDirctoryWindowsStr ); + tempDirctoryWindowsStr[ tempDirctoryStrHelper.length() ] = (WCHAR)NULL; + + // Get the length of the resulting short path. + long length = 0; + TCHAR *buffer = NULL; + length = GetShortPathName((LPCTSTR)tempDirctoryWindowsStr, NULL, 0); + + // If the short path could be retrieved, create a correct sized buffer, store the + // short path in it and convert all back to QString. + if ( length != 0 ) { + buffer = new WCHAR[length]; + length = GetShortPathName((LPCTSTR)tempDirctoryWindowsStr, buffer, length); + tempDirctoryStrHelper = QString::fromWCharArray( buffer ); + tempDirctoryStr = QDir::fromNativeSeparators(tempDirctoryStrHelper).replace("//", "/"); + delete buffer; + } + + delete tempDirctoryWindowsStr; +#endif + // If the config file name is empty it is assumed that all parameters are sent via command line call if ( configFilename.isEmpty() ) { parameterParameterFile = " " + parameterString; @@ -1629,7 +1664,7 @@ htmlText.replace("'", "'"); htmlText.replace("^", "ˆ"); htmlText.replace("~", "˜"); - htmlText.replace("€", "€"); - htmlText.replace("©", "©"); + htmlText.replace("€", "€"); + htmlText.replace("©", "©"); return htmlText; } diff -r e141699be970 -r aa29b98f5242 src/UniversalIndentGUI.vcproj --- a/src/UniversalIndentGUI.vcproj Wed May 13 09:50:12 2009 +0000 +++ b/src/UniversalIndentGUI.vcproj Wed May 13 15:10:13 2009 +0000 @@ -59,6 +59,7 @@ MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="3" + TreatWChar_tAsBuiltInType="false" UsePrecompiledHeader="0" ObjectFile="$(IntDir)\obj\" WarningLevel="3" @@ -148,6 +149,7 @@ AdditionalIncludeDirectories=""$(OutDir)\tmp\uic\";"$(QTDIR)\include\QtScript"" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS" RuntimeLibrary="2" + TreatWChar_tAsBuiltInType="false" UsePrecompiledHeader="0" ObjectFile="$(IntDir)\obj\" WarningLevel="3" diff -r e141699be970 -r aa29b98f5242 src/UniversalIndentGUI_NPP/UniversalIndentGUI_NPP.vcproj --- a/src/UniversalIndentGUI_NPP/UniversalIndentGUI_NPP.vcproj Wed May 13 09:50:12 2009 +0000 +++ b/src/UniversalIndentGUI_NPP/UniversalIndentGUI_NPP.vcproj Wed May 13 15:10:13 2009 +0000 @@ -58,6 +58,7 @@ MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="3" + TreatWChar_tAsBuiltInType="false" UsePrecompiledHeader="0" ObjectFile="$(IntDir)\obj\" ProgramDataBaseFileName="$(OutDir)\$(TargetName).pdb" @@ -148,6 +149,7 @@ AdditionalIncludeDirectories=""$(QTDIR)\include\QtScript";.;NPPCommon;.." PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;UNIVERSALINDENTGUI_NPP_EXPORTS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE" RuntimeLibrary="2" + TreatWChar_tAsBuiltInType="false" UsePrecompiledHeader="0" WarningLevel="3" Detect64BitPortabilityProblems="true"