Browse Source

check binary or not in ParseHeader in PlyParser

YoheiKakiuchi 11 years ago
parent
commit
8e35ea59d5
2 changed files with 8 additions and 7 deletions
  1. 7 6
      code/PlyParser.cpp
  2. 1 1
      code/PlyParser.h

+ 7 - 6
code/PlyParser.cpp

@@ -427,7 +427,7 @@ bool PLY::DOM::SkipComments (const char* pCur,
 }
 
 // ------------------------------------------------------------------------------------------------
-bool PLY::DOM::ParseHeader (const char* pCur,const char** pCurOut)
+bool PLY::DOM::ParseHeader (const char* pCur,const char** pCurOut,bool p_bBE)
 {
 	ai_assert(NULL != pCur && NULL != pCurOut);
 	DefaultLogger::get()->debug("PLY::DOM::ParseHeader() begin");
@@ -458,9 +458,10 @@ bool PLY::DOM::ParseHeader (const char* pCur,const char** pCurOut)
 			SkipLine(&pCur);
 		}
 	}
-	// Is this needed ? it can't work as expected, if binary data start with values as space or line end.
-	// SkipSpacesAndLineEnd(pCur,&pCur);
-	*pCurOut = pCur;
+	if(!p_bBE)
+	{ // it would occur an error, if binary data start with values as space or line end.
+		SkipSpacesAndLineEnd(pCur,&pCur);
+	}
 
 	DefaultLogger::get()->debug("PLY::DOM::ParseHeader() succeeded");
 	return true;
@@ -528,7 +529,7 @@ bool PLY::DOM::ParseInstanceBinary (const char* pCur,DOM* p_pcOut,bool p_bBE)
 
 	DefaultLogger::get()->debug("PLY::DOM::ParseInstanceBinary() begin");
 
-	if(!p_pcOut->ParseHeader(pCur,&pCur))
+	if(!p_pcOut->ParseHeader(pCur,&pCur,p_bBE))
 	{
 		DefaultLogger::get()->debug("PLY::DOM::ParseInstanceBinary() failure");
 		return false;
@@ -551,7 +552,7 @@ bool PLY::DOM::ParseInstance (const char* pCur,DOM* p_pcOut)
 	DefaultLogger::get()->debug("PLY::DOM::ParseInstance() begin");
 
 
-	if(!p_pcOut->ParseHeader(pCur,&pCur))
+	if(!p_pcOut->ParseHeader(pCur,&pCur,false))
 	{
 		DefaultLogger::get()->debug("PLY::DOM::ParseInstance() failure");
 		return false;

+ 1 - 1
code/PlyParser.h

@@ -434,7 +434,7 @@ private:
 
 	// -------------------------------------------------------------------
 	//! Handle the file header and read all element descriptions
-	bool ParseHeader (const char* pCur,const char** pCurOut);
+	bool ParseHeader (const char* pCur,const char** pCurOut, bool p_bBE);
 
 	// -------------------------------------------------------------------
 	//! Read in all element instance lists