From 73945b1912e93f36d915ee27a6f44ae19cd31733 Mon Sep 17 00:00:00 2001
From: Sven Buijssen <sven.buijssen@tu-dortmund.de>
Date: Wed, 15 Jun 2011 12:10:32 +0200
Subject: [PATCH] BUG: Fix for BUG #2886. AVS UCD reader could choke on
 leading comment lines

---
 IO/vtkAVSucdReader.cxx |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/IO/vtkAVSucdReader.cxx b/IO/vtkAVSucdReader.cxx
index 214dd11..50c230f 100644
--- a/IO/vtkAVSucdReader.cxx
+++ b/IO/vtkAVSucdReader.cxx
@@ -220,12 +220,24 @@ int vtkAVSucdReader::RequestInformation(
     this->FileStream = NULL;
 
     this->FileStream = new ifstream(this->FileName, ios::in);
-    char c='\0', buf[100];
-    while(this->FileStream->get(c) && c == '#')
+    char c='\0';
+    while (!FileStream->eof())
       {
-      this->FileStream->get(buf, 100, '\n'); this->FileStream->get(c);
+      // skip leading whitespace
+      while(isspace(FileStream->peek()))
+        {
+        FileStream->get(c);
+        }
+      // skip comment lines
+      if (FileStream->peek() == '#')
+        {
+        while(this->FileStream->get(c) && c != '\n');
+        }
+      else
+        {
+        break;
+        }
       }
-    this->FileStream->putback(c);
 
     *(this->FileStream) >> this->NumberOfNodes;
     *(this->FileStream) >> this->NumberOfCells;
-- 
1.7.5.4

