diff --git a/src/third_party/GMSH2Parser.cpp b/src/third_party/GMSH2Parser.cpp index ca6393c..0da1527 100644 --- a/src/third_party/GMSH2Parser.cpp +++ b/src/third_party/GMSH2Parser.cpp @@ -158,14 +158,16 @@ bool GMSH2Parser::parsePeriodic() { getNextToken(); [[maybe_unused]] const std::size_t entityIdentifyId = expectNonNegativeInt(); - // fixed to 16; the main difference to MSH4.1 - const std::size_t affineSize = 16; - for (std::size_t i = 0; i < affineSize; ++i) { + getNextToken(); + if (curTok == GMSHToken::string) { + // Gmsh msh2 may write: "Affine a11 a12 ... a44" (16 values) + constexpr std::size_t affineSize = 16; + for (std::size_t i = 0; i < affineSize; ++i) { + getNextToken(); + [[maybe_unused]] const double affineValue = expectNumber(); + } getNextToken(); - [[maybe_unused]] const double affineValue = expectNumber(); } - - getNextToken(); const std::size_t identifySize = expectNonNegativeInt(); for (std::size_t i = 0; i < identifySize; ++i) { diff --git a/src/third_party/GMSHLexer.cpp b/src/third_party/GMSHLexer.cpp index dbd04f9..65cbef6 100644 --- a/src/third_party/GMSHLexer.cpp +++ b/src/third_party/GMSHLexer.cpp @@ -112,6 +112,15 @@ GMSHToken GMSHLexer::getToken() { advance(); return GMSHToken::string; } + if (isalpha(lastChar)) { + do { + advance(); + } while (isalpha(lastChar)); + return GMSHToken::string; + } + // Always consume at least one character for unknown tokens to avoid + // getting stuck in an infinite tokenization loop. + advance(); return GMSHToken::unknown_token; }