From db2eefae5c2d35f3bd4ccfc3a2d4c0848424c50a Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 11 Jan 2021 16:12:31 -0500 Subject: [PATCH] consistently allow comments in molecule file section headers --- src/molecule.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/molecule.cpp b/src/molecule.cpp index 819083e0b3..5d71db68e6 100644 --- a/src/molecule.cpp +++ b/src/molecule.cpp @@ -610,7 +610,8 @@ void Molecule::read(int flag) dbodyflag = 1; body(flag,1,line); - } else error->one(FLERR,"Unknown section in molecule file"); + } else error->one(FLERR,fmt::format("Unknown section '{}' in molecule " + "file", keyword)); parse_keyword(1,line,keyword); } @@ -2004,10 +2005,10 @@ void Molecule::parse_keyword(int flag, char *line, char *keyword) MPI_Bcast(line,n,MPI_CHAR,0,world); } - // copy non-whitespace portion of line into keyword + // copy non-whitespace and non-comment portion of line into keyword int start = strspn(line," \t\n\r"); - int stop = strlen(line) - 1; + int stop = strcspn(line,"#") - 1; while (line[stop] == ' ' || line[stop] == '\t' || line[stop] == '\n' || line[stop] == '\r') stop--; line[stop+1] = '\0';