Skip to content

Commit c4fb559

Browse files
committed
Merge pull request #1085 from mgreter/bugfix/issue_1082
Improve block comment parsing for lists
2 parents e60ad9a + 980e17d commit c4fb559

File tree

6 files changed

+33
-15
lines changed

6 files changed

+33
-15
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ matrix:
3333
env: AUTOTOOLS=yes COVERAGE=yes BUILD=static
3434
- os: osx
3535
compiler: gcc
36+
- os: osx
37+
env: AUTOTOOLS=no COVERAGE=yes BUILD=static
3638

3739
script: ./script/ci-build-libsass
3840
before_install: ./script/ci-install-deps

Makefile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,15 @@ RM ?= rm -f
44
CP ?= cp -a
55
MKDIR ?= mkdir
66
WINDRES ?= windres
7-
CFLAGS ?= -Wall -O2
8-
CXXFLAGS ?= -Wall -O2
9-
LDFLAGS ?= -Wall -O2 -Wl,--no-undefined
7+
CFLAGS ?= -Wall
8+
CXXFLAGS ?= -Wall
9+
LDFLAGS ?= -Wall
10+
ifneq "$(COVERAGE)" "yes"
11+
CFLAGS += -O2
12+
CXXFLAGS += -O2
13+
LDFLAGS += -O2
14+
endif
15+
LDFLAGS += -Wl,-undefined,error
1016
CAT ?= $(if $(filter $(OS),Windows_NT),type,cat)
1117

1218
ifneq (,$(findstring /cygdrive/,$(PATH)))

ast.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
namespace Sass {
99
using namespace std;
1010

11+
static Null sass_null(Sass::Null(ParserState("null")));
12+
1113
bool Compound_Selector::operator<(const Compound_Selector& rhs) const
1214
{
1315
To_String to_string;
@@ -587,5 +589,12 @@ namespace Sass {
587589
return result;
588590
}*/
589591

592+
Expression* Hashed::at(Expression* k) const
593+
{
594+
if (elements_.count(k))
595+
{ return elements_.at(k); }
596+
else { return &sass_null; }
597+
}
598+
590599
}
591600

ast.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,10 @@ namespace Sass {
210210
size_t length() const { return list_.size(); }
211211
bool empty() const { return list_.empty(); }
212212
bool has(Expression* k) const { return elements_.count(k) == 1; }
213-
Expression* at(Expression* k) const { return elements_.at(k); }
213+
Expression* at(Expression* k) const;
214214
bool has_duplicate_key() const { return duplicate_key_ != 0; }
215215
Expression* get_duplicate_key() const { return duplicate_key_; }
216+
const unordered_map<Expression*, Expression*> elements() { return elements_; }
216217
Hashed& operator<<(pair<Expression*, Expression*> p)
217218
{
218219
reset_hash();

parser.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,7 @@ namespace Sass {
10511051

10521052
Expression* Parser::parse_comma_list()
10531053
{
1054-
if (peek< alternatives <
1054+
if (peek_css< alternatives <
10551055
// exactly<'!'>,
10561056
// exactly<':'>,
10571057
exactly<';'>,
@@ -1063,14 +1063,14 @@ namespace Sass {
10631063
{ return new (ctx.mem) List(pstate, 0); }
10641064
Expression* list1 = parse_space_list();
10651065
// if it's a singleton, return it directly; don't wrap it
1066-
if (!peek< exactly<','> >(position)) return list1;
1066+
if (!peek_css< exactly<','> >(position)) return list1;
10671067

10681068
List* comma_list = new (ctx.mem) List(pstate, 2, List::COMMA);
10691069
(*comma_list) << list1;
10701070

1071-
while (lex< exactly<','> >())
1071+
while (lex_css< exactly<','> >())
10721072
{
1073-
if (peek< alternatives <
1073+
if (peek_css< alternatives <
10741074
// exactly<'!'>,
10751075
exactly<';'>,
10761076
exactly<'}'>,
@@ -1091,7 +1091,7 @@ namespace Sass {
10911091
{
10921092
Expression* disj1 = parse_disjunction();
10931093
// if it's a singleton, return it directly; don't wrap it
1094-
if (peek< alternatives <
1094+
if (peek_css< alternatives <
10951095
// exactly<'!'>,
10961096
exactly<';'>,
10971097
exactly<'}'>,
@@ -1108,7 +1108,7 @@ namespace Sass {
11081108
List* space_list = new (ctx.mem) List(pstate, 2, List::SPACE);
11091109
(*space_list) << disj1;
11101110

1111-
while (!(peek< alternatives <
1111+
while (!(peek_css< alternatives <
11121112
// exactly<'!'>,
11131113
exactly<';'>,
11141114
exactly<'}'>,
@@ -1229,9 +1229,9 @@ namespace Sass {
12291229

12301230
Expression* Parser::parse_factor()
12311231
{
1232-
if (lex< exactly<'('> >()) {
1232+
if (lex_css< exactly<'('> >()) {
12331233
Expression* value = parse_map();
1234-
if (!lex< exactly<')'> >()) error("unclosed parenthesis", pstate);
1234+
if (!lex_css< exactly<')'> >()) error("unclosed parenthesis", pstate);
12351235
value->is_delayed(false);
12361236
// make sure wrapped lists and division expressions are non-delayed within parentheses
12371237
if (value->concrete_type() == Expression::LIST) {

script/ci-build-libsass

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ if [ "x$SASS_SPEC_PATH" == "x" ]; then export SASS_SPEC_PATH=$(pwd)/sass-spec; f
1414

1515
if [ "x$COVERAGE" == "xyes" ]; then
1616
COVERAGE_OPT="--enable-coverage"
17-
export EXTRA_CFLAGS="-O0 --coverage"
18-
export EXTRA_CXXFLAGS="-O0 --coverage"
19-
export EXTRA_LDFLAGS="-O0 --coverage"
17+
export EXTRA_CFLAGS="--coverage"
18+
export EXTRA_CXXFLAGS="--coverage"
19+
export EXTRA_LDFLAGS="--coverage"
2020
else
2121
COVERAGE_OPT="--disable-coverage"
2222
fi

0 commit comments

Comments
 (0)