]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/optimal-page-breaking.cc
Run grand replace for 2015.
[lilypond.git] / lily / optimal-page-breaking.cc
index 8142c39f7a5be34ea8fa2e0ec76d100e4e9f4241..4bcf05f8e49e71604b3f4d62229dac5470b98a2c 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 2006--2012 Joe Neeman <joeneeman@gmail.com>
+  Copyright (C) 2006--2015 Joe Neeman <joeneeman@gmail.com>
 
   LilyPond is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -51,7 +51,7 @@ Optimal_page_breaking::solve ()
   vsize page_count = robust_scm2int (forced_page_count, 1);
   Line_division ideal_line_division = current_configuration (0);
   Line_division best_division = ideal_line_division;
-  int min_sys_count = 1;
+  vsize min_sys_count = 1;
 
   // Note that system_count () only counts non-title systems.
   vsize ideal_sys_count = system_count ();
@@ -75,7 +75,9 @@ Optimal_page_breaking::solve ()
           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, 1);
+          if (min_sys_count > ideal_sys_count  // subtraction wrapped around
+              || min_sys_count <= 0)
+            min_sys_count = 1;
         }
     }
   else
@@ -117,7 +119,7 @@ Optimal_page_breaking::solve ()
 
   /* try a smaller number of systems than the ideal number for line breaking */
   Line_division bound = ideal_line_division;
-  for (vsize sys_count = ideal_sys_count + 1; --sys_count >= (vsize) min_sys_count;)
+  for (vsize sys_count = ideal_sys_count + 1; --sys_count >= min_sys_count;)
     {
       Page_spacing_result best_for_this_sys_count;
       set_current_breakpoints (0, end, sys_count, Line_division (), bound);