diff --git a/src/setup/version.cpp b/src/setup/version.cpp index 9e42f8c..703e107 100644 --- a/src/setup/version.cpp +++ b/src/setup/version.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -164,6 +165,14 @@ std::ostream & operator<<(std::ostream & os, const version & v) { return os; } +static unsigned to_unsigned(const char * chars, size_t count) { +#if BOOST_VERSION < 105200 + return boost::lexical_cast(std::string(chars, count)); +#else + return boost::lexical_cast(chars, count); +#endif +} + void version::load(std::istream & is) { static const char digits[] = "0123456789"; @@ -205,9 +214,9 @@ void version::load(std::istream & is) { std::string version_str(legacy_version, legacy_version + ARRAY_SIZE(legacy_version)); try { - unsigned a = boost::lexical_cast(version_str.data() + 1, 1); - unsigned b = boost::lexical_cast(version_str.data() + 3, 1); - unsigned c = boost::lexical_cast(version_str.data() + 5, 2); + unsigned a = to_unsigned(version_str.data() + 1, 1); + unsigned b = to_unsigned(version_str.data() + 3, 1); + unsigned c = to_unsigned(version_str.data() + 5, 2); value = INNO_VERSION(a, b, c); } catch(boost::bad_lexical_cast) { throw version_error(); @@ -257,7 +266,7 @@ void version::load(std::istream & is) { if(a_end == std::string::npos || version_str[a_end] != '.') { continue; } - unsigned a = boost::lexical_cast(version_str.data() + a_start, + unsigned a = to_unsigned(version_str.data() + a_start, a_end - a_start); size_t b_start = a_end + 1; @@ -265,7 +274,7 @@ void version::load(std::istream & is) { if(b_end == std::string::npos || version_str[b_end] != '.') { continue; } - unsigned b = boost::lexical_cast(version_str.data() + b_start, + unsigned b = to_unsigned(version_str.data() + b_start, b_end - b_start); size_t c_start = b_end + 1; @@ -273,7 +282,7 @@ void version::load(std::istream & is) { if(c_end == std::string::npos) { continue; } - unsigned c = boost::lexical_cast(version_str.data() + c_start, + unsigned c = to_unsigned(version_str.data() + c_start, c_end - c_start); size_t d_start = c_end; @@ -289,8 +298,7 @@ void version::load(std::istream & is) { d_start++; size_t d_end = version_str.find_first_not_of(digits, d_start); if(d_end != std::string::npos && d_end != d_start) { - d = boost::lexical_cast(version_str.data() + d_start, - d_end - d_start); + d = to_unsigned(version_str.data() + d_start, d_end - d_start); } }