• R/O
  • SSH
  • HTTPS

ttssh2: Commit


Commit MetaInfo

Revision7385 (tree)
Time2019-01-10 23:19:57
Authorzmatsuo

Log Message

Merge branch 'trunk' r7384 into cmake

Change Summary

Incremental Difference

--- branches/cmake/teraterm/common/codeconv.cpp (revision 7384)
+++ branches/cmake/teraterm/common/codeconv.cpp (revision 7385)
@@ -90,8 +90,11 @@
9090 */
9191 wchar_t *_MultiByteToWideChar(const char *str_ptr, size_t str_len, int code_page, size_t *w_len_)
9292 {
93- const DWORD flags = MB_ERR_INVALID_CHARS;
94- wchar_t *wstr_ptr;
93+ DWORD flags = MB_ERR_INVALID_CHARS;
94+ if (code_page == CP_UTF8) {
95+ // CP_UTF8 When this is set, dwFlags must be zero.
96+ flags = 0;
97+ }
9598 if (w_len_ != NULL) {
9699 *w_len_ = 0;
97100 }
@@ -104,7 +107,7 @@
104107 if (len == 0) {
105108 return NULL;
106109 }
107- wstr_ptr = (wchar_t *)malloc(len*sizeof(wchar_t));
110+ wchar_t *wstr_ptr = (wchar_t *)malloc(len*sizeof(wchar_t));
108111 if (wstr_ptr == NULL) {
109112 return NULL;
110113 }
@@ -121,13 +124,11 @@
121124 return wstr_ptr;
122125 }
123126
124-//#if defined(UNICODE)
125127 const char *ToCharW(const wchar_t *strW)
126128 {
127129 const char *strA = _WideCharToMultiByte(strW, 0, CP_ACP, NULL);
128130 return strA;
129131 }
130-//#endif
131132
132133 const char *ToCharA(const char *strA)
133134 {
@@ -137,40 +138,29 @@
137138 const char *ToCharU8(const char *strU8)
138139 {
139140 const wchar_t *strW = _MultiByteToWideChar(strU8, 0, CP_UTF8, NULL);
141+ if (strW == NULL) {
142+ return NULL;
143+ }
140144 const char *strA = _WideCharToMultiByte(strW, 0, CP_ACP, NULL);
141145 free((void *)strW);
142146 return strA;
143147 }
144148
145-const TCHAR *ToTcharA(const char *strA)
149+const wchar_t *ToWcharA(const char *strA)
146150 {
147-#if defined(UNICODE)
148151 wchar_t *strW = _MultiByteToWideChar(strA, 0, CP_ACP, NULL);
149152 return strW;
150-#else
151- return ToCharA(strA);
152-#endif
153153 }
154154
155-const TCHAR *ToTcharW(const wchar_t *strW)
155+const wchar_t *ToWcharW(const wchar_t *strW)
156156 {
157-#if defined(UNICODE)
158157 return _wcsdup(strW);
159-#else
160- return ToCharW(strW);
161-#endif
162158 }
163159
164-const TCHAR *ToTcharU8(const char *strU8)
160+const wchar_t *ToWcharU8(const char *strU8)
165161 {
166162 const wchar_t *strW = _MultiByteToWideChar(strU8, 0, CP_UTF8, NULL);
167-#if defined(UNICODE)
168163 return strW;
169-#else
170- const char *strA = _WideCharToMultiByte(strW, 0, CP_ACP, NULL);
171- free((void *)strW);
172- return strA;
173-#endif
174164 }
175165
176166 const char *ToU8W(const wchar_t *strW)
--- branches/cmake/teraterm/common/codeconv.h (revision 7384)
+++ branches/cmake/teraterm/common/codeconv.h (revision 7385)
@@ -37,22 +37,27 @@
3737 char *_WideCharToMultiByte(const wchar_t *wstr_ptr, size_t wstr_len, int code_page, size_t *mb_len_);
3838 wchar_t *_MultiByteToWideChar(const char *str_ptr, size_t str_len, int code_page, size_t *w_len_);
3939
40-const TCHAR *ToTcharA(const char *strA);
41-const TCHAR *ToTcharW(const wchar_t *strW);
42-const TCHAR *ToTcharU8(const char *strU8);
4340 const char *ToCharA(const char *strA);
4441 const char *ToCharW(const wchar_t *strW);
4542 const char *ToCharU8(const char *strU8);
4643 const wchar_t *ToWcharA(const char *strA);
44+const wchar_t *ToWcharW(const wchar_t *strW);
45+const wchar_t *ToWcharU8(const char *strU8);
4746 const char *ToU8A(const char *strA);
4847 const char *ToU8W(const wchar_t *strW);
4948
5049 #if defined(_UNICODE)
51-#define ToCharT(s) ToCharW(s)
52-#define ToU8T(s) ToU8W(s)
50+#define ToTcharA(s) ToWcharA(s)
51+#define ToTcharW(s) ToWcharW(s)
52+#define ToTcharU8(s) ToWcharU8(s)
53+#define ToCharT(s) ToCharW(s)
54+#define ToU8T(s) ToU8W(s)
5355 #else
54-#define ToCharT(s) ToCharA(s)
55-#define ToU8T(s) ToU8A(s)
56+#define ToTcharA(s) ToCharA(s)
57+#define ToTcharW(s) ToCharW(s)
58+#define ToTcharU8(s) ToCharU8(s)
59+#define ToCharT(s) ToCharA(s)
60+#define ToU8T(s) ToU8A(s)
5661 #endif
5762
5863 #ifdef __cplusplus
@@ -60,13 +65,7 @@
6065 #endif
6166
6267 #ifdef __cplusplus
63-TCHAR *ToTchar(const char *strA);
64-TCHAR *ToTchar(const wchar_t *strW);
65-#endif
6668
67-
68-#ifdef __cplusplus
69-
7069 #if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER > 1910))
7170 #define MOVE_CONSTRUCTOR_ENABLE
7271 #endif
Show on old repository browser