From ff6cbd788849961a2ed1767488c7194efc9a0602 Mon Sep 17 00:00:00 2001 From: Paul Bauer Date: Fri, 15 Mar 2019 16:27:37 +0100 Subject: [PATCH] Fix case insensitive string comparison Changed instances of string comparison back to use same order as in original code, and revert one change for comparison over length to original code. Change-Id: I07c3ccce93c37ff897365d80c0ff384e29aa6322 --- src/gromacs/gmxpreprocess/pdb2top.cpp | 6 ++---- src/gromacs/gmxpreprocess/resall.cpp | 2 +- src/gromacs/topology/residuetypes.cpp | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/gromacs/gmxpreprocess/pdb2top.cpp b/src/gromacs/gmxpreprocess/pdb2top.cpp index bf7ea227ca..584ba950fa 100644 --- a/src/gromacs/gmxpreprocess/pdb2top.cpp +++ b/src/gromacs/gmxpreprocess/pdb2top.cpp @@ -1143,10 +1143,8 @@ static bool atomname_cmp_nr(const char *anm, const MoleculePatch *patch, int *nr } else { - std::string tmp = anm; - tmp.erase(tmp.end() - 1); - return (tmp.length() == patch->nname.length() && - gmx::equalCaseInsensitive(tmp, patch->nname)); + return (strlen(anm) == patch->nname.length() + 1 && + gmx_strncasecmp(anm, patch->nname.c_str(), patch->nname.length()) == 0); } } } diff --git a/src/gromacs/gmxpreprocess/resall.cpp b/src/gromacs/gmxpreprocess/resall.cpp index aace595218..fac51b47a2 100644 --- a/src/gromacs/gmxpreprocess/resall.cpp +++ b/src/gromacs/gmxpreprocess/resall.cpp @@ -433,7 +433,7 @@ void readResidueDatabase(const std::string &rrdb, std::vector auto found = std::find_if(rtpDBEntry->begin(), rtpDBEntry->end()-1, [&res](const PreprocessResidue &entry) - { return gmx::equalCaseInsensitive(res->resname, entry.resname); }); + { return gmx::equalCaseInsensitive(entry.resname, res->resname); }); if (found == rtpDBEntry->end() - 1) { diff --git a/src/gromacs/topology/residuetypes.cpp b/src/gromacs/topology/residuetypes.cpp index 9331c99508..558c8a45e7 100644 --- a/src/gromacs/topology/residuetypes.cpp +++ b/src/gromacs/topology/residuetypes.cpp @@ -113,7 +113,7 @@ residueEntryByResidueName(gmx::ArrayRef entries, const s { return std::find_if(entries.begin(), entries.end(), [&residueName](const ResidueTypeEntry &old) - { return gmx::equalCaseInsensitive(residueName, old.residueName); }); + { return gmx::equalCaseInsensitive(old.residueName, residueName); }); } bool ResidueType::nameIndexedInResidueTypes(const std::string &residueName) -- 2.11.4.GIT