From cdb7f9d6e9c7a821d447d5c3c99e7b5eb6a03963 Mon Sep 17 00:00:00 2001 From: Greg Sjaardema Date: Fri, 8 Mar 2024 09:56:47 -0700 Subject: [PATCH] EXODIFF: Fix so command_file parsing can handle arbitrarily long line --- .../applications/exodiff/ED_SystemInterface.C | 79 ++++--------------- .../seacas/applications/exodiff/ED_Version.h | 4 +- 2 files changed, 18 insertions(+), 65 deletions(-) diff --git a/packages/seacas/applications/exodiff/ED_SystemInterface.C b/packages/seacas/applications/exodiff/ED_SystemInterface.C index 482ec97e81..775d629634 100644 --- a/packages/seacas/applications/exodiff/ED_SystemInterface.C +++ b/packages/seacas/applications/exodiff/ED_SystemInterface.C @@ -24,9 +24,8 @@ #include 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)); } @@ -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; @@ -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)) { @@ -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)) { @@ -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)) { @@ -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)) { @@ -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)) { @@ -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)) { @@ -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)) { @@ -1406,13 +1365,7 @@ 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 { @@ -1420,7 +1373,7 @@ void SystemInterface::Parse_Command_File() } } - cmd_file.getline(line, 256); + std::getline(cmd_file, line); xline = line; } } @@ -1430,7 +1383,7 @@ namespace { Tolerance &def_tol, std::vector &names, std::vector &toler) { - char line[256]; + std::string line{}; toler.clear(); names.clear(); @@ -1557,7 +1510,7 @@ namespace { } } - cmd_file.getline(line, 256); + std::getline(cmd_file, line); xline = line; while (!cmd_file.eof()) { if (xline.empty() || @@ -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; } @@ -1653,7 +1606,7 @@ namespace { } } - cmd_file.getline(line, 256); + std::getline(cmd_file, line); xline = line; } diff --git a/packages/seacas/applications/exodiff/ED_Version.h b/packages/seacas/applications/exodiff/ED_Version.h index 08b16c94c4..88e598a287 100644 --- a/packages/seacas/applications/exodiff/ED_Version.h +++ b/packages/seacas/applications/exodiff/ED_Version.h @@ -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");