[c++ options] Fix locale dependency in test-gnc-option-scheme-output.

Created by using std::to_string() in GncOptionRangeValue::serialize.
It wraps sprintf that reads the locale. Use ostringstream instead.
This commit is contained in:
John Ralls 2023-03-02 12:19:19 -08:00
parent e9f6bf7a5c
commit 1eecb9f5c0
2 changed files with 8 additions and 3 deletions

View File

@ -139,7 +139,7 @@
" (if (exact-integer? value)
(if (< value 100)
(format #f "'(percent . ~d)" value)
(format #f "'(pixels . ~f)" value))
(format #f "'(pixels . ~d)" value))
(format #f "'~f" value)
)))

View File

@ -21,7 +21,6 @@
* *
\********************************************************************/
//#include "options.h"
#include "gnc-option-impl.hpp"
#include "gnc-datetime.hpp"
#include "guid.hpp"
@ -832,7 +831,13 @@ template <typename ValueType> std::string
GncOptionRangeValue<ValueType>::serialize() const noexcept
{
if constexpr (std::is_arithmetic_v<ValueType>)
return std::to_string(m_value);
{
std::ostringstream ostr;
if constexpr(is_same_decayed_v<ValueType, double>)
ostr << std::showpoint << std::fixed;
ostr << m_value;
return ostr.str();
}
return "";
}