diff options
author | Karl Berry <karl@freefriends.org> | 2018-01-17 22:50:15 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-01-17 22:50:15 +0000 |
commit | e7dfe5ab98e759081fc73990ed6c1ac6910a105d (patch) | |
tree | 1635f79c86856a6aa57a45b8b952b651ef9fcba9 /Build/source/texk/dvisvgm/dvisvgm-src/src/XMLString.cpp | |
parent | ae542350b1e3add10d4ee3d7b68f610132f31a50 (diff) |
dvisvgm 2.3.1 (patched)
git-svn-id: svn://tug.org/texlive/trunk@46352 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/dvisvgm/dvisvgm-src/src/XMLString.cpp')
-rw-r--r-- | Build/source/texk/dvisvgm/dvisvgm-src/src/XMLString.cpp | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/XMLString.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/XMLString.cpp index e23df4b7656..9c52064f1f1 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/XMLString.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/XMLString.cpp @@ -2,7 +2,7 @@ ** XMLString.cpp ** ** ** ** This file is part of dvisvgm -- a fast DVI to SVG converter ** -** Copyright (C) 2005-2017 Martin Gieseking <martin.gieseking@uos.de> ** +** Copyright (C) 2005-2018 Martin Gieseking <martin.gieseking@uos.de> ** ** ** ** This program is free software; you can redistribute it and/or ** ** modify it under the terms of the GNU General Public License as ** @@ -18,11 +18,8 @@ ** along with this program; if not, see <http://www.gnu.org/licenses/>. ** *************************************************************************/ -#include <config.h> #include <cmath> #include <cstdlib> -#include <iomanip> -#include <sstream> #include "Unicode.hpp" #include "XMLString.hpp" @@ -47,7 +44,7 @@ XMLString::XMLString (const string &str, bool plain) { assign(str); else { for (char c : str) - *this += translate(c); + append(translate(c)); } } @@ -58,20 +55,15 @@ XMLString::XMLString (const char *str, bool plain) { assign(str); else { while (*str) - *this += translate(*str++); + append(translate(*str++)); } } } -XMLString::XMLString (int n, bool cast) { - if (cast) { - stringstream ss; - ss << n; - ss >> *this; - } - else - *this += translate(n); +XMLString::XMLString (int n, bool cast) + : string(cast ? to_string(n) : translate(n)) +{ } @@ -90,14 +82,21 @@ static inline double round (double x, int n) { XMLString::XMLString (double x) { - stringstream ss; if (DECIMAL_PLACES > 0) { // don't use fixed and setprecision() manipulators here to avoid // banker's rounding applied in some STL implementations x = round(x, DECIMAL_PLACES); } - if (std::abs(x) < 1e-7) + if (std::abs(x) < 1e-6) x = 0; - ss << x; - ss >> *this; + assign(to_string(x)); + size_t pos = find('.'); + if (pos != string::npos) { + pos = find_last_not_of('0'); + if (pos != string::npos) { + erase(pos+1); // remove trailing zeros + if (at(length()-1) == '.') + pop_back(); // remove trailing dot + } + } } |