Skip to content

Commit e4e65b4

Browse files
authored
Merge pull request #2316 from mgreter/nschonni/cleanups
Let's see if we see compiler warnings pop up again ...
2 parents b31cf55 + 5923e62 commit e4e65b4

26 files changed

+221
-243
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ bin/*
7070
.libs/
7171
win/bin
7272
*.user
73+
win/*.db
7374

7475
# Final results
7576

src/ast.cpp

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ namespace Sass {
222222
// heads are not equal
223223
else return *l_h < *r_h;
224224
}
225-
return true;
226225
}
227226

228227
bool Complex_Selector::operator== (const Complex_Selector& rhs) const
@@ -326,7 +325,6 @@ namespace Sass {
326325
if (const Complex_Selector* cs = Cast<Complex_Selector>(&rhs)) return *this < *cs;
327326
if (const Compound_Selector* ch = Cast<Compound_Selector>(&rhs)) return *this < *ch;
328327
throw std::runtime_error("invalid selector base classes to compare");
329-
return false;
330328
}
331329

332330
bool Compound_Selector::operator== (const Selector& rhs) const
@@ -366,7 +364,6 @@ namespace Sass {
366364
if (const Complex_Selector* cs = Cast<Complex_Selector>(&rhs)) return *this < *cs;
367365
if (const Compound_Selector* ch = Cast<Compound_Selector>(&rhs)) return *this < *ch;
368366
throw std::runtime_error("invalid selector base classes to compare");
369-
return false;
370367
}
371368

372369
bool Simple_Selector::operator== (const Selector& rhs) const
@@ -406,9 +403,9 @@ namespace Sass {
406403
bool Selector_List::operator== (const Selector& rhs) const
407404
{
408405
// solve the double dispatch problem by using RTTI information via dynamic cast
409-
if (Selector_List_Ptr_Const ls = Cast<Selector_List>(&rhs)) { return *this == *ls; }
410-
else if (Complex_Selector_Ptr_Const ls = Cast<Complex_Selector>(&rhs)) { return *this == *ls; }
411-
else if (Compound_Selector_Ptr_Const ls = Cast<Compound_Selector>(&rhs)) { return *this == *ls; }
406+
if (Selector_List_Ptr_Const sl = Cast<Selector_List>(&rhs)) { return *this == *sl; }
407+
else if (Complex_Selector_Ptr_Const cpx = Cast<Complex_Selector>(&rhs)) { return *this == *cpx; }
408+
else if (Compound_Selector_Ptr_Const cpd = Cast<Compound_Selector>(&rhs)) { return *this == *cpd; }
412409
// no compare method
413410
return this == &rhs;
414411
}
@@ -452,8 +449,7 @@ namespace Sass {
452449
// advance
453450
++i; ++n;
454451
}
455-
// no mismatch
456-
return true;
452+
// there is no break?!
457453
}
458454

459455
bool Selector_List::operator< (const Selector& rhs) const
@@ -834,9 +830,9 @@ namespace Sass {
834830

835831
for (size_t i = 0, iL = length(); i < iL; ++i)
836832
{
837-
Selector_Obj lhs = (*this)[i];
833+
Selector_Obj wlhs = (*this)[i];
838834
// very special case for wrapped matches selector
839-
if (Wrapped_Selector_Obj wrapped = Cast<Wrapped_Selector>(lhs)) {
835+
if (Wrapped_Selector_Obj wrapped = Cast<Wrapped_Selector>(wlhs)) {
840836
if (wrapped->name() == ":not") {
841837
if (Selector_List_Obj not_list = Cast<Selector_List>(wrapped->selector())) {
842838
if (not_list->is_superselector_of(rhs, wrapped->name())) return false;
@@ -845,7 +841,7 @@ namespace Sass {
845841
}
846842
}
847843
if (wrapped->name() == ":matches" || wrapped->name() == ":-moz-any") {
848-
lhs = wrapped->selector();
844+
wlhs = wrapped->selector();
849845
if (Selector_List_Obj list = Cast<Selector_List>(wrapped->selector())) {
850846
if (Compound_Selector_Obj comp = Cast<Compound_Selector>(rhs)) {
851847
if (!wrapping.empty() && wrapping != wrapped->name()) return false;
@@ -861,13 +857,11 @@ namespace Sass {
861857
if (wrapped->name() == wrapped_r->name()) {
862858
if (wrapped->is_superselector_of(wrapped_r)) {
863859
continue;
864-
rset.insert(lhs->to_string());
865-
866860
}}
867861
}
868862
}
869863
// match from here on as strings
870-
lset.insert(lhs->to_string());
864+
lset.insert(wlhs->to_string());
871865
}
872866

873867
for (size_t n = 0, nL = rhs->length(); n < nL; ++n)
@@ -1010,8 +1004,7 @@ namespace Sass {
10101004
// advance now
10111005
++i; ++n;
10121006
}
1013-
// no mismatch
1014-
return true;
1007+
// there is no break?!
10151008
}
10161009

10171010
bool Complex_Selector::is_superselector_of(Compound_Selector_Obj rhs, std::string wrapping)
@@ -1091,12 +1084,7 @@ namespace Sass {
10911084
{ return false; }
10921085
return lhs->tail()->is_superselector_of(marker->tail());
10931086
}
1094-
else
1095-
{
1096-
return lhs->tail()->is_superselector_of(marker->tail());
1097-
}
1098-
// catch-all
1099-
return false;
1087+
return lhs->tail()->is_superselector_of(marker->tail());
11001088
}
11011089

11021090
size_t Complex_Selector::length() const
@@ -1127,17 +1115,18 @@ namespace Sass {
11271115
error("Invalid parent selector", pstate_);
11281116
} else if (last()->head_ && last()->head_->length()) {
11291117
Compound_Selector_Obj rh = last()->head();
1130-
size_t i = 0, L = h->length();
1118+
size_t i;
1119+
size_t L = h->length();
11311120
if (Cast<Element_Selector>(h->first())) {
1132-
if (Class_Selector_Ptr sq = Cast<Class_Selector>(rh->last())) {
1133-
Class_Selector_Ptr sqs = SASS_MEMORY_COPY(sq);
1121+
if (Class_Selector_Ptr cs = Cast<Class_Selector>(rh->last())) {
1122+
Class_Selector_Ptr sqs = SASS_MEMORY_COPY(cs);
11341123
sqs->name(sqs->name() + (*h)[0]->name());
11351124
sqs->pstate((*h)[0]->pstate());
11361125
(*rh)[rh->length()-1] = sqs;
11371126
rh->pstate(h->pstate());
11381127
for (i = 1; i < L; ++i) rh->append((*h)[i]);
1139-
} else if (Id_Selector_Ptr sq = Cast<Id_Selector>(rh->last())) {
1140-
Id_Selector_Ptr sqs = SASS_MEMORY_COPY(sq);
1128+
} else if (Id_Selector_Ptr is = Cast<Id_Selector>(rh->last())) {
1129+
Id_Selector_Ptr sqs = SASS_MEMORY_COPY(is);
11411130
sqs->name(sqs->name() + (*h)[0]->name());
11421131
sqs->pstate((*h)[0]->pstate());
11431132
(*rh)[rh->length()-1] = sqs;
@@ -1353,12 +1342,7 @@ namespace Sass {
13531342

13541343
}
13551344
// has no head
1356-
else {
1357-
return this->tails(tails);
1358-
}
1359-
1360-
// unreachable
1361-
return 0;
1345+
return this->tails(tails);
13621346
}
13631347

13641348
Selector_List_Ptr Complex_Selector::tails(Selector_List_Ptr tails)
@@ -1762,7 +1746,8 @@ namespace Sass {
17621746
denominator_units_(std::vector<std::string>()),
17631747
hash_(0)
17641748
{
1765-
size_t l = 0, r = 0;
1749+
size_t l = 0;
1750+
size_t r;
17661751
if (!u.empty()) {
17671752
bool nominator = true;
17681753
while (true) {

src/ast.hpp

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,22 +1147,22 @@ namespace Sass {
11471147

11481148
inline static const std::string sass_op_to_name(enum Sass_OP op) {
11491149
switch (op) {
1150-
case AND: return "and"; break;
1151-
case OR: return "or"; break;
1152-
case EQ: return "eq"; break;
1153-
case NEQ: return "neq"; break;
1154-
case GT: return "gt"; break;
1155-
case GTE: return "gte"; break;
1156-
case LT: return "lt"; break;
1157-
case LTE: return "lte"; break;
1158-
case ADD: return "plus"; break;
1159-
case SUB: return "sub"; break;
1160-
case MUL: return "times"; break;
1161-
case DIV: return "div"; break;
1162-
case MOD: return "mod"; break;
1150+
case AND: return "and";
1151+
case OR: return "or";
1152+
case EQ: return "eq";
1153+
case NEQ: return "neq";
1154+
case GT: return "gt";
1155+
case GTE: return "gte";
1156+
case LT: return "lt";
1157+
case LTE: return "lte";
1158+
case ADD: return "plus";
1159+
case SUB: return "sub";
1160+
case MUL: return "times";
1161+
case DIV: return "div";
1162+
case MOD: return "mod";
11631163
// this is only used internally!
1164-
case NUM_OPS: return "[OPS]"; break;
1165-
default: return "invalid"; break;
1164+
case NUM_OPS: return "[OPS]";
1165+
default: return "invalid";
11661166
}
11671167
}
11681168

@@ -1191,42 +1191,42 @@ namespace Sass {
11911191
{ }
11921192
const std::string type_name() {
11931193
switch (optype()) {
1194-
case AND: return "and"; break;
1195-
case OR: return "or"; break;
1196-
case EQ: return "eq"; break;
1197-
case NEQ: return "neq"; break;
1198-
case GT: return "gt"; break;
1199-
case GTE: return "gte"; break;
1200-
case LT: return "lt"; break;
1201-
case LTE: return "lte"; break;
1202-
case ADD: return "add"; break;
1203-
case SUB: return "sub"; break;
1204-
case MUL: return "mul"; break;
1205-
case DIV: return "div"; break;
1206-
case MOD: return "mod"; break;
1194+
case AND: return "and";
1195+
case OR: return "or";
1196+
case EQ: return "eq";
1197+
case NEQ: return "neq";
1198+
case GT: return "gt";
1199+
case GTE: return "gte";
1200+
case LT: return "lt";
1201+
case LTE: return "lte";
1202+
case ADD: return "add";
1203+
case SUB: return "sub";
1204+
case MUL: return "mul";
1205+
case DIV: return "div";
1206+
case MOD: return "mod";
12071207
// this is only used internally!
1208-
case NUM_OPS: return "[OPS]"; break;
1209-
default: return "invalid"; break;
1208+
case NUM_OPS: return "[OPS]";
1209+
default: return "invalid";
12101210
}
12111211
}
12121212
const std::string separator() {
12131213
switch (optype()) {
1214-
case AND: return "&&"; break;
1215-
case OR: return "||"; break;
1216-
case EQ: return "=="; break;
1217-
case NEQ: return "!="; break;
1218-
case GT: return ">"; break;
1219-
case GTE: return ">="; break;
1220-
case LT: return "<"; break;
1221-
case LTE: return "<="; break;
1222-
case ADD: return "+"; break;
1223-
case SUB: return "-"; break;
1224-
case MUL: return "*"; break;
1225-
case DIV: return "/"; break;
1226-
case MOD: return "%"; break;
1214+
case AND: return "&&";
1215+
case OR: return "||";
1216+
case EQ: return "==";
1217+
case NEQ: return "!=";
1218+
case GT: return ">";
1219+
case GTE: return ">=";
1220+
case LT: return "<";
1221+
case LTE: return "<=";
1222+
case ADD: return "+";
1223+
case SUB: return "-";
1224+
case MUL: return "*";
1225+
case DIV: return "/";
1226+
case MOD: return "%";
12271227
// this is only used internally!
1228-
case NUM_OPS: return "[OPS]"; break;
1229-
default: return "invalid"; break;
1228+
case NUM_OPS: return "[OPS]";
1229+
default: return "invalid";
12301230
}
12311231
}
12321232
bool is_left_interpolant(void) const;
@@ -1294,10 +1294,10 @@ namespace Sass {
12941294
{ }
12951295
const std::string type_name() {
12961296
switch (optype_) {
1297-
case PLUS: return "plus"; break;
1298-
case MINUS: return "minus"; break;
1299-
case NOT: return "not"; break;
1300-
default: return "invalid"; break;
1297+
case PLUS: return "plus";
1298+
case MINUS: return "minus";
1299+
case NOT: return "not";
1300+
default: return "invalid";
13011301
}
13021302
}
13031303
virtual bool operator==(const Expression& rhs) const
@@ -3001,7 +3001,7 @@ namespace Sass {
30013001
virtual unsigned long specificity() const
30023002
{
30033003
unsigned long sum = 0;
3004-
unsigned long specificity = 0;
3004+
unsigned long specificity;
30053005
for (size_t i = 0, L = length(); i < L; ++i)
30063006
{
30073007
specificity = (*this)[i]->specificity();

src/bind.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ namespace Sass {
9595
env->local_frame()[p->name()] = arglist;
9696
Map_Obj argmap = Cast<Map>(a->value());
9797
for (auto key : argmap->keys()) {
98-
std::string name = unquote(Cast<String_Constant>(key)->value());
98+
std::string param = unquote(Cast<String_Constant>(key)->value());
9999
arglist->append(SASS_MEMORY_NEW(Argument,
100100
key->pstate(),
101101
argmap->at(key),
102-
"$" + name,
102+
"$" + param,
103103
false,
104104
false));
105105
}
@@ -205,14 +205,14 @@ namespace Sass {
205205
Map_Obj argmap = Cast<Map>(a->value());
206206

207207
for (auto key : argmap->keys()) {
208-
std::string name = "$" + unquote(Cast<String_Constant>(key)->value());
208+
std::string param = "$" + unquote(Cast<String_Constant>(key)->value());
209209

210-
if (!param_map.count(name)) {
210+
if (!param_map.count(param)) {
211211
std::stringstream msg;
212-
msg << callee << " has no parameter named " << name;
212+
msg << callee << " has no parameter named " << param;
213213
error(msg.str(), a->pstate());
214214
}
215-
env->local_frame()[name] = argmap->at(key);
215+
env->local_frame()[param] = argmap->at(key);
216216
}
217217
++ia;
218218
continue;

src/context.cpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -416,12 +416,12 @@ namespace Sass {
416416
// need one correct import
417417
bool has_import = false;
418418
// process all custom importers (or custom headers)
419-
for (Sass_Importer_Entry& importer : importers) {
419+
for (Sass_Importer_Entry& importer_ent : importers) {
420420
// int priority = sass_importer_get_priority(importer);
421-
Sass_Importer_Fn fn = sass_importer_get_function(importer);
421+
Sass_Importer_Fn fn = sass_importer_get_function(importer_ent);
422422
// skip importer if it returns NULL
423423
if (Sass_Import_List includes =
424-
fn(load_path.c_str(), importer, c_compiler)
424+
fn(load_path.c_str(), importer_ent, c_compiler)
425425
) {
426426
// get c pointer copy to iterate over
427427
Sass_Import_List it_includes = includes;
@@ -436,15 +436,15 @@ namespace Sass {
436436
// create the importer struct
437437
Importer importer(uniq_path, ctx_path);
438438
// query data from the current include
439-
Sass_Import_Entry include = *it_includes;
440-
char* source = sass_import_take_source(include);
441-
char* srcmap = sass_import_take_srcmap(include);
442-
size_t line = sass_import_get_error_line(include);
443-
size_t column = sass_import_get_error_column(include);
444-
const char *abs_path = sass_import_get_abs_path(include);
439+
Sass_Import_Entry include_ent = *it_includes;
440+
char* source = sass_import_take_source(include_ent);
441+
char* srcmap = sass_import_take_srcmap(include_ent);
442+
size_t line = sass_import_get_error_line(include_ent);
443+
size_t column = sass_import_get_error_column(include_ent);
444+
const char *abs_path = sass_import_get_abs_path(include_ent);
445445
// handle error message passed back from custom importer
446446
// it may (or may not) override the line and column info
447-
if (const char* err_message = sass_import_get_error_message(include)) {
447+
if (const char* err_message = sass_import_get_error_message(include_ent)) {
448448
if (source || srcmap) register_resource({ importer, uniq_path }, { source, srcmap }, &pstate);
449449
if (line == std::string::npos && column == std::string::npos) error(err_message, pstate);
450450
else error(err_message, ParserState(ctx_path, source, Position(line, column)));
@@ -696,10 +696,8 @@ namespace Sass {
696696
char* Context::render_srcmap()
697697
{
698698
if (source_map_file == "") return 0;
699-
char* result = 0;
700699
std::string map = emitter.render_srcmap(*this);
701-
result = sass_copy_c_string(map.c_str());
702-
return result;
700+
return sass_copy_c_string(map.c_str());
703701
}
704702

705703

0 commit comments

Comments
 (0)