X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Flilypond-version.cc;h=9c0e938547d6d4c0381a50272e29bb60ca1acdbf;hb=ba8a253a14cfcbd757fef0ad36232d371b88d23b;hp=385497271452b545ac6f75f85611aba39cf804c0;hpb=b11e28c777fdee74bbe9fce9349ea37a029a06e3;p=lilypond.git diff --git a/lily/lilypond-version.cc b/lily/lilypond-version.cc index 3854972714..9c0e938547 100644 --- a/lily/lilypond-version.cc +++ b/lily/lilypond-version.cc @@ -1,47 +1,58 @@ /* - 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 - + (c) 1998--2007 Jan Nieuwenhuizen */ -#include "lilypond-input-version.hh" +#include + +#include "lilypond-version.hh" #include "string-convert.hh" -#include "array.hh" +#include "misc.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) { - Array version; - version = String_convert::split (str, '.'); + major_ = 0; + minor_ = 0; + patch_ = 0; + + vector version; + version = string_split (str, '.'); + + if (version.size () > 0 && isdigit (version[0][0])) + major_ = String_convert::dec2int (version[0]); + if (version.size () > 1 && isdigit (version[1][0])) + minor_ = String_convert::dec2int (version[1]); - major_ = version[0].to_int (); - minor_ = version[1].to_int (); patch_ = 0; - if (version.size () >= 3) - patch_ = version[2].to_int (); + if (version.size () >= 3 + && isdigit (version[2][0])) + patch_ = String_convert::dec2int (version[2]); if (version.size () >= 4) extra_patch_string_ = version[3]; } -String -LilyPond_version::to_string () const +string +Lilypond_version::to_string () const { - return ::to_string (major_) + "." + ::to_string (minor_) + "." + ::to_string (patch_); + 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_; }