summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Nathan Woods <npwoods@mess.org>2016-07-25 07:57:54 -0400
committer Nathan Woods <npwoods@mess.org>2016-07-25 07:57:54 -0400
commit23175a30913f4bf8b1957bf7cb9dcb93c09bb0fd (patch)
tree8b1182705affb03438cbe8abbb00d6eb3c4b036a
parent4a9e9742fde15b835709137b81cae1223d1f69d7 (diff)
Using decltype() and removing +1/-1 "dance"
-rw-r--r--src/osd/modules/file/winfile.cpp5
-rw-r--r--src/osd/strconv.cpp6
2 files changed, 4 insertions, 7 deletions
diff --git a/src/osd/modules/file/winfile.cpp b/src/osd/modules/file/winfile.cpp
index 1f85fc15645..62f5681e697 100644
--- a/src/osd/modules/file/winfile.cpp
+++ b/src/osd/modules/file/winfile.cpp
@@ -207,11 +207,8 @@ osd_file::error osd_file::open(std::string const &orig_path, UINT32 openflags, p
// create the path if necessary
if ((ERROR_PATH_NOT_FOUND == err) && (openflags & OPEN_FLAG_CREATE) && (openflags & OPEN_FLAG_CREATE_PATHS))
{
- // the code below assumes these are the same
- assert(std::string::npos == std::wstring::npos);
-
auto pathsep = t_path.rfind('\\');
- if (pathsep != std::string::npos)
+ if (pathsep != decltype(t_path)::npos)
{
// create the path up to the file
t_path[pathsep] = 0;
diff --git a/src/osd/strconv.cpp b/src/osd/strconv.cpp
index 3919dddbf18..49a70f52684 100644
--- a/src/osd/strconv.cpp
+++ b/src/osd/strconv.cpp
@@ -25,9 +25,9 @@ std::string &astring_from_utf8(std::string &dst, const char *s)
std::basic_string<WCHAR> wstring = wstring_from_utf8(s);
// convert UTF-16 to "ANSI code page" string
- int char_count = WideCharToMultiByte(CP_ACP, 0, wstring.c_str(), wstring.size() + 1, nullptr, 0, nullptr, nullptr);
- dst.resize(char_count - 1);
- WideCharToMultiByte(CP_ACP, 0, wstring.c_str(), wstring.size() + 1, &dst[0], char_count - 1, nullptr, nullptr);
+ int char_count = WideCharToMultiByte(CP_ACP, 0, wstring.c_str(), wstring.size(), nullptr, 0, nullptr, nullptr);
+ dst.resize(char_count);
+ WideCharToMultiByte(CP_ACP, 0, wstring.c_str(), wstring.size(), &dst[0], char_count, nullptr, nullptr);
return dst;
}