summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ModuleCache.cc1
-rw-r--r--src/lexer.l15
-rw-r--r--src/mainwin.cc11
-rw-r--r--src/module.cc15
-rw-r--r--src/parsersettings.cc13
5 files changed, 17 insertions, 38 deletions
diff --git a/src/ModuleCache.cc b/src/ModuleCache.cc
index 030cfa0..2d4cbe9 100644
--- a/src/ModuleCache.cc
+++ b/src/ModuleCache.cc
@@ -23,7 +23,6 @@ ModuleCache *ModuleCache::inst = NULL;
FileModule *ModuleCache::evaluate(const std::string &filename)
{
- std::cout << "modcache eval" << filename << "\n";
FileModule *lib_mod = NULL;
// Create cache ID
diff --git a/src/lexer.l b/src/lexer.l
index bb1664e..59bf56f 100644
--- a/src/lexer.l
+++ b/src/lexer.l
@@ -115,7 +115,7 @@ use[ \t\r\n>]*"<" { BEGIN(cond_use); }
BEGIN(INITIAL);
fs::path fullpath = find_valid_path(sourcepath(), fs::path(filename), &openfilenames);
if (fullpath.empty()) {
- PRINTB("WARNING: Can't open 'use' file '%s'.", filename);
+ PRINTB("WARNING: Can't open library '%s'.", filename);
} else {
handle_dep(fullpath.string());
parserlval.text = strdup(fullpath.string().c_str());
@@ -197,13 +197,6 @@ fs::path sourcepath()
*/
void includefile()
{
- PRINTB("lex includefile filename %s",filename.c_str());
- PRINTB("lex includefile filepath %s",filepath.c_str());
- PRINTB("lex includefile sourcepath %s",sourcepath().c_str());
- BOOST_FOREACH(std::string of, openfilenames) {
- PRINTB("lex includefile openfilename: %s",of);
- }
-
fs::path localpath = fs::path(filepath) / filename;
fs::path fullpath = find_valid_path(sourcepath(), localpath, &openfilenames);
if (!fullpath.empty()) {
@@ -211,14 +204,12 @@ void includefile()
}
else {
rootmodule->registerInclude(boosty::stringy(localpath), boosty::stringy(localpath));
- PRINTB("WARNING: Can't open 'include' file '%s'.", filename);
+ PRINTB("WARNING: Can't open include file '%s'.", boosty::stringy(localpath));
if (path_stack.size() > 0) path_stack.pop_back();
return;
};
- PRINTB("lex fullpath %s",fullpath);
std::string fullname = boosty::stringy(fullpath);
- PRINTB("lex fullname %s",fullname);
filepath.clear();
path_stack.push_back(fullpath.parent_path());
@@ -227,7 +218,7 @@ void includefile()
yyin = fopen(fullname.c_str(), "r");
if (!yyin) {
- PRINTB("WARNING: Can't open 'include' file '%s'.", fullname);
+ PRINTB("WARNING: Can't open include file '%s'.", boosty::stringy(localpath));
path_stack.pop_back();
return;
}
diff --git a/src/mainwin.cc b/src/mainwin.cc
index a7b7a30..8151e29 100644
--- a/src/mainwin.cc
+++ b/src/mainwin.cc
@@ -615,9 +615,7 @@ void MainWindow::refreshDocument()
*/
bool MainWindow::compile(bool reload, bool procevents)
{
- PRINT("compile");
if (!compileTopLevelDocument(reload)) return false;
- PRINT("init render");
// Invalidate renderers before we kill the CSG tree
this->qglview->setRenderer(NULL);
@@ -1022,16 +1020,11 @@ bool MainWindow::fileChangedOnDisk()
bool MainWindow::includesChanged()
{
- PRINT("includes changed?");
if (this->root_module) {
BOOST_FOREACH(const FileModule::IncludeContainer::value_type &item, this->root_module->includes) {
- //std::cout<< item.first << "second" << item.second << "\n";
- //std::cout<< (is_modified(item.first, item.second)) <<"\n";
- if (this->root_module->include_modified(item.second))
- return true;
+ if (this->root_module->include_modified(item.second)) return true;
}
}
- PRINT("includes not changed");
return false;
}
@@ -1044,7 +1037,6 @@ bool MainWindow::includesChanged()
*/
bool MainWindow::compileTopLevelDocument(bool reload)
{
- PRINT("compile top level");
bool shouldcompiletoplevel = !reload;
if (includesChanged()) shouldcompiletoplevel = true;
@@ -1055,7 +1047,6 @@ bool MainWindow::compileTopLevelDocument(bool reload)
}
if (shouldcompiletoplevel) {
- PRINT("shouldcompile top level");
console->clear();
updateTemporalVariables();
diff --git a/src/module.cc b/src/module.cc
index 27e01ff..e910c44 100644
--- a/src/module.cc
+++ b/src/module.cc
@@ -200,10 +200,9 @@ std::string Module::dump(const std::string &indent, const std::string &name) con
void FileModule::registerInclude(const std::string &localpath,
const std::string &fullpath)
{
- PRINTB("filemodule reginclude %s -> %s", localpath % fullpath);
struct stat st;
memset(&st, 0, sizeof(struct stat));
- bool valid = stat(fullpath.c_str(), &st);
+ bool valid = stat(fullpath.c_str(), &st) == 0;
IncludeFile inc = {fullpath, valid, st.st_mtime};
this->includes[localpath] = inc;
}
@@ -261,12 +260,12 @@ bool FileModule::include_modified(IncludeFile inc)
{
struct stat st;
memset(&st, 0, sizeof(struct stat));
- // FIXME: Detect removal of previously found files
+
fs::path fullpath = find_valid_path(this->path, inc.filename);
- if (!fullpath.empty()) {
- bool valid = stat(inc.filename.c_str(), &st);
- if (inc.valid != valid) return true;
- if (st.st_mtime > inc.mtime) return true;
- }
+ bool valid = !fullpath.empty() ? (stat(boosty::stringy(fullpath).c_str(), &st) == 0) : false;
+
+ if (valid != inc.valid) return true;
+ if (valid && st.st_mtime > inc.mtime) return true;
+
return false;
}
diff --git a/src/parsersettings.cc b/src/parsersettings.cc
index 1f95719..8924eb4 100644
--- a/src/parsersettings.cc
+++ b/src/parsersettings.cc
@@ -25,26 +25,25 @@ fs::path search_libs(const fs::path &localpath)
BOOST_FOREACH(const std::string &dir, librarypath) {
fs::path usepath = fs::path(dir) / localpath;
if (fs::exists(usepath) && !fs::is_directory(usepath)) {
- PRINTB("found %s in %s", localpath.string() % dir);
return usepath.string();
}
}
return fs::path();
}
-// files must be 'ordinary' - they mus exist and be non-directories
+// files must be 'ordinary' - they must exist and be non-directories
static bool check_valid(const fs::path &p, const std::vector<std::string> *openfilenames)
{
if (p.empty()) {
- PRINTB("WARNING: %s invalid - file path is blank",p);
+ PRINTB("WARNING: File path is blank: %s",p);
return false;
}
if (!p.has_parent_path()) {
- PRINTB("WARNING: %s invalid - no parent path",p);
+ PRINTB("WARNING: No parent path: %s",p);
return false;
}
if (!fs::exists(p)) {
- PRINTB("WARNING: %s invalid - file not found",p);
+ PRINTB("WARNING: File not found: %s",p);
// searched ===
return false;
}
@@ -57,7 +56,7 @@ static bool check_valid(const fs::path &p, const std::vector<std::string> *openf
if (openfilenames) {
BOOST_FOREACH(const std::string &s, *openfilenames) {
if (s == fullname) {
- PRINTB("WARNING: circular include with %s", fullname);
+ PRINTB("WARNING: circular include file %s", fullname);
return false;
}
}
@@ -78,7 +77,7 @@ fs::path find_valid_path(const fs::path &sourcepath,
fs::path fpath = sourcepath / localpath;
if (check_valid(fpath, openfilenames)) return fpath;
fpath = search_libs(localpath);
- if (check_valid(fpath, openfilenames)) return fpath;
+ if (!fpath.empty() && check_valid(fpath, openfilenames)) return fpath;
}
return fs::path();
}
contact: Jan Huwald // Impressum