OSDN Git Service

Fix bugs of importing INI file created by 1.97b or earlier.
authors_kawamoto <s_kawamoto@users.sourceforge.jp>
Sun, 16 Oct 2011 14:12:58 +0000 (23:12 +0900)
committers_kawamoto <s_kawamoto@users.sourceforge.jp>
Sun, 16 Oct 2011 14:12:58 +0000 (23:12 +0900)
FFFTP_Eng_Release/FFFTP.exe
Release/FFFTP.exe
registory.c

index c50c54c..39305ae 100644 (file)
Binary files a/FFFTP_Eng_Release/FFFTP.exe and b/FFFTP_Eng_Release/FFFTP.exe differ
index 16fab4b..85996d1 100644 (file)
Binary files a/Release/FFFTP.exe and b/Release/FFFTP.exe differ
index 2326c05..2d5b07e 100644 (file)
@@ -99,6 +99,9 @@ static int IsMasterPasswordError = PASSWORD_OK;
 static int IsRndSourceInit = 0;\r
 static ulong RndSource[9];\r
 \r
+// UTF-8対応\r
+static int IniKanjiCode = KANJI_NOCNV;\r
+\r
 /*===== 外部参照 =====*/\r
 \r
 /* 設定値 */\r
@@ -638,6 +641,9 @@ int LoadRegistory(void)
                Sts = YES;\r
 \r
                ReadIntValueFromReg(hKey3, "Version", &Version);\r
+               // UTF-8対応\r
+               if(Version < 1980)\r
+                       IniKanjiCode = KANJI_SJIS;\r
 \r
                if(OpenSubKey(hKey3, "Options", &hKey4) == FFFTP_SUCCESS)\r
                {\r
@@ -2260,6 +2266,10 @@ static int ReadStringFromReg(void *Handle, char *Name, char *Str, DWORD Size)
 {\r
        int Sts;\r
        char *Pos;\r
+       // UTF-8対応\r
+       char* pa0;\r
+       wchar_t* pw0;\r
+       DWORD TempSize;\r
 \r
        Sts = FFFTP_FAIL;\r
        if(TmpRegType == REGTYPE_REG)\r
@@ -2275,10 +2285,37 @@ static int ReadStringFromReg(void *Handle, char *Name, char *Str, DWORD Size)
        {\r
                if((Pos = ScanValue(Handle, Name)) != NULL)\r
                {\r
-                       Size = min1(Size-1, strlen(Pos));\r
-                       Size = StrReadIn(Pos, Size, Str);\r
-                       *(Str + Size) = NUL;\r
-                       Sts = FFFTP_SUCCESS;\r
+                       // UTF-8対応\r
+//                     Size = min1(Size-1, strlen(Pos));\r
+//                     Size = StrReadIn(Pos, Size, Str);\r
+//                     *(Str + Size) = NUL;\r
+//                     Sts = FFFTP_SUCCESS;\r
+                       switch(IniKanjiCode)\r
+                       {\r
+                       case KANJI_SJIS:\r
+                               if(pa0 = AllocateStringA(Size * 4))\r
+                               {\r
+                                       if(pw0 = AllocateStringW(Size * 4 * 4))\r
+                                       {\r
+                                               TempSize = min1((Size * 4) - 1, strlen(Pos));\r
+                                               TempSize = StrReadIn(Pos, TempSize, pa0);\r
+                                               *(pa0 + TempSize) = NUL;\r
+                                               AtoW(pw0, Size * 4 * 4, pa0, -1);\r
+                                               WtoM(Str, Size, pw0, -1);\r
+                                               TerminateStringM(Str, Size);\r
+                                               Sts = FFFTP_SUCCESS;\r
+                                               FreeDuplicatedString(pw0);\r
+                                       }\r
+                                       FreeDuplicatedString(pa0);\r
+                               }\r
+                               break;\r
+                       case KANJI_NOCNV:\r
+                               Size = min1(Size-1, strlen(Pos));\r
+                               Size = StrReadIn(Pos, Size, Str);\r
+                               *(Str + Size) = NUL;\r
+                               Sts = FFFTP_SUCCESS;\r
+                               break;\r
+                       }\r
                }\r
        }\r
        return(Sts);\r