From d6dbdfdbe64f2083f98064afe9c88afbc9a84e09 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 2 Mar 2021 15:53:17 -0500 Subject: [PATCH] detect and warn about unknown header keywords (instead of error out on an empty line) --- src/molecule.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/molecule.cpp b/src/molecule.cpp index 58d6bc9cc4..aede487868 100644 --- a/src/molecule.cpp +++ b/src/molecule.cpp @@ -480,10 +480,16 @@ void Molecule::read(int flag) nibody = values.next_int(); ndbody = values.next_int(); nwant = 3; - } else break; - + } else { + // unknown header keyword + if (utils::strmatch(text,"^\\d+\\s+\\S+")) { + values.next_int(); + auto keyword = values.next_string(); + error->one(FLERR,fmt::format("Invalid header keyword: {}",keyword)); + } else break; + } if (nmatch != nwant) - error->one(FLERR,"Invalid header in molecule file"); + error->one(FLERR,"Invalid header line format in molecule file"); } catch (TokenizerException &e) { error->one(FLERR, fmt::format("Invalid header in molecule file\n" "{}", e.what()));