Skip to content

Commit

Permalink
Add local unaware atof function
Browse files Browse the repository at this point in the history
Fixes sass#923
  • Loading branch information
mgreter committed Mar 9, 2015
1 parent 21ce837 commit 14bfd99
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
6 changes: 3 additions & 3 deletions eval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 14bfd99

Please sign in to comment.