XML: better descriptions on a couple errors, more accurate line number reporting...
authorRoyce Mitchell III <royce3@ev1.net>
Sat, 26 Nov 2005 04:24:17 +0000 (04:24 +0000)
committerRoyce Mitchell III <royce3@ev1.net>
Sat, 26 Nov 2005 04:24:17 +0000 (04:24 +0000)
mingw/directory: move msvc fix for popen with the rest of the code that got moved
rbuild.dsp: added new files to project

svn path=/trunk/; revision=19611

reactos/tools/rbuild/XML.cpp
reactos/tools/rbuild/XML.h
reactos/tools/rbuild/backend/mingw/mingw.cpp
reactos/tools/rbuild/directory.cpp
reactos/tools/rbuild/rbuild.dsp

index 306dbe2..62db6a8 100644 (file)
@@ -348,6 +348,13 @@ XMLFile::get_token(string& token)
        return true;
 }
 
+bool
+XMLFile::get_token ( string& token, string& location )
+{
+       location = Location();
+       return get_token ( token );
+}
+
 string
 XMLFile::Location() const
 {
@@ -547,8 +554,8 @@ XMLParse ( XMLFile& f,
            const Path& path,
            bool* pend_tag = NULL )
 {
-       string token;
-       if ( !f.get_token(token) )
+       string token, location;
+       if ( !f.get_token(token,location) )
                return NULL;
        bool end_tag, is_include = false;
 
@@ -557,15 +564,15 @@ XMLParse ( XMLFile& f,
                || !strncmp ( token.c_str (), "<?", 2 ) )
        {
                if ( token[0] != '<' )
-                       throw XMLSyntaxErrorException ( f.Location (),
+                       throw XMLSyntaxErrorException ( location,
                                                        "expecting xml tag, not '%s'",
                                                        token.c_str () );
-               if ( !f.get_token(token) )
+               if ( !f.get_token(token,location) )
                        return NULL;
        }
 
        XMLElement* e = new XMLElement ( &f,
-                                        f.Location () );
+                                        location );
        bool bNeedEnd = e->Parse ( token, end_tag );
 
        if ( e->name == "xi:include" && includes )
@@ -586,7 +593,7 @@ XMLParse ( XMLFile& f,
                else if ( end_tag )
                {
                        delete e;
-                       throw XMLSyntaxErrorException ( f.Location (),
+                       throw XMLSyntaxErrorException ( location,
                                                        "end tag '%s' not expected",
                                                        token.c_str() );
                        return NULL;
@@ -598,27 +605,27 @@ XMLParse ( XMLFile& f,
        {
                if ( f.next_is_text () )
                {
-                       if ( !f.get_token ( token ) || token.size () == 0 )
+                       if ( !f.get_token ( token, location ) || token.size () == 0 )
                        {
                                throw InvalidBuildFileException (
-                                       f.Location(),
+                                       location,
                                        "internal tool error - get_token() failed when more_tokens() returned true" );
                                break;
                        }
                        if ( e->subElements.size() && !bThisMixingErrorReported )
                        {
-                               throw XMLSyntaxErrorException ( f.Location (),
+                               throw XMLSyntaxErrorException ( location,
                                                                "mixing of inner text with sub elements" );
                                bThisMixingErrorReported = true;
                        }
                        if ( strchr ( token.c_str (), '>' ) )
                        {
-                               throw XMLSyntaxErrorException ( f.Location (),
+                               throw XMLSyntaxErrorException ( location,
                                                                "invalid symbol '>'" );
                        }
                        if ( e->value.size() > 0 )
                        {
-                               throw XMLSyntaxErrorException ( f.Location (),
+                               throw XMLSyntaxErrorException ( location,
                                                                "multiple instances of inner text" );
                                e->value += " " + token;
                        }
@@ -628,20 +635,33 @@ XMLParse ( XMLFile& f,
                else
                {
                        XMLElement* e2 = XMLParse ( f, is_include ? NULL : includes, path, &end_tag );
+                       if ( e->name == "project" && e2->name == "1" )
+                               e = e;
                        if ( !e2 )
                        {
+                               string e_location = e->location;
+                               string e_name = e->name;
+                               delete e;
                                throw InvalidBuildFileException (
-                                       e->location,
-                                       "end of file found looking for end tag" );
+                                       e_location,
+                                       "end of file found looking for end tag: </%s>",
+                                       e_name.c_str() );
                                break;
                        }
                        if ( end_tag )
                        {
                                if ( e->name != e2->name )
                                {
+                                       string e2_location = e2->location;
+                                       string e_name = e->name;
+                                       string e2_name = e2->name;
+                                       delete e;
                                        delete e2;
-                                       throw XMLSyntaxErrorException ( f.Location (),
-                                                                       "end tag name mismatch" );
+                                       throw XMLSyntaxErrorException (
+                                               e2_location,
+                                               "end tag name mismatch - found </%s> but was expecting </%s>",
+                                               e2_name.c_str(),
+                                               e_name.c_str() );
                                        break;
                                }
                                delete e2;
@@ -649,7 +669,9 @@ XMLParse ( XMLFile& f,
                        }
                        if ( e->value.size () > 0 && !bThisMixingErrorReported )
                        {
-                               throw XMLSyntaxErrorException ( f.Location (),
+                               string e_location = e->location;
+                               delete e;
+                               throw XMLSyntaxErrorException ( e_location,
                                                                "mixing of inner text with sub elements" );
                                bThisMixingErrorReported = true;
                        }
index 38ad86c..e097f40 100644 (file)
@@ -81,7 +81,8 @@ public:
        void next_token();
        bool next_is_text();
        bool more_tokens();
-       bool get_token(std::string& token);
+       bool get_token ( std::string& token );
+       bool get_token ( std::string& token, std::string& location );
        const std::string& filename() { return _filename; }
        std::string Location() const;
 
index d4fb41e..36380ec 100644 (file)
 #include <assert.h>
 #include "modulehandler.h"
 
+#ifdef _MSC_VER
+#define popen _popen
+#define pclose _pclose
+#endif//_MSC_VER
+
 using std::string;
 using std::vector;
 using std::set;
index 2b6d5ec..e8dc49f 100644 (file)
 #include <assert.h>
 
 #include "rbuild.h"
-#ifdef _MSC_VER
-#define popen _popen
-#define pclose _pclose
-#else
+#ifndef _MSC_VER
 #include <dirent.h>
 #endif//_MSC_VER
 
index 9550f7f..433f1a9 100644 (file)
@@ -181,6 +181,14 @@ SOURCE=.\cdfile.cpp
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=.\compilationunit.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\compilationunitsupportcode.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=.\compilerflag.cpp\r
 # End Source File\r
 # Begin Source File\r
@@ -193,6 +201,10 @@ SOURCE=.\define.cpp
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=.\directory.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=.\exception.cpp\r
 # End Source File\r
 # Begin Source File\r
@@ -201,6 +213,10 @@ SOURCE=.\filesupportcode.cpp
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=.\global.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=.\include.cpp\r
 # End Source File\r
 # Begin Source File\r
@@ -213,6 +229,10 @@ SOURCE=.\linkerflag.cpp
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=.\linkerscript.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=.\module.cpp\r
 # End Source File\r
 # Begin Source File\r