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

[TSVN] [Patch] blame won't work

From: Norbert Unterberg <nepo_at_gmx.net>
Date: 2005-05-18 08:05:57 CEST

Steve,

please try attached patch. It plays around with the thread locales and
now it works at least for korean language, but there may be more trouble
lurking around ...

Norbert

Index: src/TortoiseProc/Blame.cpp
===================================================================
--- src/TortoiseProc/Blame.cpp (revision 3382)
+++ src/TortoiseProc/Blame.cpp (working copy)
@@ -24,6 +24,7 @@
 #include "Registry.h"
 #include "Utils.h"
 #include "UnicodeUtils.h"
+#include <mbctype.h>
 
 
 void CStdioFileA::WriteString(LPCSTR lpsz)
@@ -64,15 +65,27 @@
         m_highestrev = -1;
         m_nCounter = 0;
         m_nHeadRev = -1;
+
+ // save current locale before setting the new one
+ m_locale = setlocale(LC_CTYPE, NULL);
+ m_mbcp = _getmbcp();
+ m_LCID = GetThreadLocale();
+ setlocale(LC_CTYPE, "");
+ _setmbcp(_MB_CP_LOCALE);
+ SetThreadLocale(LOCALE_USER_DEFAULT);
 }
 CBlame::~CBlame()
 {
         m_progressDlg.Stop();
+ // restore previous locale
+ SetThreadLocale(m_LCID);
+ setlocale(LC_CTYPE, m_locale);
+ _setmbcp(m_mbcp);
 }
 
 BOOL CBlame::BlameCallback(LONG linenumber, LONG revision, const CString& author, const CString& date, const CStringA& line)
 {
- CString infolineA;
+ CStringA infolineA;
         CStringA fulllineA;
 
         if ((m_lowestrev < 0)||(m_lowestrev > revision))
@@ -80,8 +93,10 @@
         if (m_highestrev < revision)
                 m_highestrev = revision;
 
- CString dateA(CUnicodeUtils::GetUTF8(date));
- infolineA.Format(_T("%6ld %6ld %30s %-30s "), linenumber, revision, (LPCTSTR)dateA, (LPCTSTR)author);
+ CStringA dateA(date);
+ CStringA authorA(author);
+
+ infolineA.Format("%6ld %6ld %30s %-30s ", linenumber, revision, dateA, authorA);
         fulllineA = line;
         fulllineA.TrimRight("\r\n");
         fulllineA += "\n";
Index: src/TortoiseProc/Blame.h
===================================================================
--- src/TortoiseProc/Blame.h (revision 3382)
+++ src/TortoiseProc/Blame.h (working copy)
@@ -68,4 +68,7 @@
         CProgressDlg m_progressDlg; ///< The progress dialog shown during operation
         LONG m_lowestrev;
         LONG m_highestrev;
+ char* m_locale; ///< saved application's locale
+ int m_mbcp; ///< saved application's multibyte codepage
+ LCID m_LCID;
 };

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tortoisesvn.tigris.org
For additional commands, e-mail: dev-help@tortoisesvn.tigris.org
Received on Wed May 18 08:06:44 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.