From 5467bc94116c7e3f22210ace64e0678fff4d4347 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Tue, 23 Oct 2012 21:48:29 -0400 Subject: Make cmd-line overrides using -D work also for USEd modules. Fixes #211 diff --git a/doc/TODO.txt b/doc/TODO.txt index 7f8378d..c58a942 100644 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -239,6 +239,7 @@ o Collect "all" available OpenSCAD scripts from the internets and run the integr MISSING TESTS: -------------- +o cmd-line -D variable override o all functions o mirror o scale diff --git a/src/ModuleCache.cc b/src/ModuleCache.cc index c215342..19a3f84 100644 --- a/src/ModuleCache.cc +++ b/src/ModuleCache.cc @@ -72,7 +72,9 @@ Module *ModuleCache::evaluate(const std::string &filename) PRINTB("WARNING: Can't open library file '%s'\n", filename); return NULL; } - std::string text((std::istreambuf_iterator(ifs)), std::istreambuf_iterator()); + std::stringstream textbuf; + textbuf << ifs.rdbuf(); + textbuf << "\n" << commandline_commands; print_messages_push(); @@ -84,7 +86,7 @@ Module *ModuleCache::evaluate(const std::string &filename) this->entries[filename] = e; std::string pathname = boosty::stringy(fs::path(filename).parent_path()); - lib_mod = dynamic_cast(parse(text.c_str(), pathname.c_str(), false)); + lib_mod = dynamic_cast(parse(textbuf.str().c_str(), pathname.c_str(), false)); PRINTB_NOCACHE(" compiled module: %p", lib_mod); if (lib_mod) { -- cgit v0.10.1