Skip to content
This repository was archived by the owner on Oct 24, 2025. It is now read-only.

Commit ab3485d

Browse files
committed
Fixup a bit more
1 parent 37456e9 commit ab3485d

File tree

6 files changed

+43
-8
lines changed

6 files changed

+43
-8
lines changed

src/ast_values.cpp

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ namespace Sass {
7676
}
7777
return true;
7878
}
79+
if (auto m = Cast<Map>(&rhs)) {
80+
return m->empty() && empty();
81+
}
7982
return false;
8083
}
8184

@@ -458,18 +461,44 @@ namespace Sass {
458461
}
459462
// ensure both have same units
460463
l.normalize(); r.normalize();
461-
Units &lhs_unit = l, &rhs_unit = r;
464+
Units& lhs_unit = l, & rhs_unit = r;
462465
if (!(lhs_unit == rhs_unit)) {
463466
/* ToDo: do we always get usefull backtraces? */
464467
throw Exception::IncompatibleUnits(*this, rhs);
465468
}
466469
if (lhs_unit == rhs_unit) {
467470
return l.value() < r.value();
468-
} else {
471+
}
472+
else {
469473
return lhs_unit < rhs_unit;
470474
}
471475
}
472476

477+
bool Number::operator> (const Number& rhs) const
478+
{
479+
// unitless or only having one unit are equivalent (3.4)
480+
// therefore we need to reduce the units beforehand
481+
Number l(*this), r(rhs); l.reduce(); r.reduce();
482+
size_t lhs_units = l.numerators.size() + l.denominators.size();
483+
size_t rhs_units = r.numerators.size() + r.denominators.size();
484+
if (!lhs_units || !rhs_units) {
485+
return l.value() > r.value();
486+
}
487+
// ensure both have same units
488+
l.normalize(); r.normalize();
489+
Units& lhs_unit = l, & rhs_unit = r;
490+
if (!(lhs_unit == rhs_unit)) {
491+
/* ToDo: do we always get usefull backtraces? */
492+
throw Exception::IncompatibleUnits(*this, rhs);
493+
}
494+
if (lhs_unit == rhs_unit) {
495+
return l.value() > r.value();
496+
}
497+
else {
498+
return lhs_unit > rhs_unit;
499+
}
500+
}
501+
473502
/////////////////////////////////////////////////////////////////////////
474503
/////////////////////////////////////////////////////////////////////////
475504

src/ast_values.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ namespace Sass {
247247
size_t hash() const override;
248248

249249
bool operator< (const Number& rhs) const;
250+
bool operator> (const Number& rhs) const;
250251
bool operator== (const Number& rhs) const;
251252

252253

src/eval.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,7 @@ namespace Sass {
10281028
Arguments_Obj args = c->arguments();
10291029

10301030
Env* env = environment();
1031-
if (!env->has(full_name) /* || (!c->via_call() && Prelexer::re_special_fun(name.c_str()))*/) {
1031+
if (!c->func() && !env->has(full_name) /* || (!c->via_call() && Prelexer::re_special_fun(name.c_str()))*/) {
10321032
if (!env->has("*[f]")) {
10331033
for (Argument_Obj arg : args->elements()) {
10341034
if (List_Obj ls = Cast<List>(arg->value())) {

src/file.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,12 +236,16 @@ namespace Sass {
236236
{
237237
// magic algorith goes here!!
238238

239-
// if the file is outside this directory show the absolute path
239+
// std::cerr << "rel " << rel_path << "\n";
240+
// std::cerr << "abs " << abs_path << "\n";
241+
// std::cerr << "pstate " << orig_path << "\n";
242+
243+
// if the file is outside this directory show the absolute path
240244
if (rel_path.substr(0, 3) == "../") {
241245
return orig_path;
242246
}
243247
// this seems to work most of the time
244-
return abs_path == orig_path ? abs_path : rel_path;
248+
return abs_path == orig_path ? rel_path : rel_path;
245249
}
246250

247251
// create an absolute path by resolving relative paths with cwd

src/fn_miscs.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "ast.hpp"
22
#include "expand.hpp"
3+
#include "debugger.hpp"
34
#include "fn_utils.hpp"
45
#include "fn_miscs.hpp"
56
#include "util_string.hpp"
@@ -139,7 +140,7 @@ namespace Sass {
139140
FunctionExpressionObj func = SASS_MEMORY_NEW(FunctionExpression, pstate, name, args, "");
140141

141142
Expand expand(ctx, &d_env, &selector_stack, &original_stack);
142-
func->via_call(true); // calc invoke is allowed
143+
// func->via_call(true); // calc invoke is allowed
143144
if (ff) func->func(ff);
144145
return Cast<PreValue>(func->perform(&expand.eval));
145146
}
@@ -231,7 +232,7 @@ namespace Sass {
231232
}
232233

233234

234-
if (!d_env.has_global(full_name)) {
235+
if (!d_env.has(full_name)) {
235236
error("Function not found: " + name, pstate, traces);
236237
}
237238

src/fn_numbers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ namespace Sass {
138138
error(val->to_string(ctx.c_options) + " is not a number.", val->pstate(), traces);
139139
}
140140
if (greatest) {
141-
if (*greatest < *xi) greatest = xi;
141+
if (*xi > *greatest) greatest = xi;
142142
} else greatest = xi;
143143
}
144144
return greatest.detach();

0 commit comments

Comments
 (0)