From 2546a959c920d3df18271f9a9aed42bf574df3c1 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Wed, 8 Jun 2016 10:27:17 +0200 Subject: Store rest of string in Inkscape version ('pre' 'devel'). Fix try/catch blocks by really throwing errors. (stringstream doesn't throw errors by default.) (bzr r14962) --- src/version.cpp | 12 ++++++++++-- src/version.h | 3 +++ 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/version.cpp b/src/version.cpp index abe855ee7..7610cd8e7 100644 --- a/src/version.cpp +++ b/src/version.cpp @@ -21,28 +21,36 @@ bool sp_version_from_string(const char *string, Inkscape::Version *version) if (!string) { return false; } - + try { std::stringstream ss; + + // Throw exception if error. + ss.exceptions(std::ios::failbit | std::ios::badbit); ss << string; ss >> version->_major; char tmp=0; ss >> tmp; ss >>version->_minor; + + // Don't throw exception if failbit gets set (empty string OK). + ss.exceptions(std::ios::goodbit); + getline(ss, version->_tail); return true; } catch(...) { version->_major = 0; version->_minor = 0; + version->_tail.clear(); return false; } } char *sp_version_to_string(Inkscape::Version version) { - return g_strdup_printf("%u.%u", version._major, version._minor); + return g_strdup_printf("%u.%u%s", version._major, version._minor, version._tail.c_str()); } bool sp_version_inside_range(Inkscape::Version version, diff --git a/src/version.h b/src/version.h index e17688b6d..f6221f6a6 100644 --- a/src/version.h +++ b/src/version.h @@ -13,6 +13,8 @@ #define SVG_VERSION "1.1" +#include + namespace Inkscape { class Version { @@ -43,6 +45,7 @@ public: unsigned int _major; unsigned int _minor; + std::string _tail; // Development version }; } -- cgit v1.2.3