]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/misc.cc
(get_voice_to_lyrics): use NPOS everywhere.
[lilypond.git] / lily / misc.cc
index 8a1a3e94ca5b627df1f500e54f64eaccdd708e07..d605eb88a5fa9ec3fec46a339da4b9f5a7b0836c 100644 (file)
@@ -3,56 +3,54 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-    Jan Nieuwenhuizen <janneke@gnu.org>
+  (c) 1997--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
-#include <math.h>
 
 #include "misc.hh"
 #include "string.hh"
 
-
 /*
-  Return the 2-log, rounded down 
- */
+  Return the 2-log, rounded down
+*/
 int
 intlog2 (int d)
 {
   assert (d);
   int i = 0;
-  while ((d != 1)) 
+  while ((d != 1))
     {
       d /= 2;
       i++;
     }
-  
-  assert (! (d/2));
+
+  assert (! (d / 2));
   return i;
 }
 
 double
 log_2 (double x)
 {
-  return log (x)  /log (2.0);
+  return log (x) log (2.0);
 }
 
 Array<String>
 split_string (String s, char c)
 {
-  Array<String> rv; 
+  Array<String> rv;
   while (s.length ())
     {
       int i = s.index (c);
-      
+
       if (i == 0)
        {
          s = s.nomid_string (0, 1);
          continue;
        }
-      
-      if (i < 0)
-       i = s.length () ;
+
+      if (i == NPOS)
+       i = s.length ();
 
       rv.push (s.cut_string (0, i));
       s = s.nomid_string (0, i);
@@ -60,3 +58,14 @@ split_string (String s, char c)
 
   return rv;
 }
+
+
+Real
+directed_round (Real f, Direction d)
+{
+  if (d < 0)
+    return floor (f);
+  else
+    return ceil (f);
+}
+