diff --git a/reactos/tools/rbuild/XML.cpp b/reactos/tools/rbuild/XML.cpp index d2354851aba..11878ac4c42 100644 --- a/reactos/tools/rbuild/XML.cpp +++ b/reactos/tools/rbuild/XML.cpp @@ -197,10 +197,10 @@ XMLFile::close() } bool -XMLFile::open(const string& filename) +XMLFile::open(const string& filename_) { close(); - FILE* f = fopen ( filename.c_str(), "rb" ); + FILE* f = fopen ( filename_.c_str(), "rb" ); if ( !f ) return false; unsigned long len = (unsigned long)filelen(f); @@ -209,6 +209,7 @@ XMLFile::open(const string& filename) fclose ( f ); _p = _buf.c_str(); _end = _p + len; + _filename = filename_; next_token(); return true; } @@ -456,24 +457,23 @@ XMLParse(XMLFile& f, { XMLAttribute* att; att = e->GetAttribute("href",true); - if ( att ) + assert(att); + + string file ( path.Fixup(att->value,true) ); + string top_file ( Path::RelativeFromWorkingDirectory ( file ) ); + e->attributes.push_back ( new XMLAttribute ( "top_href", top_file ) ); + XMLFile fInc; + if ( !fInc.open ( file ) ) + throw FileNotFoundException ( file ); + else { - string file ( path.Fixup(att->value,true) ); - string top_file ( Path::RelativeFromWorkingDirectory ( file ) ); - e->attributes.push_back ( new XMLAttribute ( "top_href", top_file ) ); - XMLFile fInc; - if ( !fInc.open ( file ) ) - throw FileNotFoundException ( file ); - else + Path path2 ( path, att->value ); + for ( ;; ) { - Path path2 ( path, att->value ); - for ( ;; ) - { - XMLElement* e2 = XMLParse ( fInc, path2 ); - if ( !e2 ) - break; - e->AddSubElement ( e2 ); - } + XMLElement* e2 = XMLParse ( fInc, path2 ); + if ( !e2 ) + break; + e->AddSubElement ( e2 ); } } } @@ -519,7 +519,7 @@ XMLParse(XMLFile& f, if ( end_tag ) { if ( e->name != e2->name ) - printf ( "end tag name mismatch\n" ); + printf ( "syntax error: end tag name mismatch\n" ); delete e2; break; } diff --git a/reactos/tools/rbuild/XML.h b/reactos/tools/rbuild/XML.h index ff741927e58..4be3170f819 100644 --- a/reactos/tools/rbuild/XML.h +++ b/reactos/tools/rbuild/XML.h @@ -34,9 +34,10 @@ public: bool next_is_text(); bool more_tokens(); bool get_token(std::string& token); + const std::string& filename() { return _filename; } private: - std::string _buf; + std::string _buf, _filename; const char *_p, *_end; }; diff --git a/reactos/tools/rbuild/module.cpp b/reactos/tools/rbuild/module.cpp index d0f1e5ec099..30734645eec 100644 --- a/reactos/tools/rbuild/module.cpp +++ b/reactos/tools/rbuild/module.cpp @@ -1,6 +1,7 @@ // module.cpp #include "pch.h" +#include #include "rbuild.h" @@ -19,9 +20,10 @@ Module::Module ( const XMLElement& moduleNode, Module::~Module () { - for ( size_t i = 0; i < files.size(); i++ ) + size_t i; + for ( i = 0; i < files.size(); i++ ) delete files[i]; - for ( size_t i = 0; i < libraries.size(); i++ ) + for ( i = 0; i < libraries.size(); i++ ) delete libraries[i]; } @@ -40,6 +42,7 @@ void Module::ProcessXML ( const XMLElement& e, else if ( e.name == "directory" ) { const XMLAttribute* att = e.GetAttribute ( "name", true ); + assert(att); subpath = path + "/" + att->value; } for ( size_t i = 0; i < e.subElements.size (); i++ ) diff --git a/reactos/tools/rbuild/project.cpp b/reactos/tools/rbuild/project.cpp index 1ac65a38b31..e79bcf3cd5b 100644 --- a/reactos/tools/rbuild/project.cpp +++ b/reactos/tools/rbuild/project.cpp @@ -1,5 +1,6 @@ #include "pch.h" +#include #include "rbuild.h" @@ -55,11 +56,13 @@ Project::ProcessXML ( const XMLElement& e, const string& path ) name = att->value; att = e.GetAttribute ( "makefile", true ); + assert(att); makefile = att->value; } else if ( e.name == "module" ) { att = e.GetAttribute ( "name", true ); + assert(att); Module* module = new Module ( e, att->value, path ); modules.push_back ( module ); module->ProcessXML ( e, path ); @@ -68,6 +71,7 @@ Project::ProcessXML ( const XMLElement& e, const string& path ) else if ( e.name == "directory" ) { const XMLAttribute* att = e.GetAttribute ( "name", true ); + assert(att); subpath = path + "/" + att->value; } for ( size_t i = 0; i < e.subElements.size (); i++ )