parse, but ignore, <? ?> tags - eliminated duplicate code ala
FixSeparator() - fix path separator issues
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/XML.cpp
Modified:
branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler
.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/project.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h
Modified:
branches/xmlbuildsystem/reactos/tools/rbuild/tests/data/module.xml
Modified:
branches/xmlbuildsystem/reactos/tools/rbuild/tests/data/project.xml
Modified:
branches/xmlbuildsystem/reactos/tools/rbuild/tests/moduletest.cpp
_____
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/XML.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/XML.cpp
2005-01-07 13:34:47 UTC (rev 12867)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/XML.cpp
2005-01-07 13:48:53 UTC (rev 12868)
@@ -251,6 +251,14 @@
else
tokend += 3;
}
+ else if ( !strncmp ( _p, "<?", 2 ) )
+ {
+ tokend = strstr ( _p, "?>" );
+ if ( !tokend )
+ tokend = _end;
+ else
+ tokend += 2;
+ }
else if ( *_p == '<' )
{
tokend = strchr ( _p, '>' );
@@ -456,7 +464,9 @@
return NULL;
bool end_tag;
- while ( token[0] != '<' || !strncmp ( token.c_str(), "<!--", 4
)
)
+ while ( token[0] != '<'
+ || !strncmp ( token.c_str(), "<!--", 4 )
+ || !strncmp ( token.c_str(), "<?", 2 ) )
{
if ( token[0] != '<' )
throw XMLSyntaxErrorException ( f.Location(),
_____
Modified:
branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler
.cpp
---
branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler
.cpp 2005-01-07 13:34:47 UTC (rev 12867)
+++
branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler
.cpp 2005-01-07 13:48:53 UTC (rev 12868)
@@ -1,5 +1,6 @@
#include "../../pch.h"
+#include <assert.h>
#include "../../rbuild.h"
#include "mingw.h"
@@ -162,30 +163,30 @@
archiveFilename.c_str (),
importLibraryDependencies.c_str () );
fprintf ( fMakefile,
- "\t${gcc} -Wl,--base-file,%s/base.tmp -o %s/junk.tmp
%s %s\n",
+ "\t${gcc} -Wl,--base-file,%s" SSEP "base.tmp -o %s"
SSEP "junk.tmp %s %s\n",
workingDirectory.c_str (),
workingDirectory.c_str (),
archiveFilename.c_str (),
importLibraryDependencies.c_str () );
fprintf ( fMakefile,
- "\t${rm} %s/junk.tmp\n",
+ "\t${rm} %s" SSEP "junk.tmp\n",
workingDirectory.c_str () );
fprintf ( fMakefile,
- "\t${dlltool} --dllname %s --base-file %s/base.tmp
--output-exp %s/temp.exp --kill-at\n",
+ "\t${dlltool} --dllname %s --base-file %s" SSEP
"base.tmp --output-exp %s" SSEP "temp.exp --kill-at\n",
module.GetPath ().c_str (),
workingDirectory.c_str (),
workingDirectory.c_str ());
fprintf ( fMakefile,
- "\t${rm} %s/base.tmp\n",
+ "\t${rm} %s" SSEP "base.tmp\n",
workingDirectory.c_str () );
fprintf ( fMakefile,
- "\t${ld} -Wl,%s/temp.exp -o %s %s %s\n",
+ "\t${ld} -Wl,%s" SSEP "temp.exp -o %s %s %s\n",
workingDirectory.c_str (),
module.GetPath ().c_str (),
archiveFilename.c_str (),
importLibraryDependencies.c_str () );
fprintf ( fMakefile,
- "\t${rm} %s/temp.exp\n",
+ "\t${rm} %s" SSEP "temp.exp\n",
workingDirectory.c_str () );
GenerateArchiveTarget ( module );
_____
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp
2005-01-07 13:34:47 UTC (rev 12867)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp
2005-01-07 13:48:53 UTC (rev 12868)
@@ -8,37 +8,18 @@
using std::string;
using std::vector;
-#ifdef WIN32
-#define EXEPOSTFIX ".exe"
-#define SEP "\\"
string
FixSeparator ( const string& s )
{
string s2(s);
- char* p = strchr ( &s2[0], '/' );
+ char* p = strchr ( &s2[0], CBAD_SEP );
while ( p )
{
- *p++ = '\\';
- p = strchr ( p, '/' );
+ *p++ = CSEP;
+ p = strchr ( p, CBAD_SEP );
}
return s2;
}
-#else
-#define EXEPOSTFIX
-#define SEP "/"
-string
-FixSeparator ( const string& s )
-{
- string s2(s);
- char* p = strchr ( &s2[0], '\\' );
- while ( p )
- {
- *p++ = '/';
- p = strchr ( p, '\\' );
- }
- return s2;
-}
-#endif
Module::Module ( Project* project,
const XMLElement& moduleNode,
@@ -68,7 +49,7 @@
string subpath ( path );
if ( e.name == "file" && e.value.size () )
{
- files.push_back ( new File ( path + "/" + e.value ) );
+ files.push_back ( new File ( path + CSEP + e.value ) );
}
else if ( e.name == "library" && e.value.size () )
{
@@ -78,7 +59,7 @@
{
const XMLAttribute* att = e.GetAttribute ( "name", true
);
assert(att);
- subpath = path + "/" + att->value;
+ subpath = path + CSEP + att->value;
}
for ( size_t i = 0; i < e.subElements.size (); i++ )
ProcessXML ( *e.subElements[i], subpath );
@@ -100,7 +81,7 @@
string
Module::GetPath ()
{
- return FixSeparator (path) + SEP + name + EXEPOSTFIX;
+ return FixSeparator (path) + CSEP + name + EXEPOSTFIX;
}
_____
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/project.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/project.cpp
2005-01-07 13:34:47 UTC (rev 12867)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/project.cpp
2005-01-07 13:48:53 UTC (rev 12868)
@@ -30,15 +30,12 @@
{
Path path;
- head = XMLParse ( xmlfile, path );
- if ( !head )
- throw InvalidBuildFileException ( "Document contains no
'project' tag." );
-
- if ( head->name != "project" )
+ do
{
- throw InvalidBuildFileException ( "Expected 'project',
got '%s'.",
-
head->name.c_str());
- }
+ head = XMLParse ( xmlfile, path );
+ if ( !head )
+ throw InvalidBuildFileException ( "Document
contains no 'project' tag." );
+ } while ( head->name != "project" );
this->ProcessXML ( *head, "." );
}
@@ -73,7 +70,7 @@
{
const XMLAttribute* att = e.GetAttribute ( "name", true
);
assert(att);
- subpath = path + "/" + att->value;
+ subpath = path + CSEP + att->value;
}
for ( size_t i = 0; i < e.subElements.size (); i++ )
ProcessXML ( *e.subElements[i], subpath );
_____
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h
--- branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h
2005-01-07 13:34:47 UTC (rev 12867)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h
2005-01-07 13:48:53 UTC (rev 12868)
@@ -7,6 +7,20 @@
#include "exception.h"
#include "XML.h"
+#ifdef WIN32
+#define EXEPOSTFIX ".exe"
+#define CSEP '\\'
+#define CBAD_SEP '/'
+#define SSEP "\\"
+#define SBAD_SEP "/"
+#else
+#define EXEPOSTFIX
+#define CSEP '/'
+#define CBAD_SEP '\\'
+#define SSEP "/"
+#define SBAD_SEP "\\"
+#endif
+
class Project;
class Module;
class File;
@@ -78,4 +92,7 @@
Library ( const std::string& _name );
};
+extern std::string
+FixSeparator ( const std::string& s );
+
#endif /* __RBUILD_H */
_____
Modified:
branches/xmlbuildsystem/reactos/tools/rbuild/tests/data/module.xml
--- branches/xmlbuildsystem/reactos/tools/rbuild/tests/data/module.xml
2005-01-07 13:34:47 UTC (rev 12867)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/tests/data/module.xml
2005-01-07 13:48:53 UTC (rev 12868)
@@ -1,3 +1,4 @@
+<?xml version="1.0" ?>
<project name="Project" makefile="Makefile">
<directory name="dir1">
<module name="module1" type="buildtool">
_____
Modified:
branches/xmlbuildsystem/reactos/tools/rbuild/tests/data/project.xml
--- branches/xmlbuildsystem/reactos/tools/rbuild/tests/data/project.xml
2005-01-07 13:34:47 UTC (rev 12867)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/tests/data/project.xml
2005-01-07 13:48:53 UTC (rev 12868)
@@ -1,3 +1,4 @@
+<?xml version="1.0" ?>
<project name="Project" makefile="Makefile">
<directory name="dir1">
<module name="module1" type="buildtool">
_____
Modified:
branches/xmlbuildsystem/reactos/tools/rbuild/tests/moduletest.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/tests/moduletest.cpp
2005-01-07 13:34:47 UTC (rev 12867)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/tests/moduletest.cpp
2005-01-07 13:48:53 UTC (rev 12868)
@@ -11,16 +11,16 @@
Module& module1 = *project.modules[0];
IS_TRUE(module1.type == BuildTool);
ARE_EQUAL(2, module1.files.size());
- ARE_EQUAL("./dir1/file1.c", module1.files[0]->name);
- ARE_EQUAL("./dir1/file2.c", module1.files[1]->name);
+ ARE_EQUAL("." SSEP "dir1" SSEP "file1.c",
module1.files[0]->name);
+ ARE_EQUAL("." SSEP "dir1" SSEP "file2.c",
module1.files[1]->name);
ARE_EQUAL(0, module1.libraries.size());
Module& module2 = *project.modules[1];
IS_TRUE(module2.type == KernelModeDLL);
ARE_EQUAL(2, module2.files.size());
- ARE_EQUAL("./dir2/file3.c", module2.files[0]->name);
- ARE_EQUAL("./dir2/file4.c", module2.files[1]->name);
+ ARE_EQUAL("." SSEP "dir2" SSEP "file3.c",
module2.files[0]->name);
+ ARE_EQUAL("." SSEP "dir2" SSEP "file4.c",
module2.files[1]->name);
ARE_EQUAL(1, module2.libraries.size());
Library& library1 = *module2.libraries[0];