Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 2.1.2 and tip

stable shellext: remove wrong hf_mbtowc() from TortoiseUtils.cpp

For example, u'\u65e5\u672c'(means Japan in Japanese KANJI)
is two characters in wide character.

>>> >>> len(u'\u65e5\u672c')
2

In shift-jis, this word needs four bytes.

>>> >>> len(u'\u65e5\u672c'.encode("shift-jis"))
4

Changeset 2e733771095b

Parent 1c302f225d77

by Toshi MARUYAMA

Changes to 3 files · Browse files at 2e733771095b Showing diff from parent 1c302f225d77 Diff from another changeset...

 
140
141
142
143
 
144
145
 
146
147
148
 
683
684
685
686
 
 
687
688
689
 
140
141
142
 
143
144
 
145
146
147
148
 
683
684
685
 
686
687
688
689
690
@@ -140,9 +140,9 @@
 )  {   std::wstring subkey = L"Software\\TortoiseHg\\CMenu\\"; - subkey += _WCSTR(lang.c_str()); + subkey += MultibyteToWide(lang);   subkey += L"\\"; - subkey += _WCSTR(name.c_str()); + subkey += MultibyteToWide(name);     TDEBUG_TRACEW(L"GetCMenuTranslation: " << subkey);   @@ -683,7 +683,8 @@
  if (uFlags & GCS_UNICODE)   {   wchar_t* const dest = reinterpret_cast<wchar_t*>(pszName); - const wchar_t* const src = pszw ? pszw : _WCSTR(psz); + std::wstring wpsz = MultibyteToWide(psz); + const wchar_t* const src = pszw ? pszw : wpsz.c_str();     wcsncpy(dest, src, cchMax-1);   *(dest + cchMax-1) = 0;
 
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 
11
12
13
 
 
 
 
 
 
 
 
 
 
 
14
15
16
@@ -11,17 +11,6 @@
 #include "shlwapi.h"     -LPWSTR hf_mbtowc(LPWSTR lpw, LPCSTR lpa, int nChars) -{ - assert(lpa != NULL); - assert(lpw != NULL); - - lpw[0] = '\0'; - MultiByteToWideChar(CP_ACP, 0, lpa, -1, lpw, nChars); - return lpw; -} - -  std::string GetTHgProgRoot()  {   LPCSTR regname = "Software\\TortoiseHg";
 
6
7
8
9
10
11
12
13
14
15
 
6
7
8
 
 
 
 
9
10
11
@@ -6,10 +6,6 @@
 #include <string>  #include <vector>   -#define _WCSTR(str) hf_mbtowc((LPWSTR)alloca((strlen(str) + 1) * sizeof(WCHAR)),(str),strlen(str) + 1) - -LPWSTR hf_mbtowc(LPWSTR lpw, LPCSTR lpa, int nChars); -  std::string GetTHgProgRoot();  std::string GetTemporaryFile(LPCSTR prefix="THG");  bool IsDirectory(const std::string&);