Skip to content

Commit

Permalink
MSVC's regex implementation is different
Browse files Browse the repository at this point in the history
  • Loading branch information
dankmolot committed Sep 24, 2023
1 parent 2a3a2a7 commit aaf73df
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions source/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ std::unordered_map<int, int> ParseYueLines(std::string_view code) {

std::unordered_map<int, int> line_map;
Utils::Split(code, [&](auto line, auto num) {
std::match_results<std::string_view::const_iterator> match;
std::cmatch match;
if (std::regex_search(line.cbegin(), line.cend(), match, YUE_LINE_REGEX)) {
int source_line = std::atoi(match[1].first);
int source_line = std::stoi(match[1].str());
line_map[num] = source_line;
}
});
Expand Down
3 changes: 2 additions & 1 deletion source/errors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ void Errors::TransformStackEntry(GarrysMod::Lua::ILuaGameCallback::CLuaError::St
std::optional<GarrysMod::Lua::ILuaGameCallback::CLuaError::StackEntry> Errors::TransformErrorMessage(std::string& err) {
static std::regex ERROR_MESSAGE_REGEX("^(.*?):(\\d+): (.+)$",
std::regex_constants::optimize | std::regex_constants::ECMAScript);

std::smatch match;
if (std::regex_search(err, match, ERROR_MESSAGE_REGEX)) {
GarrysMod::Lua::ILuaGameCallback::CLuaError::StackEntry entry;
entry.source = match[1].str();
entry.line = std::atoi(match[2].first.base());
entry.line = std::stoi(match[2].str());
std::string message = match[3].str();

TransformStackEntry(entry);
Expand Down

0 comments on commit aaf73df

Please sign in to comment.