]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/lilypond-version.cc
* The grand 2005-2006 replace.
[lilypond.git] / lily / lilypond-version.cc
index 385497271452b545ac6f75f85611aba39cf804c0..93a5ceba88128a47263880af2f635478f5ee6805 100644 (file)
@@ -1,32 +1,41 @@
 /*
-  lilypond-version.cc -- implement LilyPond_version
+  lilypond-version.cc -- implement Lilypond_version
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1998--2003 Jan Nieuwenhuizen <janneke@gnu.org>
-
+  (c) 1998--2006 Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
+#include <ctype.h>
+
 #include "lilypond-input-version.hh"
 #include "string-convert.hh"
 #include "array.hh"
 
-LilyPond_version::LilyPond_version (int major, int minor, int patch)
+Lilypond_version::Lilypond_version (int major, int minor, int patch)
 {
   major_ = major;
   minor_ = minor;
   patch_ = patch;
 }
 
-LilyPond_version::LilyPond_version (String str)
+Lilypond_version::Lilypond_version (String str)
 {
+  major_ = 0; 
+  minor_ = 0;
+  patch_ = 0;
+  
   Array<String> version;
   version = String_convert::split (str, '.');
+
+  if (version.size () > 0 && isdigit (version[0][0]))
+    major_ = version[0].to_int ();
+  if (version.size () > 1 && isdigit (version[1][0]))
+    minor_ = version[1].to_int ();
   
-  major_ = version[0].to_int ();
-  minor_ = version[1].to_int ();
   patch_ = 0;
-  if (version.size () >= 3)
+  if (version.size () >= 3
+      && isdigit (version[2][0]))
     patch_ = version[2].to_int ();
 
   if (version.size () >= 4)
@@ -34,14 +43,14 @@ LilyPond_version::LilyPond_version (String str)
 }
 
 String
-LilyPond_version::to_string () const
+Lilypond_version::to_string () const
 {
   return ::to_string (major_) + "." + ::to_string (minor_) + "." + ::to_string (patch_);
 }
 
-LilyPond_version::operator int () const
+Lilypond_version::operator int () const
 {
-    // ugh
+  // ugh
   return 100000 * major_ + 1000 * minor_ + patch_;
 }