X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Flilypond-version.cc;h=6479f0a91cfd70ce4d2cbcf83e2c75c91963871d;hb=72c639c7ba83e2550cc2dbb0f0d1914563220e61;hp=ca293c9a784276c6cafb0ae08aa93ac5876ceaa7;hpb=f2d6ea6c952ab8f8651f95cdc1bc45716e4d3cc8;p=lilypond.git diff --git a/lily/lilypond-version.cc b/lily/lilypond-version.cc index ca293c9a78..6479f0a91c 100644 --- a/lily/lilypond-version.cc +++ b/lily/lilypond-version.cc @@ -3,10 +3,11 @@ source file of the GNU LilyPond music typesetter - (c) 1998--2003 Jan Nieuwenhuizen - + (c) 1998--2005 Jan Nieuwenhuizen */ +#include + #include "lilypond-input-version.hh" #include "string-convert.hh" #include "array.hh" @@ -20,13 +21,21 @@ Lilypond_version::Lilypond_version (int major, int minor, int patch) Lilypond_version::Lilypond_version (String str) { + major_ = 0; + minor_ = 0; + patch_ = 0; + Array 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) @@ -41,7 +50,7 @@ Lilypond_version::to_string () const Lilypond_version::operator int () const { - // ugh + // ugh return 100000 * major_ + 1000 * minor_ + patch_; }