Преглед изворни кода

# fix bug in STEPFileReader, loader fails if string literals contain more than one ". Thanks to Juha Vesanen for the patch.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@1258 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
aramis_acg пре 13 година
родитељ
комит
1d7018c826
2 измењених фајлова са 17 додато и 9 уклоњено
  1. 16 8
      code/STEPFileReader.cpp
  2. 1 1
      revision.h

+ 16 - 8
code/STEPFileReader.cpp

@@ -318,20 +318,28 @@ boost::shared_ptr<const EXPRESS::DataType> EXPRESS::DataType::Parse(const char*&
 	else if (*cur == '\'' ) {
 		// string literal
 		const char* start = ++cur;
-		for(;*cur != '\'';++cur) {
-			if (*cur == '\0') {
+
+		for(;*cur != '\'';++cur)	{
+			if (*cur == '\0')	{
 				throw STEP::SyntaxError("string literal not closed",line);
 			}
 		}
-		if (cur[1]=='\'') {
-			for(cur+=2;*cur != '\'';++cur) {
-				if (*cur == '\0') {
-					throw STEP::SyntaxError("string literal not closed",line);
+
+		if (cur[1] == '\'')	{
+			// Vesanen: more than 2 escaped ' in one literal!
+			do	{
+				for(cur += 2;*cur != '\'';++cur)	{
+					if (*cur == '\0')	{
+						throw STEP::SyntaxError("string literal not closed",line);
+					}
 				}
 			}
+			while(cur[1] == '\'');
 		}
-		inout = cur+1;
-		return boost::make_shared<EXPRESS::STRING>(std::string(start, static_cast<size_t>(cur-start) ));
+
+		inout = cur + 1;
+
+		return boost::make_shared<EXPRESS::STRING>(std::string(start, static_cast<size_t>(cur - start)));
 	}
 	else if (*cur == '\"' ) {
 		throw STEP::SyntaxError("binary data not supported yet",line);

+ 1 - 1
revision.h

@@ -1 +1 @@
-#define SVNRevision  1154 
+#define SVNRevision  1257