Skip to content

Commit 8e39cb1

Browse files
committed
Fix some minor coding issue
1 parent 864db89 commit 8e39cb1

File tree

10 files changed

+37
-39
lines changed

10 files changed

+37
-39
lines changed

src/ast.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1688,31 +1688,31 @@ namespace Sass {
16881688
void Arguments::adjust_after_pushing(Argument_Obj a)
16891689
{
16901690
if (!a->name().empty()) {
1691-
if (/* has_rest_argument_ || */ has_keyword_argument_) {
1691+
if (has_keyword_argument()) {
16921692
error("named arguments must precede variable-length argument", a->pstate());
16931693
}
1694-
has_named_arguments_ = true;
1694+
has_named_arguments(true);
16951695
}
16961696
else if (a->is_rest_argument()) {
1697-
if (has_rest_argument_) {
1697+
if (has_rest_argument()) {
16981698
error("functions and mixins may only be called with one variable-length argument", a->pstate());
16991699
}
17001700
if (has_keyword_argument_) {
17011701
error("only keyword arguments may follow variable arguments", a->pstate());
17021702
}
1703-
has_rest_argument_ = true;
1703+
has_rest_argument(true);
17041704
}
17051705
else if (a->is_keyword_argument()) {
1706-
if (has_keyword_argument_) {
1706+
if (has_keyword_argument()) {
17071707
error("functions and mixins may only be called with one keyword argument", a->pstate());
17081708
}
1709-
has_keyword_argument_ = true;
1709+
has_keyword_argument(true);
17101710
}
17111711
else {
1712-
if (has_rest_argument_) {
1712+
if (has_rest_argument()) {
17131713
error("ordinal arguments must precede variable-length arguments", a->pstate());
17141714
}
1715-
if (has_named_arguments_) {
1715+
if (has_named_arguments()) {
17161716
error("ordinal arguments must precede named arguments", a->pstate());
17171717
}
17181718
}

src/ast.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2224,22 +2224,22 @@ namespace Sass {
22242224
void adjust_after_pushing(Parameter_Obj p)
22252225
{
22262226
if (p->default_value()) {
2227-
if (has_rest_parameter_) {
2227+
if (has_rest_parameter()) {
22282228
error("optional parameters may not be combined with variable-length parameters", p->pstate());
22292229
}
2230-
has_optional_parameters_ = true;
2230+
has_optional_parameters(true);
22312231
}
22322232
else if (p->is_rest_parameter()) {
2233-
if (has_rest_parameter_) {
2233+
if (has_rest_parameter()) {
22342234
error("functions and mixins cannot have more than one variable-length parameter", p->pstate());
22352235
}
2236-
has_rest_parameter_ = true;
2236+
has_rest_parameter(true);
22372237
}
22382238
else {
2239-
if (has_rest_parameter_) {
2239+
if (has_rest_parameter()) {
22402240
error("required parameters must precede variable-length parameters", p->pstate());
22412241
}
2242-
if (has_optional_parameters_) {
2242+
if (has_optional_parameters()) {
22432243
error("required parameters must precede optional parameters", p->pstate());
22442244
}
22452245
}

src/backtrace.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ namespace Sass {
6060

6161
size_t depth()
6262
{
63-
size_t d = 0;
63+
size_t d = std::string::npos;
6464
Backtrace* p = parent;
6565
while (p) {
6666
++d;
6767
p = p->parent;
6868
}
69-
return d-1;
69+
return d;
7070
}
7171

7272
};

src/cssize.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,6 @@ namespace Sass {
476476
ss->tabs(ss->tabs() + node->tabs());
477477
ss->group_end(node->group_end());
478478

479-
if (!ss) continue;
480-
481479
Block_Obj bb = SASS_MEMORY_NEW(Block,
482480
children->pstate(),
483481
children->length(),
@@ -584,10 +582,11 @@ namespace Sass {
584582
}
585583

586584
Media_Query_Ptr mm = SASS_MEMORY_NEW(Media_Query,
587-
588-
mq1->pstate(), 0,
589-
mq1->length() + mq2->length(), mod == "not", mod == "only"
590-
);
585+
mq1->pstate(),
586+
0,
587+
mq1->length() + mq2->length(),
588+
mod == "not",
589+
mod == "only");
591590

592591
if (!type.empty()) {
593592
mm->media_type(SASS_MEMORY_NEW(String_Quoted, mq1->pstate(), type));

src/eval.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1597,20 +1597,19 @@ namespace Sass {
15971597

15981598
if (ltype == Expression::NULL_VAL) throw Exception::InvalidNullOperation(&lhs, &rhs, sass_op_to_name(op));
15991599
if (rtype == Expression::NULL_VAL) throw Exception::InvalidNullOperation(&lhs, &rhs, sass_op_to_name(op));
1600-
if (op == Sass_OP::MOD) throw Exception::UndefinedOperation(&lhs, &rhs, sass_op_to_name(op));
1601-
if (op == Sass_OP::MUL) throw Exception::UndefinedOperation(&lhs, &rhs, sass_op_to_name(op));
16021600
std::string sep;
16031601
switch (op) {
16041602
case Sass_OP::SUB: sep = "-"; break;
16051603
case Sass_OP::DIV: sep = "/"; break;
1606-
case Sass_OP::MUL: sep = "*"; break;
1607-
case Sass_OP::MOD: sep = "%"; break;
1604+
// cases are already handled above
16081605
case Sass_OP::EQ: sep = "=="; break;
16091606
case Sass_OP::NEQ: sep = "!="; break;
16101607
case Sass_OP::LT: sep = "<"; break;
16111608
case Sass_OP::GT: sep = ">"; break;
16121609
case Sass_OP::LTE: sep = "<="; break;
16131610
case Sass_OP::GTE: sep = ">="; break;
1611+
case Sass_OP::MUL: throw Exception::UndefinedOperation(&lhs, &rhs, sass_op_to_name(op));
1612+
case Sass_OP::MOD: throw Exception::UndefinedOperation(&lhs, &rhs, sass_op_to_name(op));
16141613
default: break;
16151614
}
16161615

src/extend.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2074,8 +2074,8 @@ namespace Sass {
20742074
if (it.first) sel = it.first->first();
20752075
if (it.second) ext = it.second;
20762076
if (ext && (ext->extended() || ext->is_optional())) continue;
2077-
std::string str_sel(sel->to_string({ NESTED, 5 }));
2078-
std::string str_ext(ext->to_string({ NESTED, 5 }));
2077+
std::string str_sel(sel ? sel->to_string({ NESTED, 5 }) : "NULL");
2078+
std::string str_ext(ext ? ext->to_string({ NESTED, 5 }) : "NULL");
20792079
// debug_ast(sel, "sel: ");
20802080
// debug_ast(ext, "ext: ");
20812081
error("\"" + str_sel + "\" failed to @extend \"" + str_ext + "\".\n"

src/functions.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ namespace Sass {
778778
return hsla_impl(hsl_struct.h, hsl_struct.s, hsl_struct.l, alpha, ctx, pstate);
779779
}
780780
if (a) {
781-
double ascale = (a ? ARGR("$alpha", Number, -100.0, 100.0)->value() : 0.0) / 100.0;
781+
double ascale = (ARGR("$alpha", Number, -100.0, 100.0)->value()) / 100.0;
782782
return SASS_MEMORY_NEW(Color,
783783
pstate,
784784
color->r(),
@@ -826,7 +826,7 @@ namespace Sass {
826826
return hsla_impl(hsl_struct.h, hsl_struct.s, hsl_struct.l, alpha, ctx, pstate);
827827
}
828828
if (a) {
829-
double alpha = a ? ARGR("$alpha", Number, 0, 1.0)->value() : color->a();
829+
double alpha = ARGR("$alpha", Number, 0, 1.0)->value();
830830
return SASS_MEMORY_NEW(Color,
831831
pstate,
832832
color->r(),

src/lexer.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ namespace Sass {
9696
// Regex equivalent: /(?:literal)/
9797
template <const char* str>
9898
const char* exactly(const char* src) {
99-
if (str == 0) return 0;
99+
if (str == NULL) return 0;
100100
const char* pre = str;
101-
if (src == 0) return 0;
101+
if (src == NULL) return 0;
102102
// there is a small chance that the search string
103103
// is longer than the rest of the string to look at
104104
while (*pre && *src == *pre) {
@@ -114,9 +114,9 @@ namespace Sass {
114114
// only define lower case alpha chars
115115
template <const char* str>
116116
const char* insensitive(const char* src) {
117-
if (str == 0) return 0;
117+
if (str == NULL) return 0;
118118
const char* pre = str;
119-
if (src == 0) return 0;
119+
if (src == NULL) return 0;
120120
// there is a small chance that the search string
121121
// is longer than the rest of the string to look at
122122
while (*pre && (*src == *pre || *src+32 == *pre)) {

src/node.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ namespace Sass {
1414
}
1515

1616

17-
Node Node::createSelector(Complex_Selector_Ptr pSelector) {
17+
Node Node::createSelector(const Complex_Selector& pSelector) {
1818
NodeDequePtr null;
1919

20-
Complex_Selector_Ptr pStripped = SASS_MEMORY_COPY(pSelector);
20+
Complex_Selector_Ptr pStripped = SASS_MEMORY_COPY(&pSelector);
2121
pStripped->tail(NULL);
2222
pStripped->combinator(Complex_Selector::ANCESTOR_OF);
2323

2424
Node n(SELECTOR, Complex_Selector::ANCESTOR_OF, pStripped, null /*pCollection*/);
25-
if (pSelector) n.got_line_feed = pSelector->has_line_feed();
25+
n.got_line_feed = pSelector.has_line_feed();
2626
return n;
2727
}
2828

@@ -196,7 +196,7 @@ namespace Sass {
196196

197197
// the first Complex_Selector may contain a dummy head pointer, skip it.
198198
if (pToConvert->head() && !empty_parent_ref) {
199-
node.collection()->push_back(Node::createSelector(pToConvert));
199+
node.collection()->push_back(Node::createSelector(*pToConvert));
200200
if (has_lf) node.collection()->back().got_line_feed = has_lf;
201201
has_lf = false;
202202
}

src/node.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ namespace Sass {
6161
static Node createCombinator(const Complex_Selector::Combinator& combinator);
6262

6363
// This method will klone the selector, stripping off the tail and combinator
64-
static Node createSelector(Complex_Selector_Ptr pSelector);
64+
static Node createSelector(const Complex_Selector& pSelector);
6565

6666
static Node createCollection();
6767
static Node createCollection(const NodeDeque& values);

0 commit comments

Comments
 (0)