fixed some warnings, and added some asserts
authorRoyce Mitchell III <royce3@ev1.net>
Thu, 6 Jan 2005 01:35:01 +0000 (01:35 +0000)
committerRoyce Mitchell III <royce3@ev1.net>
Thu, 6 Jan 2005 01:35:01 +0000 (01:35 +0000)
svn path=/branches/xmlbuildsystem/; revision=12843

reactos/tools/rbuild/XML.cpp
reactos/tools/rbuild/XML.h
reactos/tools/rbuild/module.cpp
reactos/tools/rbuild/project.cpp

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