Skip to content

Commit

Permalink
Improve deprecation handling in unquote function
Browse files Browse the repository at this point in the history
Fixes sass#1291
  • Loading branch information
mgreter committed Jun 30, 2015
1 parent a72876b commit a56e87e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
9 changes: 9 additions & 0 deletions error_handling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ namespace Sass {
warn(msg, pstate);
}

void deprecated(string msg, ParserState pstate)
{
string cwd(Sass::File::get_cwd());
cerr << "DEPRECATION WARNING: " << msg << endl;
cerr << "will be an error in future versions of Sass." << endl;
string rel_path(Sass::File::resolve_relative_path(pstate.path, cwd, cwd));
cerr << " on line " << pstate.line+1 << " of " << rel_path << endl;
}

void error(string msg, ParserState pstate)
{
throw Sass_Error(Sass_Error::syntax, pstate, msg);
Expand Down
3 changes: 3 additions & 0 deletions error_handling.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ namespace Sass {
void warn(string msg, ParserState pstate);
void warn(string msg, ParserState pstate, Backtrace* bt);

void deprecated(string msg, ParserState pstate);
// void deprecated(string msg, ParserState pstate, Backtrace* bt);

void error(string msg, ParserState pstate);
void error(string msg, ParserState pstate, Backtrace* bt);

Expand Down
14 changes: 9 additions & 5 deletions functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -771,17 +771,21 @@ namespace Sass {
if (dynamic_cast<Null*>(arg)) {
return new (ctx.mem) Null(pstate);
}
else if (List* list = dynamic_cast<List*>(arg)) {
return list;
}
else if (String_Quoted* string_quoted = dynamic_cast<String_Quoted*>(arg)) {
String_Constant* result = new (ctx.mem) String_Constant(pstate, string_quoted->value());
// remember if the string was quoted (color tokens)
result->sass_fix_1291(string_quoted->quote_mark() != 0);
return result;
}
To_String to_string(&ctx);
return new (ctx.mem) String_Constant(pstate, string(arg->perform(&to_string)));
else if (dynamic_cast<String_Constant*>(arg)) {
return (Expression*) arg;
}
else {
To_String to_string(&ctx);
string val(arg->perform(&to_string));
deprecated("Passing " + val + ", a non-string value, to unquote()", pstate);
return (Expression*) arg;
}
}

Signature quote_sig = "quote($string)";
Expand Down

0 comments on commit a56e87e

Please sign in to comment.