]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/dimen.cc
patch::: 0.1.31.jcn1: minder ugh
[lilypond.git] / lily / dimen.cc
index 9489ae9a1eef6d7f1e66275776037c1badf93d24..5e85f4992d5b0157bc798ea4dff7d589c3a7d10b 100644 (file)
@@ -4,36 +4,37 @@
 #include "string.hh"
 
 Real
-parse_dimen(String dim)
+parse_dimen (String dim)
 {
-    int i=dim.length_i()-1;
-    const char *s = dim;
-    while  (i > 0 && (isspace(s[i]) || isalpha(s[i])) ){
-       i--;
+  int i=dim.length_i()-1;
+  char const *s = dim.ch_C ();
+  while  (i > 0 && (isspace (s[i]) || isalpha (s[i])))
+    {
+      i--;
     }
-    String unit(s + i+1);
-    return convert_dimen(dim.value_f(), unit); 
+  String unit (s + i+1);
+  return convert_dimen (dim.value_f(), unit);
 }
 
 
 Real
-convert_dimen(Real quant, String unit)
+convert_dimen (Real quant, String unit)
 {
-    if (unit == "cm")
-       return quant * CM_TO_PT;
-    if (unit == "pt")
-       return quant;
-    if (unit == "mm")
-       return quant*CM_TO_PT/10;
-    if (unit == "in")
-       return quant * INCH_TO_PT;
-    error ("unknown length unit: `" + unit+"'");
+  if (unit == "cm")
+    return quant * CM_TO_PT;
+  if (unit == "pt")
+    return quant;
+  if (unit == "mm")
+    return quant*CM_TO_PT/10;
+  if (unit == "in")
+    return quant * INCH_TO_PT;
+  error (_("unknown length unit: `") + unit+"'");
 }
 
 String
-print_dimen(Real r)
+print_dimen (Real r)
 {
-    String s(r);
-    s += "pt ";
-    return s;
+  String s (r, "%.3f");
+  s += "pt ";
+  return s;
 }