From c843349d35432d0504552995085cada7f10319b1 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 13 Jun 2023 09:14:28 +0200 Subject: [PATCH] GCodeLine::has_value now uses locale-independent functions for parsing: This will hopefully fix the mysterious issues #10380 #10331 #10542. The reason is not exactly clear, seems similar to https://stackoverflow.com/questions/76133503/strtod-does-not-respect-locale-on-macos-13-3-1. Possibly a bug in macOS 13.3.1 --- src/libslic3r/GCodeReader.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libslic3r/GCodeReader.cpp b/src/libslic3r/GCodeReader.cpp index a45ea8439..cb0366757 100644 --- a/src/libslic3r/GCodeReader.cpp +++ b/src/libslic3r/GCodeReader.cpp @@ -243,9 +243,10 @@ bool GCodeReader::GCodeLine::has_value(char axis, float &value) const if (c == nullptr) return false; // Try to parse the numeric value. - char *pend = nullptr; - double v = strtod(++ c, &pend); - if (pend != nullptr && is_end_of_word(*pend)) { + double v = 0.; + const char* end = m_raw.c_str() + m_raw.size(); + auto [pend, ec] = fast_float::from_chars(++c, end, v); + if (pend != c && is_end_of_word(*pend)) { // The axis value has been parsed correctly. value = float(v); return true;