minor update, use string for comparison

This commit is contained in:
Yaser Afshar
2021-09-15 07:07:23 -05:00
parent 085606454b
commit 6873001fec

View File

@ -15,9 +15,9 @@
#include "atom.h" #include "atom.h"
#include "comm.h" #include "comm.h"
#include "error.h"
#include "force.h" #include "force.h"
#include "memory.h" #include "memory.h"
#include "error.h"
#include <cstring> #include <cstring>
@ -74,34 +74,34 @@ void LabelMap::modify_lmap(int narg, char **arg)
int ntypes; int ntypes;
std::vector<std::string> *labels; std::vector<std::string> *labels;
if (!strcmp(arg[0],"atom")) { const std::string tlabel(arg[0]);
if (tlabel == "atom") {
ntypes = natomtypes; ntypes = natomtypes;
labels = &typelabel; labels = &typelabel;
} else if (!strcmp(arg[0],"bond")) { } else if (tlabel == "bond") {
ntypes = nbondtypes; ntypes = nbondtypes;
labels = &btypelabel; labels = &btypelabel;
} else if (!strcmp(arg[0],"angle")) { } else if (tlabel == "angle") {
ntypes = nangletypes; ntypes = nangletypes;
labels = &atypelabel; labels = &atypelabel;
} else if (!strcmp(arg[0],"dihedral")) { } else if (tlabel == "dihedral") {
ntypes = ndihedraltypes; ntypes = ndihedraltypes;
labels = &dtypelabel; labels = &dtypelabel;
} else if (!strcmp(arg[0],"improper")) { } else if (tlabel == "improper") {
ntypes = nimpropertypes; ntypes = nimpropertypes;
labels = &itypelabel; labels = &itypelabel;
} else error->all(FLERR,"Illegal labelmap command"); } else error->all(FLERR,"Illegal labelmap command");
int itype; int itype;
int iarg = 1; int iarg = 1;
char *charlabel;
while (iarg < narg) { while (iarg < narg) {
itype = utils::inumeric(FLERR,arg[iarg++],false,lmp); itype = utils::inumeric(FLERR,arg[iarg++],false,lmp);
charlabel = arg[iarg++];
if (itype > ntypes) if (itype > ntypes)
error->all(FLERR,"Topology type exceeds system topology type"); error->all(FLERR,"Topology type exceeds system topology type");
if (isdigit(charlabel[0])) std::string slabel(arg[iarg++]);
if (isdigit(slabel[0]))
error->all(FLERR,"Type labels cannot start with a number"); error->all(FLERR,"Type labels cannot start with a number");
(*labels)[itype-1] = charlabel; (*labels)[itype-1] = slabel;
} }
} }