changeset 684:aa29b98f5242

[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
author thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
date Wed, 13 May 2009 15:10:13 +0000
parents e141699be970
children d593c70b73d5
files src/IndentHandler.cpp src/UniversalIndentGUI.vcproj src/UniversalIndentGUI_NPP/UniversalIndentGUI_NPP.vcproj
diffstat 3 files changed, 41 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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 <Windows.h>
+#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("'", "&#39;");
     htmlText.replace("^", "&circ;");
     htmlText.replace("~", "&tilde;");
-    htmlText.replace("€", "&euro;");
-    htmlText.replace("©", "&copy;");
+    htmlText.replace("€", "&euro;");
+    htmlText.replace("©", "&copy;");
     return htmlText;
 }
--- 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="&quot;$(OutDir)\tmp\uic\&quot;;&quot;$(QTDIR)\include\QtScript&quot;"
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
 				RuntimeLibrary="2"
+				TreatWChar_tAsBuiltInType="false"
 				UsePrecompiledHeader="0"
 				ObjectFile="$(IntDir)\obj\"
 				WarningLevel="3"
--- 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="&quot;$(QTDIR)\include\QtScript&quot;;.;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"