From e3096036b5bece607c42de18e817c5575850f942 Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Sat, 6 Jun 2026 12:08:01 +0200 Subject: [PATCH] PStringUtils::ToDouble: signal conversion errors like ToInt ToDouble() had the same shortcoming as ToInt(): wrapping strtod() with a nullptr endptr made a failed conversion indistinguishable from a legitimate 0.0. Add an optional `bool *ok` out-parameter that reports success. strtod() (with endptr + errno) is kept instead of std::from_chars so the accepted input set stays identical to TString::Atof() (leading whitespace skipped, leading '+' honoured, trailing characters ignored); ok is set false on a non-numeric string or an ERANGE overflow. The parameter defaults to nullptr, so existing call sites keep compiling unchanged. Convert the IsFloat-guarded ToDouble call sites in PMsrHandler to the single-parse ToDouble(token, &ok) form (replacing the IsFloat() guard + separate ToDouble() that parsed every token twice). All downstream >=0 / <=0 / range checks are preserved, and push_back sites only append on success so no spurious 0.0 is stored on error. Number-vs-keyword discriminators (pos.error/boundary "none", rrf_phase/fourier-phase parX) are restructured so the keyword branch is taken when ok is false. As a side effect this fixes a latent gap in the GLOBAL rrf_freq handler, where a non-numeric frequency previously slipped through with a stale value instead of raising an error. The IsFloat-guarded ToInt fit-range offsets (fgb/lgb) are intentionally left untouched, as there the guard type differs from the conversion. All 85 integration tests pass. Co-Authored-By: Claude Opus 4.8 --- src/classes/PMsrHandler.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/classes/PMsrHandler.cpp b/src/classes/PMsrHandler.cpp index 81fa385e..027df28d 100644 --- a/src/classes/PMsrHandler.cpp +++ b/src/classes/PMsrHandler.cpp @@ -4807,6 +4807,8 @@ Bool_t PMsrHandler::HandlePlotEntry(PMsrLines &lines) param.fRRFPhase = fParam[no-1].fValue; } } + } else { + error = true; } } } else if (iter1->fLine.Contains("rrf_packing", TString::kIgnoreCase)) {