summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-03-21 02:16:22 +0200
committerPerttu Ahola <celeron55@gmail.com>2012-03-21 02:16:22 +0200
commit2f2ef80ec274daa0f7a814b28429f48447cd88b0 (patch)
tree17c96e975927dcef33d9d955ecc3077bb2ad6144
parentc0530921ffac89c2249500ba0a1bddd9d288cfbe (diff)
downloadminetest-2f2ef80ec274daa0f7a814b28429f48447cd88b0.tar.gz
minetest-2f2ef80ec274daa0f7a814b28429f48447cd88b0.tar.bz2
minetest-2f2ef80ec274daa0f7a814b28429f48447cd88b0.zip
Use atof() in mystof(), because istringstream>>float randomly causes a segfault on mingw
-rw-r--r--src/utility.h13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/utility.h b/src/utility.h
index fbd76f230..07216a27d 100644
--- a/src/utility.h
+++ b/src/utility.h
@@ -1049,22 +1049,25 @@ inline s32 mystoi(const std::string &s, s32 min, s32 max)
// MSVC2010 includes it's own versions of these
//#if !defined(_MSC_VER) || _MSC_VER < 1600
-inline s32 mystoi(std::string s)
+inline s32 mystoi(const std::string &s)
{
return atoi(s.c_str());
}
-inline s32 mystoi(std::wstring s)
+inline s32 mystoi(const std::wstring &s)
{
return atoi(wide_to_narrow(s).c_str());
}
-inline float mystof(std::string s)
+inline float mystof(const std::string &s)
{
- float f;
+ // This crap causes a segfault in certain cases on MinGW
+ /*float f;
std::istringstream ss(s);
ss>>f;
- return f;
+ return f;*/
+ // This works in that case
+ return atof(s.c_str());
}
//#endif