Skip to content

Commit

Permalink
Some additional checks for the MacOS workaround for Issue beltoforion…
Browse files Browse the repository at this point in the history
  • Loading branch information
nalinigans committed Feb 28, 2023
1 parent 8e88b81 commit 739fcc9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions parser/mpValReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include "mpError.h"

#ifdef __APPLE__
#include<regex>
#include <regex>
#endif


Expand Down Expand Up @@ -69,9 +69,11 @@ bool DblValReader::IsValue(const char_type* a_szExpr, int& a_iPos, Value& a_Val)
{
#ifdef __APPLE__
// Workaround for clang not parsing strings like 3i with std::stringstream(imaginary numbers)
// See https://discourse.llvm.org/t/different-behavior-from-stringstream-operator-in-libc-vs-libstdc/57482
// See https://discourse.llvm.org/t/different-behavior-from-stringstream-operator-in-libc-vs-libstdc/57482
// yields 3 groups if successful. The 2nd and 3rd groups when present together as in 3i or 2n is what
// clang does differently compared to gcc and visual studio
// 1 2 3
std::regex pattern("(\\s*)(\\d*\\.*\\d*)(\\w*).*"); // yields 3 groups if successful
std::regex pattern("(\\s*)(\\d+\\.*\\d*)(\\w+).*");
std::smatch match;
std::string str(a_szExpr+ a_iPos);
if (std::regex_match(str, match, pattern) && match.size() == 4 && match[3].length() == 1)
Expand Down

0 comments on commit 739fcc9

Please sign in to comment.