From 05e2a6ded3024718a62e367d28d6fca200faf3d0 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 14 Feb 2012 02:26:50 -0800 Subject: * eval.c (rangev_func, rangev, range_star_v_func, range_star_v): Regression: handle the case where the range is open-ended (to is nil). --- ChangeLog | 6 ++++++ eval.c | 14 ++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index c84ac72c..dff37529 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2012-02-14 Kaz Kylheku + + * eval.c (rangev_func, rangev, range_star_v_func, + range_star_v): Regression: handle the case where the range is + open-ended (to is nil). + 2012-02-14 Kaz Kylheku * eval.c (rangev): If a descending range is specified, diff --git a/eval.c b/eval.c index aab3623a..efdc22db 100644 --- a/eval.c +++ b/eval.c @@ -1673,8 +1673,9 @@ static val rangev_func(val env, val lcons) rplaca(lcons, from); if (eql(from, to) || - (lt(from, to) && gt(next, to)) || - (gt(from, to) && lt(next, to))) + (to && + ((lt(from, to) && gt(next, to)) || + (gt(from, to) && lt(next, to))))) { rplacd(lcons, nil); return nil; @@ -1690,7 +1691,7 @@ static val rangev(val args) uses_or2; val from = or2(first(args), zero); val to = second(args); - val step = or2(third(args), if3(le(from, to), one, negone)); + val step = or2(third(args), if3(to && gt(from, to), negone, one)); val env = cons(from, cons(to, step)); return make_lazy_cons(func_f1(env, rangev_func)); @@ -1707,8 +1708,9 @@ static val range_star_v_func(val env, val lcons) rplaca(lcons, from); if (eql(next, to) || - (lt(from, to) && gt(next, to)) || - (gt(from, to) && lt(next, to))) + (to && + ((lt(from, to) && gt(next, to)) || + (gt(from, to) && lt(next, to))))) { rplacd(lcons, nil); return nil; @@ -1728,7 +1730,7 @@ static val range_star_v(val args) if (eql(from, to)) { return nil; } else { - val step = or2(third(args), if3(le(from, to), one, negone)); + val step = or2(third(args), if3(to && gt(from, to), negone, one)); val env = cons(from, cons(to, step)); return make_lazy_cons(func_f1(env, range_star_v_func)); -- cgit v1.2.3