From d5019a964e376e8ad0ad398cc4cfb3d97509402d Mon Sep 17 00:00:00 2001 From: don bright Date: Wed, 13 Feb 2013 22:55:19 -0600 Subject: [PATCH] deal with test suite issues under mingw-cross compile and wine --- src/lexer.l | 8 ++++++++ src/printutils.cc | 22 ++++++++++++++++++++++ src/printutils.h | 3 +++ src/transform.cc | 4 +++- src/value.cc | 2 ++ 5 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/lexer.l b/src/lexer.l index 63b00474..4dff654a 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -225,6 +225,14 @@ void includefile() finfo = locate_file((fs::path(filepath) / filename).string()); } + if (!exists(finfo) || finfo.empty()) { + // deal with some unusual situations with is_absolute() and Wine + fs::path fnp( fs::path(filepath) / filename ); + if (fs::exists( fnp ) && !fs::is_directory( fnp )) { + finfo = fnp; + } + } + if (finfo.empty()) { PRINTB("WARNING: Can't find 'include' file '%s'.", filename); } diff --git a/src/printutils.cc b/src/printutils.cc index a8b62aa2..698fffb9 100644 --- a/src/printutils.cc +++ b/src/printutils.cc @@ -1,4 +1,5 @@ #include "printutils.h" +#include #include std::list print_messages_stack; @@ -49,3 +50,24 @@ void PRINT_NOCACHE(const std::string &msg) outputhandler(msg, outputhandler_data); } } + +std::string two_digit_exp_format( std::string doublestr ) +{ +#ifdef _WIN32 + size_t exppos = doublestr.find('e'); + if ( exppos != std::string::npos) { + exppos += 2; + if ( doublestr[exppos] == '0' ) doublestr.erase(exppos,1); + } +#endif + return doublestr; +} + +std::string two_digit_exp_format( double x ) +{ + std::stringstream s; + s << x; + return two_digit_exp_format( s.str() ); +} + + diff --git a/src/printutils.h b/src/printutils.h index 9d99a19f..439c8843 100644 --- a/src/printutils.h +++ b/src/printutils.h @@ -22,6 +22,9 @@ void PRINT(const std::string &msg); void PRINT_NOCACHE(const std::string &msg); #define PRINTB_NOCACHE(_fmt, _arg) do { PRINT_NOCACHE(str(boost::format(_fmt) % _arg)); } while (0) +std::string two_digit_exp_format( std::string doublestr ); +std::string two_digit_exp_format( double x ); + // extremely simple logging, eventually replace with something like boost.log // usage: logstream out(5); openscad_loglevel=6; out << "hi"; static int openscad_loglevel = 0; diff --git a/src/transform.cc b/src/transform.cc index 0f678c5e..d94e0d4f 100644 --- a/src/transform.cc +++ b/src/transform.cc @@ -29,6 +29,8 @@ #include "context.h" #include "polyset.h" #include "builtin.h" +#include "value.h" +#include "printutils.h" #include #include #include @@ -189,7 +191,7 @@ std::string TransformNode::toString() const stream << "["; for (int i=0;i<4;i++) { // FIXME: The 0 test is to avoid a leading minus before a single 0 (cosmetics) - stream << ((this->matrix(j, i)==0)?0:this->matrix(j, i)); + stream << two_digit_exp_format((this->matrix(j, i)==0)?0:this->matrix(j, i)); if (i != 3) stream << ", "; } stream << "]"; diff --git a/src/value.cc b/src/value.cc index 7744a187..98a7ecaa 100644 --- a/src/value.cc +++ b/src/value.cc @@ -25,6 +25,7 @@ */ #include "value.h" +#include "printutils.h" #include #include #include @@ -197,6 +198,7 @@ public: if (dotpos != std::string::npos) { if (tmpstr.size() - dotpos > 12) tmpstr.erase(dotpos + 12); } + tmpstr = two_digit_exp_format( tmpstr ); return tmpstr; #else // attempt to emulate Qt's QString.sprintf("%g"); from old OpenSCAD.