diff options
Diffstat (limited to 'src/value.cc')
-rw-r--r-- | src/value.cc | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/value.cc b/src/value.cc index 7744a18..f14f826 100644 --- a/src/value.cc +++ b/src/value.cc @@ -25,6 +25,7 @@ */ #include "value.h" +#include "printutils.h" #include <stdio.h> #include <math.h> #include <assert.h> @@ -38,7 +39,7 @@ std::ostream &operator<<(std::ostream &stream, const Filename &filename) { - stream << QuotedString(QDir::current().relativeFilePath(QString::fromStdString(filename)).toStdString()); + stream << QuotedString(QDir::current().relativeFilePath(QString::fromLocal8Bit(filename.c_str())).toLocal8Bit().constData()); return stream; } @@ -196,15 +197,18 @@ public: size_t dotpos = tmpstr.find('.'); if (dotpos != std::string::npos) { if (tmpstr.size() - dotpos > 12) tmpstr.erase(dotpos + 12); + while (tmpstr[tmpstr.size()-1] == '0') tmpstr.erase(tmpstr.size()-1); } + if ( tmpstr.compare("-0") == 0 ) tmpstr = "0"; + tmpstr = two_digit_exp_format( tmpstr ); return tmpstr; #else - // attempt to emulate Qt's QString.sprintf("%g"); from old OpenSCAD. - // see https://github.com/openscad/openscad/issues/158 - std::stringstream tmp; - tmp.unsetf(std::ios::floatfield); - tmp << op1; - return tmp.str(); + // attempt to emulate Qt's QString.sprintf("%g"); from old OpenSCAD. + // see https://github.com/openscad/openscad/issues/158 + std::stringstream tmp; + tmp.unsetf(std::ios::floatfield); + tmp << op1; + return tmp.str(); #endif } |