From 804385793dcad0400e6b7ccfe006fece27e5feac Mon Sep 17 00:00:00 2001 From: Joe Neeman Date: Wed, 24 Jan 2007 08:37:06 +0200 Subject: [PATCH] Fix off-by-one error in constrained-breaking. --- lily/constrained-breaking.cc | 2 +- lily/page-breaking.cc | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lily/constrained-breaking.cc b/lily/constrained-breaking.cc index cbc22cfc05..d01bc2ab2e 100644 --- a/lily/constrained-breaking.cc +++ b/lily/constrained-breaking.cc @@ -274,7 +274,7 @@ Constrained_breaking::get_min_systems (vsize start, vsize end) int Constrained_breaking::get_max_systems (vsize start, vsize end) { - vsize brk = (end >= start_.size ()) ? breaks_.size () - 1 : starting_breakpoints_[end]; + vsize brk = (end >= start_.size ()) ? breaks_.size () : starting_breakpoints_[end]; return brk - starting_breakpoints_[start]; } diff --git a/lily/page-breaking.cc b/lily/page-breaking.cc index b43c302367..5c81dc392c 100644 --- a/lily/page-breaking.cc +++ b/lily/page-breaking.cc @@ -75,7 +75,13 @@ void Page_breaking::break_into_pieces (vsize start_break, vsize end_break, Line_division const &div) { vector chunks = chunk_list (start_break, end_break); - assert (chunks.size () == div.size () + 1); + bool ignore_div = false; + if (chunks.size () != div.size () + 1) + { + programming_error ("did not find a valid page breaking configuration"); + ignore_div = true; + assert (0); + } for (vsize i = 0; i < chunks.size () - 1; i++) { @@ -86,7 +92,9 @@ Page_breaking::break_into_pieces (vsize start_break, vsize end_break, Line_divis vsize end; line_breaker_args (sys, chunks[i], chunks[i+1], &start, &end); - vector pos = line_breaking_[sys].get_solution (start, end, div[i]); + vector pos = ignore_div + ? line_breaking_[sys].get_best_solution (start, end) + : line_breaking_[sys].get_solution (start, end, div[i]); all_[sys].pscore_->root_system ()->break_into_pieces (pos); } } -- 2.39.2