From 5133802c58ef432ab8b289418ee834ba480d74eb Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 23 Nov 2011 12:52:03 -0800 Subject: * lib.c (plus, minus): Fixed wrong assertion which would incorrectly fire for inputs that do not overflow. * match.c (search_form): Fixed incorrect loop test which could lead to nonterminating behavior. * RELNOTES: Updated. --- ChangeLog | 10 ++++++++++ RELNOTES | 5 +++++ lib.c | 4 ++-- match.c | 3 ++- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index e51f06ba..4101ba1c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2011-11-23 Kaz Kylheku + + * lib.c (plus, minus): Fixed wrong assertion which would incorrectly + fire for inputs that do not overflow. + + * match.c (search_form): Fixed incorrect loop test which could + lead to nonterminating behavior. + + * RELNOTES: Updated. + 2011-11-23 Kaz Kylheku Semantics change. If a variable is followed by a mixture diff --git a/RELNOTES b/RELNOTES index 9f9c16a1..3fadec42 100644 --- a/RELNOTES +++ b/RELNOTES @@ -12,6 +12,11 @@ - thus @foo bar behaves properly once again; it is not treated as foo followed by the regex / +/, ignoring the text bar. + - Infinite looping bug in negative match with longest-match semantics. + + - Bug in the overflow detection in the lib.c plus and minus function. + + (current release) TXR 042 diff --git a/lib.c b/lib.c index c1d27c97..1076bb2c 100644 --- a/lib.c +++ b/lib.c @@ -733,7 +733,7 @@ val plus(val anum, val bnum) cnum b = c_num(bnum); numeric_assert (a <= 0 || b <= 0 || NUM_MAX - b >= a); - numeric_assert (a >= 0 || b >= 0 || NUM_MIN - b >= a); + numeric_assert (a >= 0 || b >= 0 || NUM_MIN - b <= a); return num(a + b); } @@ -745,7 +745,7 @@ val minus(val anum, val bnum) numeric_assert (b != NUM_MIN || NUM_MIN == -NUM_MAX); numeric_assert (a <= 0 || -b <= 0 || NUM_MAX + b >= a); - numeric_assert (a >= 0 || -b >= 0 || NUM_MIN + b >= a); + numeric_assert (a >= 0 || -b >= 0 || NUM_MIN + b <= a); return num(a - b); } diff --git a/match.c b/match.c index 9f49657d..cc61479e 100644 --- a/match.c +++ b/match.c @@ -426,7 +426,8 @@ static val search_form(match_line_ctx *c, val needle_form, val from_end) rlcp(spec, needle_form); - for (; (from_end && ge(pos, c->pos)) || length_str_ge(c->dataline, pos); + for (; (from_end && ge(pos, c->pos)) || + (!from_end && length_str_ge(c->dataline, pos)); pos = plus(pos, step)) { cons_bind (new_bindings, new_pos, -- cgit v1.2.3