From a815fcfbad1263dbd4da66f78af688bcbed96161 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 16 May 2026 12:19:50 +0000 Subject: [PATCH 1/2] Make parse_csv_float locale-independent using std::istringstream with C locale Agent-Logs-Url: https://github.com/audiohacking/acestep.cpp/sessions/2329eeb3-4e21-4d6b-8232-3e78627581e0 Co-authored-by: lmangani <1423657+lmangani@users.noreply.github.com> --- src/pipeline-synth-ops.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/pipeline-synth-ops.cpp b/src/pipeline-synth-ops.cpp index cc97350..06d377c 100644 --- a/src/pipeline-synth-ops.cpp +++ b/src/pipeline-synth-ops.cpp @@ -12,11 +12,11 @@ #include "task-types.h" #include "vae-enc.h" -#include #include #include -#include #include +#include +#include #include #include #include @@ -26,8 +26,8 @@ static const int FRAMES_PER_SECOND = 25; // CSV list parsers tolerant to any whitespace around commas. Bail on first // parse error or overflow, returning the values consumed so far. // Integer variant uses std::from_chars (locale-immune, C++17 charconv). -// Float variant uses std::strtof for portability (Apple Clang lacks the -// floating-point overload of std::from_chars on some SDK versions). +// Float variant uses std::istringstream imbued with the C locale so that +// decimal parsing is locale-independent on all platforms. static std::vector parse_csv_int(const std::string & s) { std::vector out; const char * first = s.data(); @@ -54,6 +54,8 @@ static std::vector parse_csv_float(const std::string & s) { std::vector out; const char * first = s.data(); const char * last = first + s.size(); + std::istringstream ss; + ss.imbue(std::locale::classic()); while (first < last) { while (first < last && (*first == ',' || *first == ' ')) { ++first; @@ -61,14 +63,19 @@ static std::vector parse_csv_float(const std::string & s) { if (first == last) { break; } - char * end = nullptr; - errno = 0; - float v = std::strtof(first, &end); - if (end == first || errno == ERANGE) { + // Find the end of this token (next comma or end of string). + const char * token_end = first; + while (token_end < last && *token_end != ',') { + ++token_end; + } + ss.clear(); + ss.str(std::string(first, token_end)); + float v{}; + if (!(ss >> v)) { break; } out.push_back(v); - first = end; + first = token_end; } return out; } From 6514d53131d5d3b5adbe40449be8f9ec991cac6a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 16 May 2026 12:20:36 +0000 Subject: [PATCH 2/2] Reuse string buffer across iterations and validate full token consumption with ss.eof() Agent-Logs-Url: https://github.com/audiohacking/acestep.cpp/sessions/2329eeb3-4e21-4d6b-8232-3e78627581e0 Co-authored-by: lmangani <1423657+lmangani@users.noreply.github.com> --- src/pipeline-synth-ops.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pipeline-synth-ops.cpp b/src/pipeline-synth-ops.cpp index 06d377c..1ad88a7 100644 --- a/src/pipeline-synth-ops.cpp +++ b/src/pipeline-synth-ops.cpp @@ -56,6 +56,7 @@ static std::vector parse_csv_float(const std::string & s) { const char * last = first + s.size(); std::istringstream ss; ss.imbue(std::locale::classic()); + std::string token; while (first < last) { while (first < last && (*first == ',' || *first == ' ')) { ++first; @@ -68,10 +69,11 @@ static std::vector parse_csv_float(const std::string & s) { while (token_end < last && *token_end != ',') { ++token_end; } + token.assign(first, token_end); ss.clear(); - ss.str(std::string(first, token_end)); + ss.str(token); float v{}; - if (!(ss >> v)) { + if (!(ss >> v) || !ss.eof()) { break; } out.push_back(v);