diff --git a/eval.cpp b/eval.cpp index 54168a5f62..a25ee8100a 100644 --- a/eval.cpp +++ b/eval.cpp @@ -658,19 +658,19 @@ namespace Sass { { case Textual::NUMBER: result = new (ctx.mem) Number(t->pstate(), - atof(num.c_str()), + sass_atof(num.c_str()), "", zero); break; case Textual::PERCENTAGE: result = new (ctx.mem) Number(t->pstate(), - atof(num.c_str()), + sass_atof(num.c_str()), "%", zero); break; case Textual::DIMENSION: result = new (ctx.mem) Number(t->pstate(), - atof(num.c_str()), + sass_atof(num.c_str()), Token(number(text.c_str()), t->pstate()), zero); break; diff --git a/util.cpp b/util.cpp index f6a89db71b..50bc915a9d 100644 --- a/util.cpp +++ b/util.cpp @@ -21,6 +21,16 @@ namespace Sass { return ret; } + /* Locale unspecific atof function. */ + double sass_atof(const char *str) + { + char* locale = setlocale(LC_NUMERIC, NULL); + setlocale(LC_NUMERIC, "C"); + double val = atof(str); + setlocale(LC_NUMERIC, locale); + return val; + } + // double escape every escape sequences // escape unescaped quotes and backslashes string string_escape(const string& str) diff --git a/util.hpp b/util.hpp index b320c444dc..5d01045cc6 100644 --- a/util.hpp +++ b/util.hpp @@ -9,6 +9,7 @@ namespace Sass { using namespace std; char* sass_strdup(const char* str); + double sass_atof(const char* str); string string_escape(const string& str); string string_unescape(const string& str); string evacuate_quotes(const string& str);