FFFTPのソースコードです。
Revision | 4bf2da0a7dd6992182cb0cc9afc800405eec34cc (tree) |
---|---|
Time | 2011-10-16 23:12:58 |
Author | s_kawamoto <s_kawamoto@user...> |
Commiter | s_kawamoto |
Fix bugs of importing INI file created by 1.97b or earlier.
@@ -99,6 +99,9 @@ static int IsMasterPasswordError = PASSWORD_OK; | ||
99 | 99 | static int IsRndSourceInit = 0; |
100 | 100 | static ulong RndSource[9]; |
101 | 101 | |
102 | +// UTF-8対応 | |
103 | +static int IniKanjiCode = KANJI_NOCNV; | |
104 | + | |
102 | 105 | /*===== 外部参照 =====*/ |
103 | 106 | |
104 | 107 | /* 設定値 */ |
@@ -638,6 +641,9 @@ int LoadRegistory(void) | ||
638 | 641 | Sts = YES; |
639 | 642 | |
640 | 643 | ReadIntValueFromReg(hKey3, "Version", &Version); |
644 | + // UTF-8対応 | |
645 | + if(Version < 1980) | |
646 | + IniKanjiCode = KANJI_SJIS; | |
641 | 647 | |
642 | 648 | if(OpenSubKey(hKey3, "Options", &hKey4) == FFFTP_SUCCESS) |
643 | 649 | { |
@@ -2260,6 +2266,10 @@ static int ReadStringFromReg(void *Handle, char *Name, char *Str, DWORD Size) | ||
2260 | 2266 | { |
2261 | 2267 | int Sts; |
2262 | 2268 | char *Pos; |
2269 | + // UTF-8対応 | |
2270 | + char* pa0; | |
2271 | + wchar_t* pw0; | |
2272 | + DWORD TempSize; | |
2263 | 2273 | |
2264 | 2274 | Sts = FFFTP_FAIL; |
2265 | 2275 | if(TmpRegType == REGTYPE_REG) |
@@ -2275,10 +2285,37 @@ static int ReadStringFromReg(void *Handle, char *Name, char *Str, DWORD Size) | ||
2275 | 2285 | { |
2276 | 2286 | if((Pos = ScanValue(Handle, Name)) != NULL) |
2277 | 2287 | { |
2278 | - Size = min1(Size-1, strlen(Pos)); | |
2279 | - Size = StrReadIn(Pos, Size, Str); | |
2280 | - *(Str + Size) = NUL; | |
2281 | - Sts = FFFTP_SUCCESS; | |
2288 | + // UTF-8対応 | |
2289 | +// Size = min1(Size-1, strlen(Pos)); | |
2290 | +// Size = StrReadIn(Pos, Size, Str); | |
2291 | +// *(Str + Size) = NUL; | |
2292 | +// Sts = FFFTP_SUCCESS; | |
2293 | + switch(IniKanjiCode) | |
2294 | + { | |
2295 | + case KANJI_SJIS: | |
2296 | + if(pa0 = AllocateStringA(Size * 4)) | |
2297 | + { | |
2298 | + if(pw0 = AllocateStringW(Size * 4 * 4)) | |
2299 | + { | |
2300 | + TempSize = min1((Size * 4) - 1, strlen(Pos)); | |
2301 | + TempSize = StrReadIn(Pos, TempSize, pa0); | |
2302 | + *(pa0 + TempSize) = NUL; | |
2303 | + AtoW(pw0, Size * 4 * 4, pa0, -1); | |
2304 | + WtoM(Str, Size, pw0, -1); | |
2305 | + TerminateStringM(Str, Size); | |
2306 | + Sts = FFFTP_SUCCESS; | |
2307 | + FreeDuplicatedString(pw0); | |
2308 | + } | |
2309 | + FreeDuplicatedString(pa0); | |
2310 | + } | |
2311 | + break; | |
2312 | + case KANJI_NOCNV: | |
2313 | + Size = min1(Size-1, strlen(Pos)); | |
2314 | + Size = StrReadIn(Pos, Size, Str); | |
2315 | + *(Str + Size) = NUL; | |
2316 | + Sts = FFFTP_SUCCESS; | |
2317 | + break; | |
2318 | + } | |
2282 | 2319 | } |
2283 | 2320 | } |
2284 | 2321 | return(Sts); |