summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lexer.l8
-rw-r--r--src/printutils.cc22
-rw-r--r--src/printutils.h3
-rw-r--r--src/transform.cc4
-rw-r--r--src/value.cc2
5 files changed, 38 insertions, 1 deletions
diff --git a/src/lexer.l b/src/lexer.l
index 63b0047..4dff654 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 a8b62aa..698fffb 100644
--- a/src/printutils.cc
+++ b/src/printutils.cc
@@ -1,4 +1,5 @@
#include "printutils.h"
+#include <sstream>
#include <stdio.h>
std::list<std::string> 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 9d99a19..439c884 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 0f678c5..d94e0d4 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 <sstream>
#include <vector>
#include <assert.h>
@@ -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 7744a18..98a7eca 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>
@@ -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.
contact: Jan Huwald // Impressum