Skip to content

Commit

Permalink
Merge pull request sass#226 from nschonni/nth-unsigned-comparison
Browse files Browse the repository at this point in the history
Remove negative check of unsigned int
  • Loading branch information
Aaron Leung committed Jan 13, 2014
2 parents 9e57bdf + 05db8a7 commit 9b444f4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -790,13 +790,14 @@ namespace Sass {
{
List* l = dynamic_cast<List*>(env["$list"]);
Number* n = ARG("$n", Number);
if (n->value() == 0) error("argument `$n` of `" + string(sig) + "` must be non-zero", path, position);
if (!l) {
l = new (ctx.mem) List(path, position, 1);
*l << ARG("$list", Expression);
}
if (l->empty()) error("argument `$list` of `" + string(sig) + "` must not be empty", path, position);
size_t index = std::floor(n->value() < 0 ? l->length() + n->value() : n->value() - 1);
if (index < 0 || index > l->length() - 1) error("index out of bounds for `" + string(sig) + "`", path, position);
if (index > l->length() - 1) error("index out of bounds for `" + string(sig) + "`", path, position);
return l->value_at_index(index);
}

Expand Down

0 comments on commit 9b444f4

Please sign in to comment.