]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/tuplet-bracket.cc
Use signed arithmetic to avoid overflow.
[lilypond.git] / lily / tuplet-bracket.cc
index abc559ab051b3942c941988e9cae856fc2bc94da..9935e87735bac3b19da290bad07010e0b1367b34 100644 (file)
@@ -276,15 +276,15 @@ Tuplet_bracket::print (SCM smob)
   bool equally_long = false;
   Grob *par_beam = parallel_beam (me, columns, &equally_long);
 
   bool equally_long = false;
   Grob *par_beam = parallel_beam (me, columns, &equally_long);
 
-  bool bracket_visibility = ! (par_beam && equally_long); // Flag, print/don't print tuplet bracket.
+  bool bracket_visibility = !(par_beam && equally_long); // Flag, print/don't print tuplet bracket.
   /*
     FIXME: The type of this prop is sucky.
   */
   SCM bracket_vis_prop = me->get_property ("bracket-visibility");
   /*
     FIXME: The type of this prop is sucky.
   */
   SCM bracket_vis_prop = me->get_property ("bracket-visibility");
-  bool bracket_prop = to_boolean (bracket_vis_prop); // Flag, user has set bracket-visibility prop.
+  bool bracket_prop = ly_scm2bool (bracket_vis_prop); // Flag, user has set bracket-visibility prop.
   bool bracket = (bracket_vis_prop == ly_symbol2scm ("if-no-beam"));
   bool bracket = (bracket_vis_prop == ly_symbol2scm ("if-no-beam"));
-  if (bracket_prop)
-    bracket_visibility = true;
+  if (scm_is_bool (bracket_vis_prop))
+    bracket_visibility = bracket_prop;
   else if (bracket)
     bracket_visibility = !par_beam;
 
   else if (bracket)
     bracket_visibility = !par_beam;
 
@@ -302,7 +302,7 @@ Tuplet_bracket::print (SCM smob)
       the bracket, but still let the number be displayed.
       Only do this if the user has not explicitly specified bracket-visibility = #t.
   */
       the bracket, but still let the number be displayed.
       Only do this if the user has not explicitly specified bracket-visibility = #t.
   */
-  if (!bracket_prop
+  if (!to_boolean (bracket_vis_prop)
       && (robust_scm2moment (me->get_bound (LEFT)->get_column ()->get_property ("when"), Moment (0))
          == robust_scm2moment (me->get_bound (RIGHT)->get_column ()->get_property ("when"), Moment (0))))
     bracket_visibility = false;
       && (robust_scm2moment (me->get_bound (LEFT)->get_column ()->get_property ("when"), Moment (0))
          == robust_scm2moment (me->get_bound (RIGHT)->get_column ()->get_property ("when"), Moment (0))))
     bracket_visibility = false;
@@ -322,7 +322,7 @@ Tuplet_bracket::print (SCM smob)
     Don't print the bracket when it would be smaller than the number.
     ...Unless the user has coded bracket-visibility = #t, that is.
   */
     Don't print the bracket when it would be smaller than the number.
     ...Unless the user has coded bracket-visibility = #t, that is.
   */
-  Real gap = 0.0;
+  Real gap = 0.;
   if (bracket_visibility && number_grob)
     {
       Interval ext = number_grob->extent (number_grob, X_AXIS);
   if (bracket_visibility && number_grob)
     {
       Interval ext = number_grob->extent (number_grob, X_AXIS);
@@ -500,8 +500,7 @@ Tuplet_bracket::get_bounds (Grob *me, Grob **left, Grob **right)
 
 /*
   use first -> last note for slope, and then correct for disturbing
 
 /*
   use first -> last note for slope, and then correct for disturbing
-  notes in between.
-*/
+  notes in between.  */
 void
 Tuplet_bracket::calc_position_and_height (Grob *me_grob, Real *offset, Real *dy)
 {
 void
 Tuplet_bracket::calc_position_and_height (Grob *me_grob, Real *offset, Real *dy)
 {
@@ -522,11 +521,9 @@ Tuplet_bracket::calc_position_and_height (Grob *me_grob, Real *offset, Real *dy)
   Interval staff;
   Grob *st = Staff_symbol_referencer::get_staff_symbol (me);
 
   Interval staff;
   Grob *st = Staff_symbol_referencer::get_staff_symbol (me);
 
-  /*
-    staff-padding doesn't work correctly on cross-staff tuplets
-    because it only considers one staff symbol. Until this works,
-    disable it.
-  */
+  /* staff-padding doesn't work correctly on cross-staff tuplets
+     because it only considers one staff symbol. Until this works,
+     disable it. */
   if (st && !to_boolean (me->get_property ("cross-staff")))
     {
       Real pad = robust_scm2double (me->get_property ("staff-padding"), -1.0);
   if (st && !to_boolean (me->get_property ("cross-staff")))
     {
       Real pad = robust_scm2double (me->get_property ("staff-padding"), -1.0);
@@ -548,7 +545,7 @@ Tuplet_bracket::calc_position_and_height (Grob *me_grob, Real *offset, Real *dy)
   Real x1 = robust_relative_extent (rgr, commonx, X_AXIS)[RIGHT];
   bool follow_beam = par_beam
     && get_grob_direction (par_beam) == dir
   Real x1 = robust_relative_extent (rgr, commonx, X_AXIS)[RIGHT];
   bool follow_beam = par_beam
     && get_grob_direction (par_beam) == dir
-    && ! to_boolean (par_beam->get_property ("knee"));
+    && !to_boolean (par_beam->get_property ("knee"));
 
   vector<Offset> points;
   if (columns.size ()
 
   vector<Offset> points;
   if (columns.size ()
@@ -624,7 +621,7 @@ Tuplet_bracket::calc_position_and_height (Grob *me_grob, Real *offset, Real *dy)
     }
 
   /*
     }
 
   /*
-    This is a slight hack.  We compute two encompass points from the
+    This is a slight hack. We compute two encompass points from the
     bbox of the smaller tuplets.
 
     We assume that the smaller bracket is 1.0 space high.
     bbox of the smaller tuplets.
 
     We assume that the smaller bracket is 1.0 space high.