killing whitespace and changing comment style
This commit is contained in:
+23
-27
@@ -25,7 +25,6 @@ bool XmlFileUtil::LoadFromFileShowErrors( XNode &xml, RageFileBasic &f )
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool XmlFileUtil::LoadFromFileShowErrors( XNode &xml, const RString &sFile )
|
bool XmlFileUtil::LoadFromFileShowErrors( XNode &xml, const RString &sFile )
|
||||||
{
|
{
|
||||||
RageFile f;
|
RageFile f;
|
||||||
@@ -82,7 +81,6 @@ static void InitEntities()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// skip spaces
|
// skip spaces
|
||||||
static void tcsskip( const RString &s, RString::size_type &i )
|
static void tcsskip( const RString &s, RString::size_type &i )
|
||||||
{
|
{
|
||||||
@@ -107,7 +105,6 @@ static void SetString( const RString &s, int iStart, int iEnd, RString* ps, bool
|
|||||||
ps->assign( s, iStart, len );
|
ps->assign( s, iStart, len );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// attr1="value1" attr2='value2' attr3=value3 />
|
// attr1="value1" attr2='value2' attr3=value3 />
|
||||||
// ^- return pointer
|
// ^- return pointer
|
||||||
// Desc : loading attribute plain xml text
|
// Desc : loading attribute plain xml text
|
||||||
@@ -220,12 +217,12 @@ RString::size_type LoadInternal( XNode *pNode, const RString &xml, RString &sErr
|
|||||||
if( xml[iOffset+1] == chXMLTagPre )
|
if( xml[iOffset+1] == chXMLTagPre )
|
||||||
return iOffset;
|
return iOffset;
|
||||||
|
|
||||||
/* <!-- */
|
// <!--
|
||||||
if( !xml.compare(iOffset+1, 3, "!--") )
|
if( !xml.compare(iOffset+1, 3, "!--") )
|
||||||
{
|
{
|
||||||
iOffset += 4;
|
iOffset += 4;
|
||||||
|
|
||||||
/* Find the close tag. */
|
// Find the close tag.
|
||||||
RString::size_type iEnd = xml.find( "-->", iOffset );
|
RString::size_type iEnd = xml.find( "-->", iOffset );
|
||||||
if( iEnd == string::npos )
|
if( iEnd == string::npos )
|
||||||
{
|
{
|
||||||
@@ -587,7 +584,7 @@ namespace
|
|||||||
}
|
}
|
||||||
else if( sExpression.size() > 0 && sExpression[0] == '@' )
|
else if( sExpression.size() > 0 && sExpression[0] == '@' )
|
||||||
{
|
{
|
||||||
/* This is a raw string. */
|
// This is a raw string.
|
||||||
sExpression.erase( 0, 1 );
|
sExpression.erase( 0, 1 );
|
||||||
LuaHelpers::Push( L, sExpression );
|
LuaHelpers::Push( L, sExpression );
|
||||||
}
|
}
|
||||||
@@ -632,7 +629,7 @@ namespace
|
|||||||
{
|
{
|
||||||
XNode *pNode = new XNode( sName );
|
XNode *pNode = new XNode( sName );
|
||||||
|
|
||||||
/* Set the value of the node to the table. */
|
// Set the value of the node to the table.
|
||||||
{
|
{
|
||||||
XNodeLuaValue *pValue = new XNodeLuaValue;
|
XNodeLuaValue *pValue = new XNodeLuaValue;
|
||||||
lua_pushvalue( L, -1 );
|
lua_pushvalue( L, -1 );
|
||||||
@@ -640,12 +637,12 @@ namespace
|
|||||||
pNode->AppendAttrFrom( XNode::TEXT_ATTRIBUTE, pValue );
|
pNode->AppendAttrFrom( XNode::TEXT_ATTRIBUTE, pValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Iterate over the table, pulling out attributes and tables to process. */
|
// Iterate over the table, pulling out attributes and tables to process.
|
||||||
vector<RString> NodeNamesToAdd;
|
vector<RString> NodeNamesToAdd;
|
||||||
vector<LuaReference> NodesToAdd;
|
vector<LuaReference> NodesToAdd;
|
||||||
|
|
||||||
/* Add array elements first, in array order, so iterating over the XNode keeps the
|
/* Add array elements first, in array order, so iterating over the XNode
|
||||||
* array in order. */
|
* keeps the array in order. */
|
||||||
FOREACH_LUATABLEI( L, -1, i )
|
FOREACH_LUATABLEI( L, -1, i )
|
||||||
{
|
{
|
||||||
if( !lua_istable(L, -1) )
|
if( !lua_istable(L, -1) )
|
||||||
@@ -658,13 +655,13 @@ namespace
|
|||||||
int iLen = NodeNamesToAdd.size();
|
int iLen = NodeNamesToAdd.size();
|
||||||
FOREACH_LUATABLE( L, -1 )
|
FOREACH_LUATABLE( L, -1 )
|
||||||
{
|
{
|
||||||
/* If this entry is a table, add it recursively. */
|
// If this entry is a table, add it recursively.
|
||||||
if( lua_istable(L, -2) )
|
if( lua_istable(L, -2) )
|
||||||
{
|
{
|
||||||
if( lua_isnumber(L, -1) )
|
if( lua_isnumber(L, -1) )
|
||||||
{
|
{
|
||||||
/* If this number is an integer, and between [1,iLen], then we added
|
/* If this number is an integer, and between [1,iLen], then
|
||||||
* this one already above. */
|
* we added this one already above. */
|
||||||
lua_Number f = lua_tonumber( L, -1 );
|
lua_Number f = lua_tonumber( L, -1 );
|
||||||
int i;
|
int i;
|
||||||
lua_number2int(i, f);
|
lua_number2int(i, f);
|
||||||
@@ -683,20 +680,20 @@ namespace
|
|||||||
RString sName;
|
RString sName;
|
||||||
LuaHelpers::Pop( L, sName );
|
LuaHelpers::Pop( L, sName );
|
||||||
|
|
||||||
/* Otherwise, add an attribute. */
|
// Otherwise, add an attribute.
|
||||||
XNodeLuaValue *pValue = new XNodeLuaValue;
|
XNodeLuaValue *pValue = new XNodeLuaValue;
|
||||||
pValue->SetValueFromStack( L );
|
pValue->SetValueFromStack( L );
|
||||||
pNode->AppendAttrFrom( sName, pValue );
|
pNode->AppendAttrFrom( sName, pValue );
|
||||||
}
|
}
|
||||||
lua_pop( L, 1 );
|
lua_pop( L, 1 );
|
||||||
|
|
||||||
/* Recursively process tables. */
|
// Recursively process tables.
|
||||||
for( size_t i = 0; i < NodesToAdd.size(); ++i )
|
for( size_t i = 0; i < NodesToAdd.size(); ++i )
|
||||||
{
|
{
|
||||||
const RString &sNodeName = NodeNamesToAdd[i];
|
const RString &sNodeName = NodeNamesToAdd[i];
|
||||||
LuaReference &NodeToAdd = NodesToAdd[i];
|
LuaReference &NodeToAdd = NodesToAdd[i];
|
||||||
|
|
||||||
/* Check if the table is on the stack. */
|
// Check if the table is on the stack.
|
||||||
ProcessedTables.PushSelf( L );
|
ProcessedTables.PushSelf( L );
|
||||||
NodeToAdd.PushSelf( L ); // push table
|
NodeToAdd.PushSelf( L ); // push table
|
||||||
lua_gettable( L, -2 );
|
lua_gettable( L, -2 );
|
||||||
@@ -706,7 +703,7 @@ namespace
|
|||||||
if( bSawThisTableAlready )
|
if( bSawThisTableAlready )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Add the table to the stack. */
|
// Add the table to the stack.
|
||||||
ProcessedTables.PushSelf( L );
|
ProcessedTables.PushSelf( L );
|
||||||
NodeToAdd.PushSelf( L );
|
NodeToAdd.PushSelf( L );
|
||||||
lua_pushboolean( L, true );
|
lua_pushboolean( L, true );
|
||||||
@@ -718,7 +715,7 @@ namespace
|
|||||||
if( pNewNode )
|
if( pNewNode )
|
||||||
pNode->AppendChild( pNewNode );
|
pNode->AppendChild( pNewNode );
|
||||||
|
|
||||||
/* Remove the table from the stack. */
|
// Remove the table from the stack.
|
||||||
ProcessedTables.PushSelf( L );
|
ProcessedTables.PushSelf( L );
|
||||||
NodeToAdd.PushSelf( L );
|
NodeToAdd.PushSelf( L );
|
||||||
lua_pushnil( L );
|
lua_pushnil( L );
|
||||||
@@ -731,19 +728,18 @@ namespace
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Pop a table off of the stack, and return an XNode tree referring recursively
|
||||||
* Pop a table off of the stack, and return an XNode tree referring recursively
|
|
||||||
* to entries in the table.
|
* to entries in the table.
|
||||||
*
|
*
|
||||||
* The table may not contain table cycles; if a cycle is detected, only the first
|
* The table may not contain table cycles; if a cycle is detected, only the first
|
||||||
* table seen will have a corresponding XNode.
|
* table seen will have a corresponding XNode.
|
||||||
*
|
*
|
||||||
* Users of the resulting XNode may access the original table via PushValue.
|
* Users of the resulting XNode may access the original table via PushValue. */
|
||||||
*/
|
|
||||||
XNode *XmlFileUtil::XNodeFromTable( lua_State *L )
|
XNode *XmlFileUtil::XNodeFromTable( lua_State *L )
|
||||||
{
|
{
|
||||||
/* Maintain a set of references that we've created. Tables may loop; XNode trees may
|
/* Maintain a set of references that we've created. Tables may loop; XNode
|
||||||
* not. If we encounter a cycle, skip creating an XNode for that node. */
|
* trees may not. If we encounter a cycle, skip creating an XNode for
|
||||||
|
* that node. */
|
||||||
LuaReference ProcessedTables;
|
LuaReference ProcessedTables;
|
||||||
lua_newtable( L );
|
lua_newtable( L );
|
||||||
ProcessedTables.SetFromStack( L );
|
ProcessedTables.SetFromStack( L );
|
||||||
@@ -760,14 +756,14 @@ void XmlFileUtil::MergeIniUnder( XNode *pFrom, XNode *pTo )
|
|||||||
* with the possibility of duplicate child names. */
|
* with the possibility of duplicate child names. */
|
||||||
vector<XNodes::iterator> aToMove;
|
vector<XNodes::iterator> aToMove;
|
||||||
|
|
||||||
/* Iterate over each section in pFrom. */
|
// Iterate over each section in pFrom.
|
||||||
XNodes::iterator it = pFrom->m_childs.begin();
|
XNodes::iterator it = pFrom->m_childs.begin();
|
||||||
while( it != pFrom->m_childs.end() )
|
while( it != pFrom->m_childs.end() )
|
||||||
{
|
{
|
||||||
XNodes::iterator next = it;
|
XNodes::iterator next = it;
|
||||||
++next;
|
++next;
|
||||||
|
|
||||||
/* If this node doesn't exist in pTo, just move the whole node. */
|
// If this node doesn't exist in pTo, just move the whole node.
|
||||||
XNode *pSectionNode = *it;
|
XNode *pSectionNode = *it;
|
||||||
XNode *pChildNode = pTo->GetChild( pSectionNode->GetName() );
|
XNode *pChildNode = pTo->GetChild( pSectionNode->GetName() );
|
||||||
if( pChildNode == NULL )
|
if( pChildNode == NULL )
|
||||||
@@ -778,7 +774,7 @@ void XmlFileUtil::MergeIniUnder( XNode *pFrom, XNode *pTo )
|
|||||||
{
|
{
|
||||||
FOREACH_Attr( pSectionNode, it2 )
|
FOREACH_Attr( pSectionNode, it2 )
|
||||||
{
|
{
|
||||||
/* Don't overwrite existing nodes. */
|
// Don't overwrite existing nodes.
|
||||||
pChildNode->AppendAttrFrom( it2->first, it2->second->Copy(), false );
|
pChildNode->AppendAttrFrom( it2->first, it2->second->Copy(), false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user