ext/libsass/eval.cpp in sassc-1.2.0 vs ext/libsass/eval.cpp in sassc-1.3.0

- old
+ new

@@ -391,20 +391,28 @@ } Expression* Eval::operator()(Map* m) { if (m->is_expanded()) return m; + + // make sure we're not starting with duplicate keys. + // the duplicate key state will have been set in the parser phase. + if (m->has_duplicate_key()) { + To_String to_string(&ctx); + error("Duplicate key \"" + m->get_duplicate_key()->perform(&to_string) + "\" in map " + m->perform(&to_string) + ".", m->pstate()); + } + Map* mm = new (ctx.mem) Map(m->pstate(), m->length()); for (auto key : m->keys()) { - *mm << std::make_pair(key->perform(this), m->at(key)->perform(this)); + *mm << std::make_pair(key->perform(this), m->at(key)->perform(this));; } - // check for duplicate keys + // check the evaluated keys aren't duplicates. if (mm->has_duplicate_key()) { To_String to_string(&ctx); - error("Duplicate key \"" + mm->get_duplicate_key()->perform(&to_string) + "\" in map " + m->perform(&to_string) + ".", m->pstate()); + error("Duplicate key \"" + mm->get_duplicate_key()->perform(&to_string) + "\" in map " + mm->perform(&to_string) + ".", mm->pstate()); } mm->is_expanded(true); return mm; } @@ -788,10 +796,14 @@ sass_atof(num.c_str()), Token(number(text.c_str())), zero); break; case Textual::HEX: { + if (t->value().substr(0, 1) != "#") { + result = new (ctx.mem) String_Constant(t->pstate(), t->value()); + break; + } string hext(t->value().substr(1)); // chop off the '#' if (hext.length() == 6) { string r(hext.substr(0,2)); string g(hext.substr(2,2)); string b(hext.substr(4,2)); @@ -921,10 +933,11 @@ if (!str->quote_mark()) { str->value(string_unescape(str->value())); } else if (str->quote_mark()) { str->quote_mark('*'); } + str->is_delayed(true); return str; } Expression* Eval::operator()(String_Constant* s) { @@ -995,12 +1008,20 @@ Expression* Eval::operator()(Media_Query_Expression* e) { Expression* feature = e->feature(); feature = (feature ? feature->perform(this) : 0); + if (feature && dynamic_cast<String_Quoted*>(feature)) { + feature = new (ctx.mem) String_Constant(feature->pstate(), + dynamic_cast<String_Quoted*>(feature)->value()); + } Expression* value = e->value(); value = (value ? value->perform(this) : 0); + if (value && dynamic_cast<String_Quoted*>(value)) { + value = new (ctx.mem) String_Constant(value->pstate(), + dynamic_cast<String_Quoted*>(value)->value()); + } return new (ctx.mem) Media_Query_Expression(e->pstate(), feature, value, e->is_interpolated()); } @@ -1100,11 +1121,13 @@ l->b() == r->b() && l->a() == r->a(); } break; case Expression::STRING: { - return unquote(static_cast<String_Constant*>(lhs)->value()) == - unquote(static_cast<String_Constant*>(rhs)->value()); + string slhs = static_cast<String_Quoted*>(lhs)->value(); + string srhs = static_cast<String_Quoted*>(rhs)->value(); + return unquote(slhs) == unquote(srhs) && + (!(is_quoted(slhs) || is_quoted(srhs)) || slhs[0] == srhs[0]); } break; case Expression::LIST: { List* l = static_cast<List*>(lhs); List* r = static_cast<List*>(rhs);