summaryrefslogtreecommitdiff
path: root/src/ini.cpp
diff options
context:
space:
mode:
authorNiels Martin Hansen <nielsm@indvikleren.dk>2021-02-21 20:48:21 +0100
committerNiels Martin Hansen <nielsm@indvikleren.dk>2021-02-23 11:25:39 +0100
commitb427ddce887617f17aefdbe1f22ca1e00d013c3d (patch)
tree06fd938bd05dd716ba2d573978789f2c8e068505 /src/ini.cpp
parentbeeb9e0a1b1c6ceb61499edeb8cd6cf7999d12ea (diff)
downloadopenttd-b427ddce887617f17aefdbe1f22ca1e00d013c3d.tar.xz
Codechange: Switch to explicit wide strings
Diffstat (limited to 'src/ini.cpp')
-rw-r--r--src/ini.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/ini.cpp b/src/ini.cpp
index e70cc268a..4988c778e 100644
--- a/src/ini.cpp
+++ b/src/ini.cpp
@@ -92,17 +92,15 @@ bool IniFile::SaveToDisk(const std::string &filename)
#endif
#if defined(_WIN32)
- /* _tcsncpy = strcpy is TCHAR is char, but isn't when TCHAR is wchar. */
-# undef strncpy
/* Allocate space for one more \0 character. */
- TCHAR tfilename[MAX_PATH + 1], tfile_new[MAX_PATH + 1];
- _tcsncpy(tfilename, OTTD2FS(filename.c_str()), MAX_PATH);
- _tcsncpy(tfile_new, OTTD2FS(file_new.c_str()), MAX_PATH);
+ wchar_t tfilename[MAX_PATH + 1], tfile_new[MAX_PATH + 1];
+ wcsncpy(tfilename, OTTD2FS(filename.c_str()), MAX_PATH);
+ wcsncpy(tfile_new, OTTD2FS(file_new.c_str()), MAX_PATH);
/* SHFileOperation wants a double '\0' terminated string. */
tfilename[MAX_PATH - 1] = '\0';
tfile_new[MAX_PATH - 1] = '\0';
- tfilename[_tcslen(tfilename) + 1] = '\0';
- tfile_new[_tcslen(tfile_new) + 1] = '\0';
+ tfilename[wcslen(tfilename) + 1] = '\0';
+ tfile_new[wcslen(tfile_new) + 1] = '\0';
/* Rename file without any user confirmation. */
SHFILEOPSTRUCT shfopt;