Skip to content

Commit

Permalink
EXODIFF: Fix so command_file parsing can handle arbitrarily long line
Browse files Browse the repository at this point in the history
  • Loading branch information
gsjaardema committed Mar 8, 2024
1 parent 15070dc commit cdb7f9d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 65 deletions.
79 changes: 16 additions & 63 deletions packages/seacas/applications/exodiff/ED_SystemInterface.C
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@
#include <SL_tokenize.h>

namespace {
[[noreturn]] void Parse_Die(const char *line)
[[noreturn]] void Parse_Die(std::string &sline)
{
std::string sline = line;
chop_whitespace(sline);
Error(fmt::format("parsing input file, currently at \"{}\".\n", sline));
}
Expand Down Expand Up @@ -903,9 +902,9 @@ void SystemInterface::Parse_Command_File()
std::ifstream cmd_file(command_file, std::ios::in);
SMART_ASSERT(cmd_file.good());

char line[256];
std::string line;
std::string xline, tok2, tok3;
cmd_file.getline(line, 256);
std::getline(cmd_file, line);
xline = line;
while (!cmd_file.eof()) {
std::string tok1;
Expand Down Expand Up @@ -1212,13 +1211,7 @@ void SystemInterface::Parse_Command_File()

Check_Parsed_Names(glob_var_names, glob_var_do_all_flag);

if (!xline.empty()) {
copy_string(line, xline);
}
else {
copy_string(line, "");
}

line = xline;
continue;
}
else if (abbreviation(tok1, "nodal", 4) && abbreviation(tok2, "variables", 3)) {
Expand All @@ -1228,13 +1221,7 @@ void SystemInterface::Parse_Command_File()

Check_Parsed_Names(node_var_names, node_var_do_all_flag);

if (!xline.empty()) {
copy_string(line, xline);
}
else {
copy_string(line, "");
}

line = xline;
continue;
}
else if (abbreviation(tok1, "element", 4) && abbreviation(tok2, "variables", 3)) {
Expand All @@ -1244,13 +1231,7 @@ void SystemInterface::Parse_Command_File()

Check_Parsed_Names(elmt_var_names, elmt_var_do_all_flag);

if (!xline.empty()) {
copy_string(line, xline);
}
else {
copy_string(line, "");
}

line = xline;
continue;
}
else if (tok1 == "nodeset" && abbreviation(tok2, "variables", 3)) {
Expand All @@ -1260,13 +1241,7 @@ void SystemInterface::Parse_Command_File()

Check_Parsed_Names(ns_var_names, ns_var_do_all_flag);

if (!xline.empty()) {
copy_string(line, xline);
}
else {
copy_string(line, "");
}

line = xline;
continue;
}
else if (abbreviation(tok1, "sideset", 4) && abbreviation(tok2, "variables", 3)) {
Expand All @@ -1276,13 +1251,7 @@ void SystemInterface::Parse_Command_File()

Check_Parsed_Names(ss_var_names, ss_var_do_all_flag);

if (!xline.empty()) {
copy_string(line, xline);
}
else {
copy_string(line, "");
}

line = xline;
continue;
}
else if (abbreviation(tok1, "sideset", 4) && abbreviation(tok2, "distribution", 4)) {
Expand Down Expand Up @@ -1376,12 +1345,7 @@ void SystemInterface::Parse_Command_File()

Check_Parsed_Names(eb_var_names, eb_var_do_all_flag);

if (!xline.empty()) {
copy_string(line, xline);
}
else {
copy_string(line, "");
}
line = xline;
continue;
}
else if (abbreviation(tok1, "faceblock", 4) && abbreviation(tok2, "variables", 3)) {
Expand All @@ -1391,12 +1355,7 @@ void SystemInterface::Parse_Command_File()

Check_Parsed_Names(fb_var_names, fb_var_do_all_flag);

if (!xline.empty()) {
copy_string(line, xline);
}
else {
copy_string(line, "");
}
line = xline;
continue;
}
else if (abbreviation(tok1, "element", 4) && abbreviation(tok2, "attributes", 3)) {
Expand All @@ -1406,21 +1365,15 @@ void SystemInterface::Parse_Command_File()

Check_Parsed_Names(elmt_att_names, elmt_att_do_all_flag);

if (!xline.empty()) {
copy_string(line, xline);
}
else {
copy_string(line, "");
}

line = xline;
continue;
}
else {
Parse_Die(line);
}
}

cmd_file.getline(line, 256);
std::getline(cmd_file, line);
xline = line;
}
}
Expand All @@ -1430,7 +1383,7 @@ namespace {
Tolerance &def_tol, std::vector<std::string> &names,
std::vector<Tolerance> &toler)
{
char line[256];
std::string line{};

toler.clear();
names.clear();
Expand Down Expand Up @@ -1557,7 +1510,7 @@ namespace {
}
}

cmd_file.getline(line, 256);
std::getline(cmd_file, line);
xline = line;
while (!cmd_file.eof()) {
if (xline.empty() ||
Expand All @@ -1580,7 +1533,7 @@ namespace {
names.push_back(tok);
toler.push_back(def_tol);
}
cmd_file.getline(line, 256);
std::getline(cmd_file, line);
xline = line;
continue;
}
Expand Down Expand Up @@ -1653,7 +1606,7 @@ namespace {
}
}

cmd_file.getline(line, 256);
std::getline(cmd_file, line);
xline = line;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/seacas/applications/exodiff/ED_Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
// See packages/seacas/LICENSE for details
#pragma once

static const std::string version("3.31");
static const std::string verdate("2024-01-10");
static const std::string version("3.32");
static const std::string verdate("2024-03-08");

0 comments on commit cdb7f9d

Please sign in to comment.