Browse Source

*** empty log message ***

David Rose 25 years ago
parent
commit
51f840d6f0
1 changed files with 43 additions and 39 deletions
  1. 43 39
      pandatool/src/fltegg/fltToEggConverter.cxx

+ 43 - 39
pandatool/src/fltegg/fltToEggConverter.cxx

@@ -461,52 +461,56 @@ parse_comment(const FltRecord *flt_record, const string &name,
   string comment = flt_record->get_comment();
   string comment = flt_record->get_comment();
 
 
   // Scan for <egg>.
   // Scan for <egg>.
+  static const string egg_str = "<egg>";
+
   size_t p;
   size_t p;
   p = 0;
   p = 0;
+  while (p < comment.length() && 
+	 cmp_nocase(comment.substr(p, 5), egg_str) != 0) {
+    p++;
+  }
+   
+  if (p >= comment.length()) {
+    // No "<egg>" in the comment.
+    return true;
+  }
 
 
-  static const string egg_str = "<egg>";
+  p += 5;
+  // Now scan past whitespace for the open curly brace.
+  while (p < comment.length() && isspace(comment[p])) {
+    ++p;
+  }
+  if (p >= comment.length() || comment[p] != '{') {
+    nout << "No opening brace in comment for " 
+	 << name << "\n\n";
+    _error = true;
+    return false;
+  }
 
 
-  while (p < comment.length()) {
-    if (cmp_nocase(comment.substr(p, 5), egg_str) == 0) {
-      p += 5;
-      // Now scan past whitespace for the open curly brace.
-      while (p < comment.length() && isspace(comment[p])) {
-	++p;
-      }
-      if (p < comment.length() && comment[p] == '{') {
-	// Here's the beginning.  Now lop off the closing brace at the
-	// end.
-	++p;
-	size_t q = comment.length() - 1;
-	while (q > p && comment[q] != '}') {
-	  --q;
-	}
-	if (q == p) {
-	  nout << "No closing brace in comment for " 
-	       << name << "\n\n";
-	  _error = true;
-	  return false;
-	}
-	string egg_syntax = comment.substr(p, q - p);
+  // Here's the beginning of the string after "<egg> {".  Now lop off
+  // the closing brace at the end.
+  ++p;
+  size_t q = comment.length() - 1;
+  while (q > p && comment[q] != '}') {
+    --q;
+  }
+  if (q == p) {
+    nout << "No closing brace in comment for " 
+	 << name << "\n\n";
+    _error = true;
+    return false;
+  }
 
 
-	if (!egg_node->parse_egg(egg_syntax)) {
-	  nout << "Syntax error in comment for "
-	       << name << "\n\n";
-	  _error = true;
-	  return false;
-	}
-	// Correctly parsed!
-	return true;
-      }
-      nout << "No opening brace in comment for " 
-	   << name << "\n\n";
-      _error = true;
-      return false;
-    }
-    p++;
+  string egg_syntax = comment.substr(p, q - p);
+  
+  if (!egg_node->parse_egg(egg_syntax)) {
+    nout << "Syntax error in comment for "
+	 << name << "\n\n";
+    _error = true;
+    return false;
   }
   }
 
 
-  // No <egg> appears in this comment.
+  // Correctly parsed!
   return true;
   return true;
 }
 }