X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Foptimal-page-breaking.cc;h=4bcf05f8e49e71604b3f4d62229dac5470b98a2c;hb=90e4d7057f3857da049dfda3d130017d4719bd6b;hp=b3d5fe1f7b12d9767e9edf1975e2f8b3d258b74c;hpb=d61cf3bbdb1c6670a127ba3baddf2f04d3e34fd3;p=lilypond.git diff --git a/lily/optimal-page-breaking.cc b/lily/optimal-page-breaking.cc index b3d5fe1f7b..4bcf05f8e4 100644 --- a/lily/optimal-page-breaking.cc +++ b/lily/optimal-page-breaking.cc @@ -1,7 +1,7 @@ /* This file is part of LilyPond, the GNU music typesetter. - Copyright (C) 2006--2012 Joe Neeman + Copyright (C) 2006--2015 Joe Neeman LilyPond is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -64,12 +64,21 @@ Optimal_page_breaking::solve () best = space_systems_on_best_pages (0, first_page_num); page_count = best.systems_per_page_.size (); - min_sys_count = ideal_sys_count - best.systems_per_page_.back (); + if (page_count == 0) + { + min_sys_count = 0; + } + else + { + min_sys_count = ideal_sys_count - best.systems_per_page_.back (); - if (page_count > 1 && best.systems_per_page_[page_count - 2] > 1) - min_sys_count -= best.systems_per_page_[page_count - 2]; + if (page_count > 1 && best.systems_per_page_[page_count - 2] > 1) + min_sys_count -= best.systems_per_page_[page_count - 2]; - min_sys_count = max (min_sys_count, (vsize)1); + if (min_sys_count > ideal_sys_count // subtraction wrapped around + || min_sys_count <= 0) + min_sys_count = 1; + } } else { @@ -103,7 +112,7 @@ Optimal_page_breaking::solve () if (page_count == 1) message (_ ("Fitting music on 1 page...")); - else if (scm_is_integer (forced_page_count)) + else if (scm_is_integer (forced_page_count) || page_count == 0) message (_f ("Fitting music on %d pages...", (int)page_count)); else message (_f ("Fitting music on %d or %d pages...", (int)page_count - 1, (int)page_count)); @@ -161,8 +170,7 @@ Optimal_page_breaking::solve () } /* try a larger number of systems than the ideal line breaking number. This - is more or less C&P, but the loop bounds make it difficult to try something - like do {...} while (flip(&d) != UP). */ + is more or less C&P. */ bound = ideal_line_division; for (vsize sys_count = ideal_sys_count + 1; sys_count <= max_sys_count; sys_count++) {