リビジョン | 105a8fb79a0b0c22e6d0733b2682a92470c26788 (tree) |
---|---|
日時 | 2018-11-24 01:30:02 |
作者 | Starg <starg@user...> |
コミッター | Starg |
Fix ini key encodings
@@ -218,19 +218,19 @@ IniGetKeyInt32Array(char *section, char *key, int32 *n, int arraysize) | ||
218 | 218 | int ret = 0; |
219 | 219 | TCHAR *tIniFile = char_to_tchar(IniFile); |
220 | 220 | TCHAR *tSection = char_to_tchar(section); |
221 | - TCHAR *tKey = char_to_tchar(key); | |
222 | 221 | TCHAR buffer[INI_MAXLEN]; |
223 | - TCHAR keybuffer[INI_MAXLEN]; | |
222 | + char keybuffer[INI_MAXLEN]; | |
224 | 223 | for(i=0;i<arraysize;i++){ |
225 | - _stprintf(keybuffer,_T("%ls%d"),tKey,i); | |
224 | + sprintf(keybuffer,"%s%d",key,i); | |
225 | + TCHAR *tkey = char_to_tchar(keybuffer); | |
226 | 226 | GetPrivateProfileString |
227 | - (tSection,keybuffer,INI_INVALID,buffer,INI_MAXLEN-1,tIniFile); | |
227 | + (tSection,tkey,INI_INVALID,buffer,INI_MAXLEN-1,tIniFile); | |
228 | + safe_free(tkey); | |
228 | 229 | if(_tcsicmp(buffer,INI_INVALID)) |
229 | 230 | n[i] =_ttol(buffer); |
230 | 231 | else |
231 | 232 | ret++; |
232 | 233 | } |
233 | - safe_free(tKey); | |
234 | 234 | safe_free(tSection); |
235 | 235 | safe_free(tIniFile); |
236 | 236 | return ret; |
@@ -243,23 +243,19 @@ IniGetKeyIntArray(char *section, char *key, int *n, int arraysize) | ||
243 | 243 | int ret = 0; |
244 | 244 | TCHAR *tIniFile = char_to_tchar(IniFile); |
245 | 245 | TCHAR *tSection = char_to_tchar(section); |
246 | - TCHAR *tKey = char_to_tchar(key); | |
247 | 246 | TCHAR buffer[INI_MAXLEN]; |
248 | - TCHAR keybuffer[INI_MAXLEN]; | |
247 | + char keybuffer[INI_MAXLEN]; | |
249 | 248 | for(i=0;i<arraysize;i++){ |
250 | -#ifdef UNICODE | |
251 | - swprintf(keybuffer,L"%ls%d",tKey,i); | |
252 | -#else | |
253 | - sprintf(keybuffer,"%s%d",tKey,i); | |
254 | -#endif | |
249 | + sprintf(keybuffer,"%s%d",key,i); | |
250 | + TCHAR *tkey = char_to_tchar(keybuffer); | |
255 | 251 | GetPrivateProfileString |
256 | - (tSection,keybuffer,INI_INVALID,buffer,INI_MAXLEN-1,tIniFile); | |
252 | + (tSection,tkey,INI_INVALID,buffer,INI_MAXLEN-1,tIniFile); | |
253 | + safe_free(tkey); | |
257 | 254 | if(_tcsicmp(buffer,INI_INVALID)) |
258 | 255 | n[i] =_ttol(buffer); |
259 | 256 | else |
260 | 257 | ret++; |
261 | 258 | } |
262 | - safe_free(tKey); | |
263 | 259 | safe_free(tSection); |
264 | 260 | safe_free(tIniFile); |
265 | 261 | return ret; |
@@ -410,19 +406,15 @@ IniPutKeyInt32Array(char *section, char *key, int32 *n, int arraysize) | ||
410 | 406 | int i; |
411 | 407 | TCHAR *tIniFile = char_to_tchar(IniFile); |
412 | 408 | TCHAR *tSection = char_to_tchar(section); |
413 | - TCHAR *tKey = char_to_tchar(key); | |
414 | 409 | TCHAR buffer[INI_MAXLEN]; |
415 | - TCHAR keybuffer[INI_MAXLEN]; | |
410 | + char keybuffer[INI_MAXLEN]; | |
416 | 411 | for(i=0;i<arraysize;i++){ |
417 | 412 | _stprintf(buffer, _T("%ld"), n[i]); |
418 | -#ifdef UNICODE | |
419 | - _swprintf(keybuffer,L"%ls%d",key,i); | |
420 | -#else | |
421 | 413 | sprintf(keybuffer,"%s%d",key,i); |
422 | -#endif | |
423 | - WritePrivateProfileString(tSection,keybuffer,buffer,tIniFile); | |
414 | + TCHAR *tkey = char_to_tchar(keybuffer); | |
415 | + WritePrivateProfileString(tSection,tkey,buffer,tIniFile); | |
416 | + safe_free(tkey); | |
424 | 417 | } |
425 | - safe_free(tKey); | |
426 | 418 | safe_free(tSection); |
427 | 419 | safe_free(tIniFile); |
428 | 420 | return 0; |
@@ -434,19 +426,15 @@ IniPutKeyIntArray(char *section, char *key, int *n, int arraysize) | ||
434 | 426 | int i; |
435 | 427 | TCHAR *tIniFile = char_to_tchar(IniFile); |
436 | 428 | TCHAR *tSection = char_to_tchar(section); |
437 | - TCHAR *tKey = char_to_tchar(key); | |
438 | 429 | TCHAR buffer[INI_MAXLEN]; |
439 | - TCHAR keybuffer[INI_MAXLEN]; | |
430 | + char keybuffer[INI_MAXLEN]; | |
440 | 431 | for(i=0;i<arraysize;i++){ |
441 | 432 | _stprintf(buffer,_T("%ld"),n[i]); |
442 | -#ifdef UNICODE | |
443 | - _swprintf(keybuffer,L"%ls%d",key,i); | |
444 | -#else | |
445 | 433 | sprintf(keybuffer,"%s%d",key,i); |
446 | -#endif | |
447 | - WritePrivateProfileString(tSection,keybuffer,buffer,tIniFile); | |
434 | + TCHAR *tkey = char_to_tchar(keybuffer); | |
435 | + WritePrivateProfileString(tSection,tkey,buffer,tIniFile); | |
436 | + safe_free(tkey); | |
448 | 437 | } |
449 | - safe_free(tKey); | |
450 | 438 | safe_free(tSection); |
451 | 439 | safe_free(tIniFile); |
452 | 440 | return 0; |