Skip to content

Commit

Permalink
Fix: Loading Files Again (AMReX-Codes#2936)
Browse files Browse the repository at this point in the history
This enables that `amrex::ParmParse::addfile` can be called
multiple times. Before this, we accidentially overwrite the
`FILE` static keyword.

Follow-up to AMReX-Codes#2842
  • Loading branch information
ax3l authored Sep 6, 2022
1 parent 8f8198c commit 35ed6b4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Src/Base/AMReX_ParmParse.H
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ public:
const std::string& val);

//! keyword for files to load
static std::string FileKeyword;
static std::string const FileKeyword;

//! Add keys and values from a file to the end of the PP table.
static void addfile (std::string const filename);
Expand Down
8 changes: 5 additions & 3 deletions Src/Base/AMReX_ParmParse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ static bool finalize_verbose = false;
static bool finalize_verbose = true;
#endif

std::string ParmParse::FileKeyword = "FILE";
std::string const ParmParse::FileKeyword = "FILE";

//
// Used by constructor to build table.
Expand Down Expand Up @@ -609,7 +609,8 @@ addDefn (std::string& def,
tab.push_back(ParmParse::PP_entry(def,val));
}
val.clear();
def = std::string();
if ( def != ParmParse::FileKeyword )
def = std::string();
}

void
Expand Down Expand Up @@ -991,7 +992,8 @@ ParmParse::prefixedName (const std::string& str) const
void
ParmParse::addfile (std::string const filename) {
auto l = std::list<std::string>{filename};
addDefn(FileKeyword,
auto file = FileKeyword;
addDefn(file,
l,
g_table);
}
Expand Down

0 comments on commit 35ed6b4

Please sign in to comment.