[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[TSVN] [Patch] TMerge Unicode build

From: Norbert Unterberg <nepo_at_gmx.net>
Date: 2005-04-16 13:52:40 CEST

After having lost work recently because of TMerge's inability of
handling UTF-8 files correctly, I offer a patch. It enables UNICODE for
the TortoiseMerge project.

However, since I don't know the subversion/apr API, I am not sure if I
the encoding of file names is correct. There a two function calls into
subversion (svn_diff_file_diff and svn_diff_file_diff3) where filenames
are now passed in ANSI encoding to the svn char* arguments. But I do not
know if subversion expects the file names in ANSI or UTF-8 encoding,
maybe we need to call different encoding function there.

At least a diff and merge now works even with UTF-8 file containing
russian and chinese characters, even on a German windows.

Norbert

Index: src/TortoiseMerge/WorkingFile.cpp
===================================================================
--- src/TortoiseMerge/WorkingFile.cpp (revision 3044)
+++ src/TortoiseMerge/WorkingFile.cpp (working copy)
@@ -68,7 +68,7 @@
 CString
 CWorkingFile::GetWindowName() const
 {
- CString sErrMsg = "";
+ CString sErrMsg = _T("");
         // TortoiseMerge allows non-existing files to be used in a merge
         // Inform the user (in a non-intrusive way) if a file is absent
         if (! this->Exists())
Index: src/TortoiseMerge/Patch.cpp
===================================================================
--- src/TortoiseMerge/Patch.cpp (revision 3044)
+++ src/TortoiseMerge/Patch.cpp (working copy)
@@ -440,7 +440,20 @@
                         {
                                 if (PatchLines.GetUnicodeType()==CFileTextLines::UTF8)
                                 {
+#ifdef UNICODE
+ // convert the UTF-8 contents in CString sPatchLine into a CStringA
+ CStringA sPatchLineA;
+ char *pszPatchLine = sPatchLineA.GetBuffer(sPatchLine.GetLength());
+ for (int k = 0; k < sPatchLine.GetLength(); ++k)
+ {
+ *pszPatchLine++ = (char)sPatchLine.GetAt(k);
+ }
+ *pszPatchLine = 0;
+ sPatchLineA.ReleaseBuffer();
+ sPatchLine = CUnicodeUtils::GetUnicode(sPatchLineA);
+#else
                                         sPatchLine = CUnicodeUtils::GetUnicode(sPatchLine);
+#endif
                                 }
                         }
                         int nPatchState = (int)chunk->arLinesStates.GetAt(j);
Index: src/TortoiseMerge/DiffData.cpp
===================================================================
--- src/TortoiseMerge/DiffData.cpp (revision 3044)
+++ src/TortoiseMerge/DiffData.cpp (working copy)
@@ -152,7 +152,7 @@
 
 BOOL CDiffData::Load()
 {
- CStringA sConvertedBaseFilename, sConvertedTheirFilename, sConvertedYourFilename;
+ CString sConvertedBaseFilename, sConvertedTheirFilename, sConvertedYourFilename;
         apr_pool_t * pool;
 
         apr_pool_create_ex (&pool, NULL, abort_on_pool_failure, NULL);
@@ -266,10 +266,13 @@
 bool
 CDiffData::DoTwoWayDiff(const CString& sBaseFilename, const CString& sYourFilename, DWORD dwIgnoreWS, apr_pool_t * pool)
 {
+ CStringA strBaseFilename(sBaseFilename);
+ CStringA strYourFilename(sYourFilename);
+
         svn_diff_t * diffYourBase = NULL;
         svn_error_t * svnerr = NULL;
 
- svnerr = svn_diff_file_diff(&diffYourBase, sBaseFilename, sYourFilename, pool);
+ svnerr = svn_diff_file_diff(&diffYourBase, strBaseFilename, strYourFilename, pool);
         if (svnerr)
         {
                 TRACE(_T("diff-error in CDiffData::Load()\n"));
@@ -462,8 +465,11 @@
 bool
 CDiffData::DoThreeWayDiff(const CString& sBaseFilename, const CString& sYourFilename, const CString& sTheirFilename, apr_pool_t * pool)
 {
+ CStringA strBaseFilename(sBaseFilename);
+ CStringA strYourFilename(sYourFilename);
+ CStringA strTheirFilename(sTheirFilename);
         svn_diff_t * diffTheirYourBase = NULL;
- svn_error_t * svnerr = svn_diff_file_diff3(&diffTheirYourBase, sBaseFilename, sTheirFilename, sYourFilename, pool);
+ svn_error_t * svnerr = svn_diff_file_diff3(&diffTheirYourBase, strBaseFilename, strTheirFilename, strYourFilename, pool);
         if (svnerr)
         {
                 TRACE(_T("diff-error in CDiffData::Load()\n"));
Index: src/TortoiseMerge/TortoiseMerge.vcproj
===================================================================
--- src/TortoiseMerge/TortoiseMerge.vcproj (revision 3044)
+++ src/TortoiseMerge/TortoiseMerge.vcproj (working copy)
@@ -17,7 +17,7 @@
                         IntermediateDirectory="..\..\obj\TortoiseMerge\Debug"
                         ConfigurationType="1"
                         UseOfMFC="2"
- CharacterSet="2">
+ CharacterSet="1">
                         <Tool
                                 Name="VCCLCompilerTool"
                                 Optimization="0"
@@ -71,7 +71,7 @@
                         IntermediateDirectory="..\..\obj\TortoiseMerge\Release"
                         ConfigurationType="1"
                         UseOfMFC="2"
- CharacterSet="2"
+ CharacterSet="1"
                         WholeProgramOptimization="TRUE">
                         <Tool
                                 Name="VCCLCompilerTool"

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tortoisesvn.tigris.org
For additional commands, e-mail: dev-help@tortoisesvn.tigris.org
Received on Sat Apr 16 13:53:13 2005

This is an archived mail posted to the TortoiseSVN Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.