• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

FFFTPのソースコードです。


Commit MetaInfo

修訂3efb66ad5ef6a7e965b9b8b23852e826b7302c5f (tree)
時間2011-09-12 21:49:27
作者s_kawamoto <s_kawamoto@user...>
Commiters_kawamoto

Log Message

This version may be nearly stable.
Fix bugs of UTF-8 to UTF-16 API bridge.
Fix bugs of behavior caused by uninitialized variables.
Disable regular expression (JRE32.DLL does not support UTF-8).
Fix bugs of remote file list view.
Change default settings to discard file list cache.

Change Summary

差異

Binary files a/FFFTP.exe and b/FFFTP.exe differ
--- a/bookmark.c
+++ b/bookmark.c
@@ -45,6 +45,10 @@
4545 #include <htmlhelp.h>
4646 #include "helpid.h"
4747
48+// UTF-8対応
49+#undef __MBSWRAPPER_H__
50+#include "mbswrapper.h"
51+
4852
4953 /*===== プロトタイプ =====*/
5054
--- a/config.h
+++ b/config.h
@@ -13,4 +13,6 @@
1313 //#define DISABLE_TRANSFER_NETWORK_BUFFERS
1414 // コントロール用のネットワークバッファを無効にする(フリーズ対策)
1515 #define DISABLE_CONTROL_NETWORK_BUFFERS
16+// JRE32.DLLを無効にする(UTF-8に非対応のため)
17+#define DISABLE_JRE32DLL
1618
--- a/connect.c
+++ b/connect.c
@@ -45,6 +45,10 @@
4545 #include <htmlhelp.h>
4646 #include "helpid.h"
4747
48+// UTF-8対応
49+#undef __MBSWRAPPER_H__
50+#include "mbswrapper.h"
51+
4852
4953 /*===== プロトタイプ =====*/
5054
@@ -1227,6 +1231,7 @@ static SOCKET DoConnect(char *Host, char *User, char *Pass, char *Acct, int Port
12271231 Flg = 1;
12281232 if(setsockopt(ContSock, SOL_SOCKET, SO_OOBINLINE, (LPSTR)&Flg, sizeof(Flg)) == SOCKET_ERROR)
12291233 ReportWSError("setsockopt", WSAGetLastError());
1234+ // データ転送用ソケットのTCP遅延転送が無効されているので念のため
12301235 if(setsockopt(ContSock, IPPROTO_TCP, TCP_NODELAY, (LPSTR)&Flg, sizeof(Flg)) == SOCKET_ERROR)
12311236 ReportWSError("setsockopt", WSAGetLastError());
12321237 #pragma aaa
--- a/filelist.c
+++ b/filelist.c
@@ -54,6 +54,10 @@
5454 #include "OleDragDrop.h"
5555 #include "common.h"
5656
57+// UTF-8対応
58+#undef __MBSWRAPPER_H__
59+#include "mbswrapper.h"
60+
5761 #define BUF_SIZE 256
5862 #define CF_CNT 2
5963 #define WM_DRAGDROP (WM_APP + 100)
@@ -603,14 +607,19 @@ static HDROP APIPRIVATE CreateDropFileMem(char **FileName,int cnt,BOOL fWide)
603607 if(fWide == TRUE){
604608 /* ワイドキャラ */
605609 for(i = 0;i < cnt;i++){
606- MultiByteToWideChar(CP_ACP,0,FileName[i],-1,wbuf,BUF_SIZE);
607- flen += (wcslen(wbuf) + 1) * sizeof(wchar_t);
610+ // UTF-8対応
611+// MultiByteToWideChar(CP_ACP,0,FileName[i],-1,wbuf,BUF_SIZE);
612+// flen += (wcslen(wbuf) + 1) * sizeof(wchar_t);
613+ flen += sizeof(wchar_t) * MtoW(NULL, 0, FileName[i], -1);
608614 }
609615 flen++;
610616 }else{
611617 /* マルチバイト */
612618 for(i = 0;i < cnt;i++){
613- flen += lstrlen(FileName[i]) + 1;
619+ // UTF-8対応
620+// flen += lstrlen(FileName[i]) + 1;
621+ MtoW(wbuf, BUF_SIZE, FileName[i], -1);
622+ flen += sizeof(char) * WtoA(NULL, 0, wbuf, -1);
614623 }
615624 }
616625
@@ -633,9 +642,11 @@ static HDROP APIPRIVATE CreateDropFileMem(char **FileName,int cnt,BOOL fWide)
633642
634643 buf = (wchar_t *)(&lpDropFile[1]);
635644 for(i = 0;i < cnt;i++){
636- MultiByteToWideChar(CP_ACP,0,FileName[i],-1,wbuf,BUF_SIZE);
637- wcscpy(buf,wbuf);
638- buf += wcslen(wbuf) + 1;
645+ // UTF-8対応
646+// MultiByteToWideChar(CP_ACP,0,FileName[i],-1,wbuf,BUF_SIZE);
647+// wcscpy(buf,wbuf);
648+// buf += wcslen(wbuf) + 1;
649+ buf += MtoW(buf, BUF_SIZE, FileName[i], -1);
639650 }
640651 }else{
641652 /* マルチバイト */
@@ -643,8 +654,11 @@ static HDROP APIPRIVATE CreateDropFileMem(char **FileName,int cnt,BOOL fWide)
643654
644655 buf = (char *)(&lpDropFile[1]);
645656 for(i = 0;i < cnt;i++){
646- lstrcpy(buf,FileName[i]);
647- buf += lstrlen(FileName[i]) + 1;
657+ // UTF-8対応
658+// lstrcpy(buf,FileName[i]);
659+// buf += lstrlen(FileName[i]) + 1;
660+ MtoW(wbuf, BUF_SIZE, FileName[i], -1);
661+ buf += WtoA(buf, BUF_SIZE, wbuf, -1);
648662 }
649663 }
650664
@@ -829,6 +843,8 @@ static LRESULT FileListCommonWndProc(HWND hWnd, UINT message, WPARAM wParam, LPA
829843 char LocDir[FMAX_PATH+1];
830844 char *PathDir;
831845
846+ // 変数が未初期化のバグ修正
847+ FileListBaseNoExpand = NULL;
832848 // ローカル側で選ばれているファイルをFileListBaseに登録
833849 if (hWndDragStart == hWndListLocal) {
834850 AskLocalCurDir(LocDir, FMAX_PATH);
@@ -868,6 +884,7 @@ static LRESULT FileListCommonWndProc(HWND hWnd, UINT message, WPARAM wParam, LPA
868884 }
869885
870886 /* ファイル名の配列を作成する */
887+ // TODO: GlobalAllocが返すのはメモリポインタではなくハンドルだが実際は同じ値
871888 FileNameList = (char **)GlobalAlloc(GPTR,sizeof(char *) * filenum);
872889 if(FileNameList == NULL){
873890 abort();
@@ -4922,9 +4939,11 @@ static void GetMonth(char *Str, WORD *Month, WORD *Day)
49224939 {
49234940 if(!IsDigit(*Pos))
49244941 {
4925- if((_mbsncmp(Pos, "月", 1) == 0) ||
4926- (memcmp(Pos, "\xB7\xEE", 2) == 0) || /* EUCの「月」 */
4927- (memcmp(Pos, "\xD4\xC2", 2) == 0)) /* GBコードの「月」 */
4942+ // UTF-8対応
4943+// if((_mbsncmp(Pos, "月", 1) == 0) ||
4944+// (memcmp(Pos, "\xB7\xEE", 2) == 0) || /* EUCの「月」 */
4945+// (memcmp(Pos, "\xD4\xC2", 2) == 0)) /* GBコードの「月」 */
4946+ if(memcmp(Pos, "\xE6\x9C\x88", 3) == 0 || memcmp(Pos, "\x8C\x8E", 2) == 0 || memcmp(Pos, "\xB7\xEE", 2) == 0 || memcmp(Pos, "\xD4\xC2", 2) == 0)
49284947 {
49294948 Pos += 2;
49304949 *Month = atoi(Str);
@@ -5053,8 +5072,10 @@ static int GetHourAndMinute(char *Str, WORD *Hour, WORD *Minute)
50535072 {
50545073 if(IsDigit(*Pos) == 0)
50555074 {
5056- if((_mbsncmp(Pos, "時", 1) == 0) ||
5057- (memcmp(Pos, "\xBB\xFE", 2) == 0)) /* EUCの「時」 */
5075+ // UTF-8対応
5076+// if((_mbsncmp(Pos, "時", 1) == 0) ||
5077+// (memcmp(Pos, "\xBB\xFE", 2) == 0)) /* EUCの「時」 */
5078+ if(memcmp(Pos, "\xE6\x99\x82", 3) == 0 || memcmp(Pos, "\x8E\x9E", 2) == 0 || memcmp(Pos, "\xBB\xFE", 2) == 0)
50585079 {
50595080 Pos += 2;
50605081 if(*Pos != NUL)
--- a/ftpproc.c
+++ b/ftpproc.c
@@ -42,6 +42,10 @@
4242 #include <htmlhelp.h>
4343 #include "helpid.h"
4444
45+// UTF-8対応
46+#undef __MBSWRAPPER_H__
47+#include "mbswrapper.h"
48+
4549
4650 /*===== プロトタイプ =====*/
4751
--- a/hostman.c
+++ b/hostman.c
@@ -41,6 +41,10 @@
4141 #include <htmlhelp.h>
4242 #include "helpid.h"
4343
44+// UTF-8対応
45+#undef __MBSWRAPPER_H__
46+#include "mbswrapper.h"
47+
4448
4549 /*===== プロトタイプ =====*/
4650
--- a/main.c
+++ b/main.c
@@ -46,6 +46,10 @@
4646 #include <htmlhelp.h>
4747 #include "helpid.h"
4848
49+// UTF-8対応
50+#undef __MBSWRAPPER_H__
51+#include "mbswrapper.h"
52+
4953
5054 #define RESIZE_OFF 0 /* ウインドウの区切り位置変更していない */
5155 #define RESIZE_ON 1 /* ウインドウの区切り位置変更中 */
@@ -152,7 +156,9 @@ int RecvMode = TRANS_DLG;
152156 int SendMode = TRANS_DLG;
153157 int MoveMode = MOVE_DLG;
154158 int ListType = LVS_REPORT;
155-int CacheEntry = 10;
159+// LISTのキャッシュを無効にする(リモートのディレクトリの表示が更新されないバグ対策)
160+//int CacheEntry = 10;
161+int CacheEntry = -10;
156162 int CacheSave = NO;
157163 char DefaultLocalPath[FMAX_PATH+1] = { "" };
158164 int SaveTimeStamp = YES;
--- a/mbswrapper.c
+++ b/mbswrapper.c
@@ -5,11 +5,13 @@
55 // 全ての制御用の文字はASCIIの範囲であるため、Shift_JISとUTF-8間の変換は不要
66
77 #define UNICODE
8+#define _UNICODE
89 #define _WIN32_WINNT 0x0600
910 #undef _WIN32_IE
1011 #define _WIN32_IE 0x0400
1112
1213 #include <tchar.h>
14+#include <direct.h>
1315 #include <windows.h>
1416 #include <commctrl.h>
1517 #include <shlobj.h>
@@ -21,8 +23,8 @@
2123 // マルチバイト文字列からワイド文字列へ変換
2224 int MtoW(LPWSTR pDst, int size, LPCSTR pSrc, int count)
2325 {
24- if(pSrc < (LPCSTR)0x00010000 || !((char*)pSrc + 1))
25- return 0;
26+ if(pSrc < (LPCSTR)0x00010000 || pSrc == (LPCSTR)~0)
27+ return pSrc;
2628 if(pDst)
2729 return MultiByteToWideChar(CP_UTF8, 0, pSrc, count, pDst, size);
2830 return MultiByteToWideChar(CP_UTF8, 0, pSrc, count, NULL, 0);
@@ -31,8 +33,8 @@ int MtoW(LPWSTR pDst, int size, LPCSTR pSrc, int count)
3133 // ワイド文字列からマルチバイト文字列へ変換
3234 int WtoM(LPSTR pDst, int size, LPCWSTR pSrc, int count)
3335 {
34- if(pSrc < (LPCWSTR)0x00010000 || !((char*)pSrc + 1))
35- return 0;
36+ if(pSrc < (LPCWSTR)0x00010000 || pSrc == (LPCWSTR)~0)
37+ return pSrc;
3638 if(pDst)
3739 return WideCharToMultiByte(CP_UTF8, 0, pSrc, count, pDst, size, NULL, NULL);
3840 return WideCharToMultiByte(CP_UTF8, 0, pSrc, count, NULL, 0, NULL, NULL);
@@ -41,8 +43,8 @@ int WtoM(LPSTR pDst, int size, LPCWSTR pSrc, int count)
4143 // ワイド文字列からShift_JIS文字列へ変換
4244 int WtoA(LPSTR pDst, int size, LPCWSTR pSrc, int count)
4345 {
44- if(pSrc < (LPCWSTR)0x00010000 || !((char*)pSrc + 1))
45- return 0;
46+ if(pSrc < (LPCWSTR)0x00010000 || pSrc == (LPCWSTR)~0)
47+ return pSrc;
4648 if(pDst)
4749 return WideCharToMultiByte(CP_ACP, 0, pSrc, count, pDst, size, NULL, NULL);
4850 return WideCharToMultiByte(CP_ACP, 0, pSrc, count, NULL, 0, NULL, NULL);
@@ -52,7 +54,7 @@ int WtoA(LPSTR pDst, int size, LPCWSTR pSrc, int count)
5254 int TerminateStringM(LPSTR lpString, int size)
5355 {
5456 int i;
55- if(lpString < (LPSTR)0x00010000 || !((char*)lpString + 1))
57+ if(lpString < (LPSTR)0x00010000 || lpString == (LPSTR)~0)
5658 return 0;
5759 for(i = 0; i < size; i++)
5860 {
@@ -68,7 +70,7 @@ int TerminateStringM(LPSTR lpString, int size)
6870 int TerminateStringW(LPWSTR lpString, int size)
6971 {
7072 int i;
71- if(lpString < (LPWSTR)0x00010000 || !((char*)lpString + 1))
73+ if(lpString < (LPWSTR)0x00010000 || lpString == (LPWSTR)~0)
7274 return 0;
7375 for(i = 0; i < size; i++)
7476 {
@@ -84,7 +86,7 @@ int TerminateStringW(LPWSTR lpString, int size)
8486 size_t GetMultiStringLengthM(LPCSTR lpString)
8587 {
8688 size_t i;
87- if(lpString < (LPCSTR)0x00010000 || !((char*)lpString + 1))
89+ if(lpString < (LPCSTR)0x00010000 || lpString == (LPCSTR)~0)
8890 return 0;
8991 i = 0;
9092 while(lpString[i] != '\0' || lpString[i + 1] != '\0')
@@ -99,7 +101,7 @@ size_t GetMultiStringLengthM(LPCSTR lpString)
99101 size_t GetMultiStringLengthW(LPCWSTR lpString)
100102 {
101103 size_t i;
102- if(lpString < (LPCWSTR)0x00010000 || !((char*)lpString + 1))
104+ if(lpString < (LPCWSTR)0x00010000 || lpString == (LPCWSTR)~0)
103105 return 0;
104106 i = 0;
105107 while(lpString[i] != L'\0' || lpString[i + 1] != L'\0')
@@ -114,7 +116,9 @@ size_t GetMultiStringLengthW(LPCWSTR lpString)
114116 char* AllocateStringM(int size)
115117 {
116118 char* p;
117- p = (char*)malloc(sizeof(char) * size);
119+ // 0が指定される場合があるため1文字分追加
120+ p = (char*)malloc(sizeof(char) * (size + 1));
121+ // 念のため先頭にNULL文字を代入
118122 if(p)
119123 *p = '\0';
120124 return p;
@@ -124,7 +128,9 @@ char* AllocateStringM(int size)
124128 wchar_t* AllocateStringW(int size)
125129 {
126130 wchar_t* p;
127- p = (wchar_t*)malloc(sizeof(wchar_t) * size);
131+ // 0が指定される場合があるため1文字分追加
132+ p = (wchar_t*)malloc(sizeof(wchar_t) * (size + 1));
133+ // 念のため先頭にNULL文字を代入
128134 if(p)
129135 *p = L'\0';
130136 return p;
@@ -134,7 +140,9 @@ wchar_t* AllocateStringW(int size)
134140 char* AllocateStringA(int size)
135141 {
136142 char* p;
137- p = (char*)malloc(sizeof(char) * size);
143+ // 0が指定される場合があるため1文字分追加
144+ p = (char*)malloc(sizeof(char) * (size + 1));
145+ // 念のため先頭にNULL文字を代入
138146 if(p)
139147 *p = '\0';
140148 return p;
@@ -145,7 +153,7 @@ wchar_t* DuplicateMtoW(LPCSTR lpString, int c)
145153 {
146154 wchar_t* p;
147155 int i;
148- if(lpString < (LPCSTR)0x00010000 || !((char*)lpString + 1))
156+ if(lpString < (LPCSTR)0x00010000 || lpString == (LPCSTR)~0)
149157 return (wchar_t*)lpString;
150158 if(c < 0)
151159 c = strlen(lpString);
@@ -163,7 +171,7 @@ wchar_t* DuplicateMtoWBuffer(LPCSTR lpString, int c, int size)
163171 {
164172 wchar_t* p;
165173 int i;
166- if(lpString < (LPCSTR)0x00010000 || !((char*)lpString + 1))
174+ if(lpString < (LPCSTR)0x00010000 || lpString == (LPCSTR)~0)
167175 return (wchar_t*)lpString;
168176 if(c < 0)
169177 c = strlen(lpString);
@@ -181,7 +189,7 @@ wchar_t* DuplicateMtoWMultiString(LPCSTR lpString)
181189 {
182190 int count;
183191 wchar_t* p;
184- if(lpString < (LPCSTR)0x00010000 || !((char*)lpString + 1))
192+ if(lpString < (LPCSTR)0x00010000 || lpString == (LPCSTR)~0)
185193 return (wchar_t*)lpString;
186194 count = GetMultiStringLengthM(lpString) + 1;
187195 p = AllocateStringW(count);
@@ -195,7 +203,7 @@ wchar_t* DuplicateMtoWMultiStringBuffer(LPCSTR lpString, int size)
195203 {
196204 int count;
197205 wchar_t* p;
198- if(lpString < (LPCSTR)0x00010000 || !((char*)lpString + 1))
206+ if(lpString < (LPCSTR)0x00010000 || lpString == (LPCSTR)~0)
199207 return (wchar_t*)lpString;
200208 count = GetMultiStringLengthM(lpString) + 1;
201209 p = AllocateStringW(size);
@@ -213,7 +221,7 @@ char* DuplicateWtoM(LPCWSTR lpString, int c)
213221 {
214222 char* p;
215223 int i;
216- if(lpString < (LPCWSTR)0x00010000 || !((char*)lpString + 1))
224+ if(lpString < (LPCWSTR)0x00010000 || lpString == (LPCWSTR)~0)
217225 return (char*)lpString;
218226 if(c < 0)
219227 c = wcslen(lpString);
@@ -231,7 +239,7 @@ char* DuplicateWtoA(LPCWSTR lpString, int c)
231239 {
232240 char* p;
233241 int i;
234- if(lpString < (LPCWSTR)0x00010000 || !((char*)lpString + 1))
242+ if(lpString < (LPCWSTR)0x00010000 || lpString == (LPCWSTR)~0)
235243 return (char*)lpString;
236244 if(c < 0)
237245 c = wcslen(lpString);
@@ -247,7 +255,7 @@ char* DuplicateWtoA(LPCWSTR lpString, int c)
247255 // 文字列用に確保したメモリを開放
248256 void FreeDuplicatedString(void* p)
249257 {
250- if(p < (void*)0x00010000 || !((char*)p + 1))
258+ if(p < (void*)0x00010000 || p == (void*)~0)
251259 return;
252260 free(p);
253261 }
@@ -340,8 +348,26 @@ END_ROUTINE
340348
341349 DWORD GetLogicalDriveStringsM(DWORD nBufferLength, LPSTR lpBuffer)
342350 {
343- // TODO: 本来は変換が必要だが半角英数のみと思われるので省略
344- return GetLogicalDriveStringsA(nBufferLength, lpBuffer);
351+ DWORD r = 0;
352+ wchar_t* pw0 = NULL;
353+START_ROUTINE
354+ pw0 = AllocateStringW(nBufferLength * 4);
355+ GetLogicalDriveStringsW(nBufferLength * 4, pw0);
356+ WtoM(lpBuffer, nBufferLength, pw0, -1);
357+ r = TerminateStringM(lpBuffer, nBufferLength);
358+END_ROUTINE
359+ FreeDuplicatedString(pw0);
360+ return r;
361+}
362+
363+ATOM RegisterClassExM(CONST WNDCLASSEXA * v0)
364+{
365+ LRESULT r = 0;
366+START_ROUTINE
367+ // WNDPROCがShift_JIS用であるため
368+ r = RegisterClassExA(v0);
369+END_ROUTINE
370+ return r;
345371 }
346372
347373 HWND CreateWindowExM(DWORD dwExStyle, LPCSTR lpClassName, LPCSTR lpWindowName, DWORD dwStyle, int X, int Y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam)
@@ -359,6 +385,58 @@ END_ROUTINE
359385 return r;
360386 }
361387
388+LONG GetWindowLongM(HWND hWnd, int nIndex)
389+{
390+ LRESULT r = 0;
391+START_ROUTINE
392+ // WNDPROCがShift_JIS用であるため
393+ if(IsWindowUnicode(hWnd))
394+ r = GetWindowLongW(hWnd, nIndex);
395+ else
396+ r = GetWindowLongA(hWnd, nIndex);
397+END_ROUTINE
398+ return r;
399+}
400+
401+LONG SetWindowLongM(HWND hWnd, int nIndex, LONG dwNewLong)
402+{
403+ LRESULT r = 0;
404+START_ROUTINE
405+ // WNDPROCがShift_JIS用であるため
406+ if(IsWindowUnicode(hWnd))
407+ r = SetWindowLongW(hWnd, nIndex, dwNewLong);
408+ else
409+ r = SetWindowLongA(hWnd, nIndex, dwNewLong);
410+END_ROUTINE
411+ return r;
412+}
413+
414+LRESULT DefWindowProcM(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
415+{
416+ LRESULT r = 0;
417+START_ROUTINE
418+ // WNDPROCがShift_JIS用であるため
419+ if(IsWindowUnicode(hWnd))
420+ r = DefWindowProcW(hWnd, Msg, wParam, lParam);
421+ else
422+ r = DefWindowProcA(hWnd, Msg, wParam, lParam);
423+END_ROUTINE
424+ return r;
425+}
426+
427+LRESULT CallWindowProcM(WNDPROC lpPrevWndFunc, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
428+{
429+ LRESULT r = 0;
430+START_ROUTINE
431+ // WNDPROCがShift_JIS用であるため
432+ if(IsWindowUnicode(hWnd))
433+ r = CallWindowProcW(lpPrevWndFunc, hWnd, Msg, wParam, lParam);
434+ else
435+ r = CallWindowProcA(lpPrevWndFunc, hWnd, Msg, wParam, lParam);
436+END_ROUTINE
437+ return r;
438+}
439+
362440 LRESULT SendMessageM(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
363441 {
364442 LRESULT r = 0;
@@ -544,6 +622,28 @@ START_ROUTINE
544622 wLVFindInfo.vkDirection = pmLVFindInfo->vkDirection;
545623 r = SendMessageW(hWnd, LVM_FINDITEMW, wParam, (LPARAM)&wLVItem);
546624 break;
625+ case LVM_GETCOLUMNA:
626+ pmLVColumn = (LVCOLUMNA*)lParam;
627+ wLVColumn.mask = pmLVColumn->mask;
628+ wLVColumn.fmt = pmLVColumn->fmt;
629+ wLVColumn.cx = pmLVColumn->cx;
630+ Size = pmLVColumn->cchTextMax * 4;
631+ pw0 = AllocateStringW(Size);
632+ wLVColumn.pszText = pw0;
633+ wLVColumn.cchTextMax = Size;
634+ wLVColumn.iSubItem = pmLVColumn->iSubItem;
635+ wLVColumn.iImage = pmLVColumn->iImage;
636+ wLVColumn.iOrder = pmLVColumn->iOrder;
637+ r = SendMessageW(hWnd, LVM_GETCOLUMNW, wParam, (LPARAM)&wLVColumn);
638+ pmLVColumn->mask = wLVColumn.mask;
639+ pmLVColumn->fmt = wLVColumn.fmt;
640+ pmLVColumn->cx = wLVColumn.cx;
641+ WtoM(pmLVColumn->pszText, pmLVColumn->cchTextMax, wLVColumn.pszText, -1);
642+ TerminateStringM(pmLVColumn->pszText, pmLVColumn->cchTextMax);
643+ pmLVColumn->iSubItem = wLVColumn.iSubItem;
644+ pmLVColumn->iImage = wLVColumn.iImage;
645+ pmLVColumn->iOrder = wLVColumn.iOrder;
646+ break;
547647 case LVM_INSERTCOLUMNA:
548648 pmLVColumn = (LVCOLUMNA*)lParam;
549649 wLVColumn.mask = pmLVColumn->mask;
@@ -551,6 +651,7 @@ START_ROUTINE
551651 wLVColumn.cx = pmLVColumn->cx;
552652 pw0 = DuplicateMtoW(pmLVColumn->pszText, -1);
553653 wLVColumn.pszText = pw0;
654+ // TODO: cchTextMaxの確認
554655 wLVColumn.cchTextMax = pmLVColumn->cchTextMax;
555656 wLVColumn.iSubItem = pmLVColumn->iSubItem;
556657 wLVColumn.iImage = pmLVColumn->iImage;
@@ -611,6 +712,19 @@ END_ROUTINE
611712 return r;
612713 }
613714
715+LRESULT DefDlgProcM(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
716+{
717+ LRESULT r = 0;
718+START_ROUTINE
719+ // WNDPROCがShift_JIS用であるため
720+ if(IsWindowUnicode(hWnd))
721+ r = DefDlgProcW(hWnd, Msg, wParam, lParam);
722+ else
723+ r = DefDlgProcA(hWnd, Msg, wParam, lParam);
724+END_ROUTINE
725+ return r;
726+}
727+
614728 LRESULT SendDlgItemMessageM(HWND hDlg, int nIDDlgItem, UINT Msg, WPARAM wParam, LPARAM lParam)
615729 {
616730 LRESULT r = 0;
@@ -637,10 +751,15 @@ UINT DragQueryFileM(HDROP hDrop, UINT iFile, LPSTR lpszFile, UINT cch)
637751 UINT r = 0;
638752 wchar_t* pw0 = NULL;
639753 START_ROUTINE
640- pw0 = AllocateStringW(cch * 4);
641- DragQueryFileW(hDrop, iFile, pw0, cch * 4);
642- WtoM(lpszFile, cch, pw0, -1);
643- r = TerminateStringM(lpszFile, cch);
754+ if(iFile == (UINT)-1)
755+ r = DragQueryFileW(hDrop, iFile, lpszFile, cch);
756+ else
757+ {
758+ pw0 = AllocateStringW(cch * 4);
759+ DragQueryFileW(hDrop, iFile, pw0, cch * 4);
760+ WtoM(lpszFile, cch, pw0, -1);
761+ r = TerminateStringM(lpszFile, cch);
762+ }
644763 END_ROUTINE
645764 FreeDuplicatedString(pw0);
646765 return r;
@@ -684,6 +803,20 @@ END_ROUTINE
684803 return r;
685804 }
686805
806+DWORD GetTempPathM(DWORD nBufferLength, LPSTR lpBuffer)
807+{
808+ DWORD r = 0;
809+ wchar_t* pw0 = NULL;
810+START_ROUTINE
811+ pw0 = AllocateStringW(nBufferLength * 4);
812+ GetTempPathW(nBufferLength * 4, pw0);
813+ WtoM(lpBuffer, nBufferLength, pw0, -1);
814+ r = TerminateStringM(lpBuffer, nBufferLength);
815+END_ROUTINE
816+ FreeDuplicatedString(pw0);
817+ return r;
818+}
819+
687820 DWORD GetFileAttributesM(LPCSTR lpFileName)
688821 {
689822 DWORD r = FALSE;
@@ -1363,3 +1496,226 @@ END_ROUTINE
13631496 return r;
13641497 }
13651498
1499+HWND CreateDialogParamM(HINSTANCE hInstance, LPCSTR lpTemplateName, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam)
1500+{
1501+ HWND r = NULL;
1502+ wchar_t* pw0 = NULL;
1503+START_ROUTINE
1504+ pw0 = DuplicateMtoW(lpTemplateName, -1);
1505+ r = CreateDialogParamW(hInstance, pw0, hWndParent, lpDialogFunc, dwInitParam);
1506+END_ROUTINE
1507+ FreeDuplicatedString(pw0);
1508+ return r;
1509+}
1510+
1511+int mkdirM(const char * _Path)
1512+{
1513+ int r = 0;
1514+ wchar_t* pw0 = NULL;
1515+START_ROUTINE
1516+ pw0 = DuplicateMtoW(_Path, -1);
1517+ r = _wmkdir(pw0);
1518+END_ROUTINE
1519+ FreeDuplicatedString(pw0);
1520+ return r;
1521+}
1522+
1523+int _mkdirM(const char * _Path)
1524+{
1525+ int r = 0;
1526+ wchar_t* pw0 = NULL;
1527+START_ROUTINE
1528+ pw0 = DuplicateMtoW(_Path, -1);
1529+ r = _wmkdir(pw0);
1530+END_ROUTINE
1531+ FreeDuplicatedString(pw0);
1532+ return r;
1533+}
1534+
1535+int rmdirM(const char * _Path)
1536+{
1537+ int r = 0;
1538+ wchar_t* pw0 = NULL;
1539+START_ROUTINE
1540+ pw0 = DuplicateMtoW(_Path, -1);
1541+ r = _wrmdir(pw0);
1542+END_ROUTINE
1543+ FreeDuplicatedString(pw0);
1544+ return r;
1545+}
1546+
1547+int _rmdirM(const char * _Path)
1548+{
1549+ int r = 0;
1550+ wchar_t* pw0 = NULL;
1551+START_ROUTINE
1552+ pw0 = DuplicateMtoW(_Path, -1);
1553+ r = _wrmdir(pw0);
1554+END_ROUTINE
1555+ FreeDuplicatedString(pw0);
1556+ return r;
1557+}
1558+
1559+size_t _mbslenM(const unsigned char * _Str)
1560+{
1561+ size_t r = 0;
1562+ wchar_t* pw0 = NULL;
1563+ wchar_t* wr;
1564+START_ROUTINE
1565+ pw0 = DuplicateMtoW(_Str, -1);
1566+ r = wcslen(pw0);
1567+END_ROUTINE
1568+ FreeDuplicatedString(pw0);
1569+ return r;
1570+}
1571+
1572+unsigned char * _mbschrM(const unsigned char * _Str, unsigned int _Ch)
1573+{
1574+ unsigned char* r = NULL;
1575+ wchar_t* pw0 = NULL;
1576+ wchar_t* wr;
1577+START_ROUTINE
1578+ pw0 = DuplicateMtoW(_Str, -1);
1579+ // TODO: 非ASCII文字の対応
1580+ wr = wcschr(pw0, _Ch);
1581+ if(wr)
1582+ {
1583+ *wr = L'\0';
1584+ r = _Str + WtoM(NULL, 0, pw0, -1) - 1;
1585+ }
1586+END_ROUTINE
1587+ FreeDuplicatedString(pw0);
1588+ return r;
1589+}
1590+
1591+unsigned char * _mbsrchrM(const unsigned char * _Str, unsigned int _Ch)
1592+{
1593+ unsigned char* r = NULL;
1594+ wchar_t* pw0 = NULL;
1595+ wchar_t* wr;
1596+START_ROUTINE
1597+ pw0 = DuplicateMtoW(_Str, -1);
1598+ // TODO: 非ASCII文字の対応
1599+ wr = wcsrchr(pw0, _Ch);
1600+ if(wr)
1601+ {
1602+ *wr = L'\0';
1603+ r = _Str + WtoM(NULL, 0, pw0, -1) - 1;
1604+ }
1605+END_ROUTINE
1606+ FreeDuplicatedString(pw0);
1607+ return r;
1608+}
1609+
1610+unsigned char * _mbsstrM(const unsigned char * _Str, const unsigned char * _Substr)
1611+{
1612+ unsigned char* r = NULL;
1613+ wchar_t* pw0 = NULL;
1614+ wchar_t* pw1 = NULL;
1615+ wchar_t* wr;
1616+START_ROUTINE
1617+ pw0 = DuplicateMtoW(_Str, -1);
1618+ pw1 = DuplicateMtoW(_Substr, -1);
1619+ wr = wcsstr(pw0, pw1);
1620+ if(wr)
1621+ {
1622+ *wr = L'\0';
1623+ r = _Str + WtoM(NULL, 0, pw0, -1) - 1;
1624+ }
1625+END_ROUTINE
1626+ FreeDuplicatedString(pw0);
1627+ FreeDuplicatedString(pw1);
1628+ return r;
1629+}
1630+
1631+int _mbscmpM(const unsigned char * _Str1, const unsigned char * _Str2)
1632+{
1633+ int r = 0;
1634+ wchar_t* pw0 = NULL;
1635+ wchar_t* pw1 = NULL;
1636+START_ROUTINE
1637+ pw0 = DuplicateMtoW(_Str1, -1);
1638+ pw1 = DuplicateMtoW(_Str2, -1);
1639+ r = wcscmp(pw0, pw1);
1640+END_ROUTINE
1641+ FreeDuplicatedString(pw0);
1642+ FreeDuplicatedString(pw1);
1643+ return r;
1644+}
1645+
1646+int _mbsicmpM(const unsigned char * _Str1, const unsigned char * _Str2)
1647+{
1648+ int r = 0;
1649+ wchar_t* pw0 = NULL;
1650+ wchar_t* pw1 = NULL;
1651+START_ROUTINE
1652+ pw0 = DuplicateMtoW(_Str1, -1);
1653+ pw1 = DuplicateMtoW(_Str2, -1);
1654+ r = _wcsicmp(pw0, pw1);
1655+END_ROUTINE
1656+ FreeDuplicatedString(pw0);
1657+ FreeDuplicatedString(pw1);
1658+ return r;
1659+}
1660+
1661+int _mbsncmpM(const unsigned char * _Str1, const unsigned char * _Str2, size_t _MaxCount)
1662+{
1663+ int r = 0;
1664+ wchar_t* pw0 = NULL;
1665+ wchar_t* pw1 = NULL;
1666+START_ROUTINE
1667+ pw0 = DuplicateMtoW(_Str1, -1);
1668+ pw1 = DuplicateMtoW(_Str2, -1);
1669+ r = wcsncmp(pw0, pw1, _MaxCount);
1670+END_ROUTINE
1671+ FreeDuplicatedString(pw0);
1672+ FreeDuplicatedString(pw1);
1673+ return r;
1674+}
1675+
1676+unsigned char * _mbslwrM(unsigned char * _String)
1677+{
1678+ unsigned char* r = NULL;
1679+ wchar_t* pw0 = NULL;
1680+START_ROUTINE
1681+ pw0 = DuplicateMtoW(_String, -1);
1682+ _wcslwr(pw0);
1683+ r = _String;
1684+ WtoM(_String, strlen(_String) + 1, pw0, -1);
1685+END_ROUTINE
1686+ FreeDuplicatedString(pw0);
1687+ return r;
1688+}
1689+
1690+unsigned char * _mbsuprM(unsigned char * _String)
1691+{
1692+ unsigned char* r = NULL;
1693+ wchar_t* pw0 = NULL;
1694+START_ROUTINE
1695+ pw0 = DuplicateMtoW(_String, -1);
1696+ _wcsupr(pw0);
1697+ r = _String;
1698+ WtoM(_String, strlen(_String) + 1, pw0, -1);
1699+END_ROUTINE
1700+ FreeDuplicatedString(pw0);
1701+ return r;
1702+}
1703+
1704+unsigned char * _mbsnincM(const unsigned char * _Str, size_t _Count)
1705+{
1706+ unsigned char* r = NULL;
1707+ wchar_t* pw0 = NULL;
1708+ wchar_t* wr;
1709+START_ROUTINE
1710+ pw0 = DuplicateMtoW(_Str, -1);
1711+ wr = _wcsninc(pw0, _Count);
1712+ if(wr)
1713+ {
1714+ *wr = L'\0';
1715+ r = _Str + WtoM(NULL, 0, pw0, -1) - 1;
1716+ }
1717+END_ROUTINE
1718+ FreeDuplicatedString(pw0);
1719+ return r;
1720+}
1721+
--- a/mbswrapper.h
+++ b/mbswrapper.h
@@ -17,8 +17,18 @@
1717 #define FindNextFile FindNextFileM
1818 #undef GetLogicalDriveStrings
1919 #define GetLogicalDriveStrings GetLogicalDriveStringsM
20+#undef RegisterClassEx
21+#define RegisterClassEx RegisterClassExM
2022 #undef CreateWindowEx
2123 #define CreateWindowEx CreateWindowExM
24+#undef GetWindowLong
25+#define GetWindowLong GetWindowLongM
26+#undef SetWindowLong
27+#define SetWindowLong SetWindowLongM
28+#undef DefWindowProc
29+#define DefWindowProc DefWindowProcM
30+#undef CallWindowProc
31+#define CallWindowProc CallWindowProcM
2232 #undef SendMessage
2333 #define SendMessage SendMessageM
2434 #undef SendDlgItemMessage
@@ -33,6 +43,8 @@
3343 #define SetCurrentDirectory SetCurrentDirectoryM
3444 #undef SetDllDirectory
3545 #define SetDllDirectory SetDllDirectoryM
46+#undef GetTempPath
47+#define GetTempPath GetTempPathM
3648 #undef GetFileAttributes
3749 #define GetFileAttributes GetFileAttributesM
3850 #undef GetModuleFileName
@@ -81,9 +93,41 @@
8193 #define ChooseFont ChooseFontM
8294 #undef DialogBoxParam
8395 #define DialogBoxParam DialogBoxParamM
96+#undef CreateDialogParam
97+#define CreateDialogParam CreateDialogParamM
98+#undef mkdir
99+#define mkdir _mkdirM
100+#undef _mkdir
101+#define _mkdir _mkdirM
102+#undef rmdir
103+#define rmdir rmdirM
104+#undef _rmdir
105+#define _rmdir _rmdirM
106+#undef _mbslen
107+#define _mbslen _mbslenM
108+#undef _mbschr
109+#define _mbschr _mbschrM
110+#undef _mbsrchr
111+#define _mbsrchr _mbsrchrM
112+#undef _mbsstr
113+#define _mbsstr _mbsstrM
114+#undef _mbscmp
115+#define _mbscmp _mbscmpM
116+#undef _mbsicmp
117+#define _mbsicmp _mbsicmpM
118+#undef _mbsncmp
119+#define _mbsncmp _mbsncmpM
120+#undef _mbslwr
121+#define _mbslwr _mbslwrM
122+#undef _mbsupr
123+#define _mbsupr _mbsuprM
124+#undef _mbsninc
125+#define _mbsninc _mbsnincM
84126
85127 #undef CreateWindow
86128 #define CreateWindow(lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam) CreateWindowEx(0L, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)
129+#undef DialogBox
130+#define DialogBox(hInstance, lpTemplate, hWndParent, lpDialogFunc) DialogBoxParam(hInstance, lpTemplate, hWndParent, lpDialogFunc, 0L)
87131
88132 #endif
89133
--- a/misc.c
+++ b/misc.c
@@ -45,6 +45,10 @@
4545 #include <htmlhelp.h>
4646 #include "helpid.h"
4747
48+// UTF-8対応
49+#undef __MBSWRAPPER_H__
50+#include "mbswrapper.h"
51+
4852
4953
5054 /*===== 入力ダイアログデータのストラクチャ =====*/
--- a/option.c
+++ b/option.c
@@ -41,6 +41,10 @@
4141 #include <htmlhelp.h>
4242 #include "helpid.h"
4343
44+// UTF-8対応
45+#undef __MBSWRAPPER_H__
46+#include "mbswrapper.h"
47+
4448
4549 /*===== プロトタイプ =====*/
4650
--- a/regexp.c
+++ b/regexp.c
@@ -64,6 +64,11 @@ int LoadJre(void)
6464 {
6565 int Sts;
6666
67+ // UTF-8対応
68+ // JRE32.DLLはUTF-8に非対応
69+#ifdef DISABLE_JRE32DLL
70+ return FALSE;
71+#endif
6772 Sts = FALSE;
6873 if((m_hDll = LoadLibrary("jre32.dll")) != NULL)
6974 {
--- a/socket.c
+++ b/socket.c
@@ -74,6 +74,7 @@ typedef struct {
7474
7575
7676 // スレッド衝突のバグ修正
77+// 念のためテーブルを増量
7778 //#define MAX_SIGNAL_ENTRY 10
7879 //#define MAX_SIGNAL_ENTRY_DBASE 5
7980 #define MAX_SIGNAL_ENTRY 100
--- a/tool.c
+++ b/tool.c
@@ -41,6 +41,10 @@
4141 #include <htmlhelp.h>
4242 #include "helpid.h"
4343
44+// UTF-8対応
45+#undef __MBSWRAPPER_H__
46+#include "mbswrapper.h"
47+
4448
4549 /*===== プロトタイプ =====*/
4650