From b60290258d88d346c71ea2068d6f75c500bb4b0f Mon Sep 17 00:00:00 2001 From: pscrozi Date: Fri, 7 Sep 2012 15:12:39 +0000 Subject: [PATCH] Bug fix to allow table keywords to be subsets of other table keywords. This is an issue pointed to by Andrew Jewett on Sept 6, 2012, and fixed with this change. git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@8753 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/pair_table.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pair_table.cpp b/src/pair_table.cpp index 17e9058b6f..664db47662 100644 --- a/src/pair_table.cpp +++ b/src/pair_table.cpp @@ -19,6 +19,7 @@ #include "math.h" #include "stdlib.h" #include "string.h" +#include "ctype.h" #include "pair_table.h" #include "atom.h" #include "force.h" @@ -343,7 +344,11 @@ void PairTable::read_table(Table *tb, char *file, char *keyword) error->one(FLERR,"Did not find keyword in table file"); if (strspn(line," \t\n\r") == strlen(line)) continue; // blank line if (line[0] == '#') continue; // comment - if (strstr(line,keyword) == line) break; // matching keyword + int i = 0; + while (isalnum(line[i]) || line[i] == '_') i++; + char *word = new char[i]; + strncpy(word,&line[0],i); + if (strcmp(word,keyword) == 0) break; // matching keyword fgets(line,MAXLINE,fp); // no match, skip section param_extract(tb,line); fgets(line,MAXLINE,fp);