Don't count key words when determining if the file count evenly divides
the block count in the .visit file format
@@ -2374,6 +2374,11 @@ avtDatabase::NumStagesForFetch(avtDataRequest_p)
// Jim Eliot, Wed 18 Nov 11:30:58 GMT 2015
// Fixed bug (2461) with reading DOS formatted files which uses '\'r
// newline character
+//
+// Burlen Loring, Fri Apr 28 10:21:30 PDT 2017
+// Don't count key words when determining if the file count evenly divides
+// the block count.
+//
// ****************************************************************************
bool
@@ -2398,8 +2403,9 @@ avtDatabase::GetFileListFromTextFile(const char *textfile,
vector<char *> list;
char str_auto[1024];
char str_with_dir[2048];
- int count = 0;
- int badCount = 0;
+ int goodCount = 0; // number of valid lines, keywords and files
+ int badCount = 0; // number of empty and comment lines
+ int fileCount = 0; // number of non empty, non comment, non keyword, lines
int bang_nBlocks = -1;
bool failed = false;
while (!ifile.eof() && !failed && badCount < 10000)
@@ -2432,7 +2438,7 @@ avtDatabase::GetFileListFromTextFile(const char *textfile,
if (str_auto[0] != '\0' && str_auto[0] != '#')
{
char *bnbp = strstr(str_auto, "!NBLOCKS ");
- if (bnbp && bnbp == str_auto && !count)
+ if (bnbp && bnbp == str_auto && !goodCount)
{
errno = 0;
bang_nBlocks = strtol(str_auto + strlen("!NBLOCKS "), 0, 10);
@@ -2454,6 +2460,8 @@ avtDatabase::GetFileListFromTextFile(const char *textfile,
if (str_auto[0] == VISIT_SLASH_CHAR || str_auto[0] == '!' ||
(str_auto_len > 2 && str_auto[1] == ':'))
{
+ // already have an absolute path like /something or C:\something,
+ // or a keyword like !SOMETHING
strcpy(str_with_dir, str_auto);
}
else
@@ -2462,7 +2470,12 @@ avtDatabase::GetFileListFromTextFile(const char *textfile,
}
char *str_heap = CXX_strdup(str_with_dir);
list.push_back(str_heap);
- ++count;
+ ++goodCount;
+
+ // lines of the file starting with ! are keywords and
+ // are not part of the block count
+ if (str_auto[0] != '!')
+ ++fileCount;
}
else
++badCount;
@@ -2470,10 +2483,11 @@ avtDatabase::GetFileListFromTextFile(const char *textfile,
if (bang_nBlocks > 0 && !failed)
{
- if (count % bang_nBlocks)
+ if (fileCount % bang_nBlocks)
{
failed = true;
- debug1 << "File count of " << count << " not evenly divided by !NBLOCKS value of " << bang_nBlocks << endl;
+ debug1 << "File count of " << fileCount << " not evenly divided by "
+ "!NBLOCKS value of " << bang_nBlocks << endl;
}
}
@@ -2487,7 +2501,7 @@ avtDatabase::GetFileListFromTextFile(const char *textfile,
}
else
{
- filelist = new char*[count];
+ filelist = new char*[goodCount];
filelistN = 0;
for (it = list.begin() ; it != list.end() ; ++it)
{
