Merge pull request #987 from Bigpet/minifixes

Fix some small mistakes
This commit is contained in:
B1ackDaemon 2015-02-02 13:10:53 +02:00
commit 4c52b65374
4 changed files with 16 additions and 8 deletions

View File

@ -157,7 +157,7 @@ std::string fmt::detail::format(const char* fmt, size_t len)
extern const std::string fmt::placeholder = "???"; extern const std::string fmt::placeholder = "???";
std::string replace_first(const std::string& src, const std::string& from, const std::string& to) std::string fmt::replace_first(const std::string& src, const std::string& from, const std::string& to)
{ {
auto pos = src.find(from); auto pos = src.find(from);
@ -169,11 +169,12 @@ std::string replace_first(const std::string& src, const std::string& from, const
return (pos ? src.substr(0, pos) + to : to) + std::string(src.c_str() + pos + from.length()); return (pos ? src.substr(0, pos) + to : to) + std::string(src.c_str() + pos + from.length());
} }
std::string replace_all(std::string src, const std::string& from, const std::string& to) std::string fmt::replace_all(const std::string &src, const std::string& from, const std::string& to)
{ {
for (auto pos = src.find(from); pos != std::string::npos; src.find(from, pos + 1)) std::string target = src;
for (auto pos = target.find(from); pos != std::string::npos; pos = target.find(from, pos + 1))
{ {
src = (pos ? src.substr(0, pos) + to : to) + std::string(src.c_str() + pos + from.length()); target = (pos ? target.substr(0, pos) + to : to) + std::string(target.c_str() + pos + from.length());
pos += to.length(); pos += to.length();
} }

View File

@ -123,7 +123,7 @@ namespace fmt
} }
std::string replace_first(const std::string& src, const std::string& from, const std::string& to); std::string replace_first(const std::string& src, const std::string& from, const std::string& to);
std::string replace_all(std::string src, const std::string& from, const std::string& to); std::string replace_all(const std::string &src, const std::string& from, const std::string& to);
template<size_t list_size> template<size_t list_size>
std::string replace_all(std::string src, const std::pair<std::string, std::string>(&list)[list_size]) std::string replace_all(std::string src, const std::pair<std::string, std::string>(&list)[list_size])

View File

@ -1004,6 +1004,7 @@ s32 cellGcmUnmapIoAddress(u64 io)
{ {
u64 ea; u64 ea;
io = io >> 20; io = io >> 20;
size = size >> 20;
ea = offsetTable.eaAddress[io]; ea = offsetTable.eaAddress[io];
for (u32 i = 0; i<size; i++) for (u32 i = 0; i<size; i++)

View File

@ -235,11 +235,17 @@ s32 cellFsStat(vm::ptr<const char> path, vm::ptr<CellFsStat> sb)
Emu.GetVFS().GetDevice(_path, real_path); Emu.GetVFS().GetDevice(_path, real_path);
int stat_result;
#ifdef _WIN32
struct _stat64 buf;
stat_result = _stat64(real_path.c_str(), &buf);
#elif
struct stat buf; struct stat buf;
stat_result = stat(real_path.c_str(), &buf);
if (int result = stat(real_path.c_str(), &buf)) #endif
if (stat_result)
{ {
sys_fs->Error("cellFsStat(): stat('%s') failed -> 0x%x", real_path.c_str(), result); sys_fs->Error("cellFsStat(): stat('%s') failed -> 0x%x", real_path.c_str(), stat_result);
} }
else else
{ {