From b2f22a54346df45ab24d83e1228700649f62d63c Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Thu, 6 Jan 2005 05:29:46 +0000 Subject: [PATCH] Fix assertion for proper Huffman merge pattern: 0 == 1 modulo 1. --- src/ChangeLog | 9 +++++++-- src/sort.c | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 39ba57a4..2e1ecee5 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +Wed Jan 5 21:23:31 2005 Ben Pfaff + + * sort.c: (merge) Fix assertion for proper Huffman merge pattern: + 0 == 1 modulo 1. See Knuth 5.4.9 (vol. 3, 2nd ed., + pp. 361). Thanks to John Darrington for + reporting the bug. + Wed Jan 5 22:42:26 WST 2005 John Darrington * case.h Fixed bug # 11307 @@ -159,7 +166,6 @@ Tue Nov 16 13:19:18 WST 2004 John Darrington * permissions.c command.def Added the PERMISSIONS command ->>>>>>> 1.110 Mon Nov 15 01:33:32 2004 Ben Pfaff * q2c.c: (dump_header) Don't try to emit #includes at very top of @@ -386,7 +392,6 @@ Mon Nov 15 00:30:33 2004 Ben Pfaff (var_dtor_free) New function. (discard_variables) Use NULL instead of inline_file. ->>>>>>> 1.106 Fri Nov 12 10:07:11 WST 2004 John Darrington * value-labs.c Fixed the implmentation of value_to_string, so diff --git a/src/sort.c b/src/sort.c index 33c5651d..5a6cf6a1 100644 --- a/src/sort.c +++ b/src/sort.c @@ -752,7 +752,7 @@ merge (struct external_sort *xsrt) make_heap (xsrt->initial_runs, xsrt->run_cnt, sizeof *xsrt->initial_runs, compare_initial_runs, NULL); dummy_run_cnt = mod (1 - (int) xsrt->run_cnt, max_order - 1); - assert (max_order == 1 + assert (max_order == 2 || (xsrt->run_cnt + dummy_run_cnt) % (max_order - 1) == 1); while (xsrt->run_cnt > 1) { -- 2.30.2