From 8aac702e1efceea2969ee10ef5eb0d10b3b120be Mon Sep 17 00:00:00 2001 From: ulfjorensen Date: Fri, 8 Oct 2010 16:51:54 +0000 Subject: [PATCH] - Workaround: ASCII XFiles aren't as strict on separator chars as before anymore. Should allow some more files to be parsed correctly. git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@825 67173fc5-114c-0410-ac8e-9d2fd5bffc1f --- code/XFileParser.cpp | 24 ++++++++++++++++++++---- code/XFileParser.h | 3 +++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/code/XFileParser.cpp b/code/XFileParser.cpp index f805bfb9a..3bad8c963 100644 --- a/code/XFileParser.cpp +++ b/code/XFileParser.cpp @@ -1000,6 +1000,22 @@ void XFileParser::CheckForSeparator() ThrowException( "Separator character (';' or ',') expected."); } +// ------------------------------------------------------------------------------------------------ +// tests and possibly consumes a separator char, but does nothing if there was no separator +void XFileParser::TestForSeparator() +{ + if( mIsBinaryFormat) + return; + + FindNextNoneWhiteSpace(); + if( P >= End) + return; + + // test and skip + if( *P == ';' || *P == ',') + P++; +} + // ------------------------------------------------------------------------------------------------ void XFileParser::readHeadOfDataObject( std::string* poName) { @@ -1332,7 +1348,7 @@ aiVector2D XFileParser::ReadVector2() aiVector2D vector; vector.x = ReadFloat(); vector.y = ReadFloat(); - CheckForSeparator(); + TestForSeparator(); return vector; } @@ -1344,7 +1360,7 @@ aiVector3D XFileParser::ReadVector3() vector.x = ReadFloat(); vector.y = ReadFloat(); vector.z = ReadFloat(); - CheckForSeparator(); + TestForSeparator(); return vector; } @@ -1357,7 +1373,7 @@ aiColor4D XFileParser::ReadRGBA() color.g = ReadFloat(); color.b = ReadFloat(); color.a = ReadFloat(); - CheckForSeparator(); + TestForSeparator(); return color; } @@ -1369,7 +1385,7 @@ aiColor3D XFileParser::ReadRGB() color.r = ReadFloat(); color.g = ReadFloat(); color.b = ReadFloat(); - CheckForSeparator(); + TestForSeparator(); return color; } diff --git a/code/XFileParser.h b/code/XFileParser.h index b21af1bd3..9f1ec6f33 100644 --- a/code/XFileParser.h +++ b/code/XFileParser.h @@ -116,6 +116,9 @@ protected: //! checks for a separator char, either a ',' or a ';' void CheckForSeparator(); + /// tests and possibly consumes a separator char, but does nothing if there was no separator + void TestForSeparator(); + //! reads a x file style string void GetNextTokenAsString( std::string& poString);