From 122501563632fd8239e9609f3127213123575196 Mon Sep 17 00:00:00 2001 From: Geoff Hutchison Date: Tue, 17 Oct 2023 14:37:13 -0400 Subject: [PATCH] Fix bug in Hall group perception with " for = files Signed-off-by: Geoff Hutchison --- avogadro/core/spacegroups.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/avogadro/core/spacegroups.cpp b/avogadro/core/spacegroups.cpp index f8a32a23e6..e89ffbbe00 100644 --- a/avogadro/core/spacegroups.cpp +++ b/avogadro/core/spacegroups.cpp @@ -28,31 +28,34 @@ unsigned short SpaceGroups::hallNumber(const std::string& spaceGroup) { unsigned short hall = 0; // can't find anything const unsigned short hall_count = 530; + // some files use " instead of = for the space group symbol + std::string sg = spaceGroup; + std::replace(sg.begin(), sg.end(), '"', '='); // space_group_hall_symbol for (unsigned short i = 0; i < hall_count; ++i) { - if (spaceGroup == space_group_hall_symbol[i]) { + if (sg == space_group_hall_symbol[i]) { return i; // found a match } } // space_group_international for (unsigned short i = 0; i < hall_count; ++i) { - if (spaceGroup == space_group_international[i]) { + if (sg == space_group_international[i]) { return i; // found a match } } // space_group_international_short for (unsigned short i = 0; i < hall_count; ++i) { - if (spaceGroup == space_group_international_short[i]) { + if (sg == space_group_international_short[i]) { return i; // found a match } } // space_group_international_full for (unsigned short i = 0; i < hall_count; ++i) { - if (spaceGroup == space_group_international_full[i]) { + if (sg == space_group_international_full[i]) { return i; // found a match } }