Skip to content

Commit 3ffb1fd

Browse files
committed
Merge pull request #1999 from mgreter/bugfix/issue_1991_and_1996
Bugfix/issue 1991 and 1996
2 parents 10d8292 + 1189ef9 commit 3ffb1fd

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

src/ast.hpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,24 @@ namespace Sass {
277277
// extra <std::vector> internally to maintain insertion order for interation.
278278
/////////////////////////////////////////////////////////////////////////////
279279
class Hashed {
280+
struct HashExpression {
281+
size_t operator() (Expression* ex) const {
282+
return ex ? ex->hash() : 0;
283+
}
284+
};
285+
struct CompareExpression {
286+
bool operator()(const Expression* lhs, const Expression* rhs) const {
287+
return lhs && rhs && *lhs == *rhs;
288+
}
289+
};
290+
typedef std::unordered_map<
291+
Expression*, // key
292+
Expression*, // value
293+
HashExpression, // hasher
294+
CompareExpression // compare
295+
> ExpressionMap;
280296
private:
281-
std::unordered_map<Expression*, Expression*> elements_;
297+
ExpressionMap elements_;
282298
std::vector<Expression*> list_;
283299
protected:
284300
size_t hash_;
@@ -287,7 +303,7 @@ namespace Sass {
287303
void reset_duplicate_key() { duplicate_key_ = 0; }
288304
virtual void adjust_after_pushing(std::pair<Expression*, Expression*> p) { }
289305
public:
290-
Hashed(size_t s = 0) : elements_(std::unordered_map<Expression*, Expression*>(s)), list_(std::vector<Expression*>())
306+
Hashed(size_t s = 0) : elements_(ExpressionMap(s)), list_(std::vector<Expression*>())
291307
{ elements_.reserve(s); list_.reserve(s); reset_duplicate_key(); }
292308
virtual ~Hashed();
293309
size_t length() const { return list_.size(); }
@@ -296,7 +312,7 @@ namespace Sass {
296312
Expression* at(Expression* k) const;
297313
bool has_duplicate_key() const { return duplicate_key_ != 0; }
298314
Expression* get_duplicate_key() const { return duplicate_key_; }
299-
const std::unordered_map<Expression*, Expression*> elements() { return elements_; }
315+
const ExpressionMap elements() { return elements_; }
300316
Hashed& operator<<(std::pair<Expression*, Expression*> p)
301317
{
302318
reset_hash();
@@ -324,7 +340,7 @@ namespace Sass {
324340
reset_duplicate_key();
325341
return *this;
326342
}
327-
const std::unordered_map<Expression*, Expression*>& pairs() const { return elements_; }
343+
const ExpressionMap& pairs() const { return elements_; }
328344
const std::vector<Expression*>& keys() const { return list_; }
329345

330346
std::unordered_map<Expression*, Expression*>::iterator end() { return elements_.end(); }

src/eval.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1729,7 +1729,7 @@ namespace Sass {
17291729
{
17301730
// the parser will look for a brace to end the selector
17311731
std::string result_str(s->contents()->perform(this)->to_string(ctx.c_options));
1732-
result_str = unquote(Util::rtrim(result_str)) + "{";
1732+
result_str = unquote(Util::rtrim(result_str)) + "\n{";
17331733
Parser p = Parser::from_c_str(result_str.c_str(), ctx, s->pstate());
17341734
return operator()(p.parse_selector_list(exp.block_stack.back()->is_root()));
17351735
}

src/prelexer.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,9 @@ namespace Sass {
164164

165165
// Match a line comment.
166166
const char* line_comment(const char* src);
167-
const char* line_comment_prefix(const char* src);
168167

169168
// Match a block comment.
170169
const char* block_comment(const char* src);
171-
const char* block_comment_prefix(const char* src);
172170
// Match either.
173171
const char* comment(const char* src);
174172
// Match double- and single-quoted strings.

0 commit comments

Comments
 (0)