diff options
author | Chris Robinson <chris.kcat@gmail.com> | 2015-02-07 04:19:50 -0800 |
---|---|---|
committer | Chris Robinson <chris.kcat@gmail.com> | 2015-02-07 04:19:50 -0800 |
commit | 50cdc0ac1e3e69142989c9aa2f27cbeb44ec6c3d (patch) | |
tree | 8a166a5724be1f77818189c37abe6f4597e548ce /Alc/alcConfig.c | |
parent | 61743a3a0017c567ee62ab50c3da28a5ed2fed8d (diff) |
Avoid tracing wide-char strings
Because on Windows, traced strings are written to a char string, which causes
UTF-16 strings to be converted to a narrow (non-UTF-8) encoding, potentially
losing characters.
Diffstat (limited to 'Alc/alcConfig.c')
-rw-r--r-- | Alc/alcConfig.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/Alc/alcConfig.c b/Alc/alcConfig.c index c8928c3c..acfc97b8 100644 --- a/Alc/alcConfig.c +++ b/Alc/alcConfig.c @@ -305,27 +305,33 @@ void ReadALConfig(void) if(SHGetSpecialFolderPathW(NULL, buffer, CSIDL_APPDATA, FALSE) != FALSE) { - size_t p = lstrlenW(buffer); - _snwprintf(buffer+p, PATH_MAX-p, L"\\alsoft.ini"); + al_string filepath = AL_STRING_INIT_STATIC(); + al_string_copy_wcstr(&filepath, buffer); + al_string_append_cstr(&filepath, "\\alsoft.ini"); - TRACE("Loading config %ls...\n", buffer); - f = _wfopen(buffer, L"rt"); + TRACE("Loading config %s...\n", al_string_get_cstr(filepath)); + f = al_fopen(al_string_get_cstr(filepath), "rt"); if(f) { LoadConfigFromFile(f); fclose(f); } + al_string_deinit(&filepath); } if((str=_wgetenv(L"ALSOFT_CONF")) != NULL && *str) { - TRACE("Loading config %ls...\n", str); - f = _wfopen(str, L"rt"); + al_string filepath = AL_STRING_INIT_STATIC(); + al_string_copy_wcstr(&filepath, str); + + TRACE("Loading config %s...\n", al_string_get_cstr(filepath)); + f = al_fopen(al_string_get_cstr(filepath), "rt"); if(f) { LoadConfigFromFile(f); fclose(f); } + al_string_deinit(&filepath); } } #else |