mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Prevent localizing the decimal point in gcc<5.
Apparently gcc V4.8 provides a defective implementation of std::locale which first doesn't support std::numpunct and second throws the wrong exception type. Unfortunately boost::locale isn't a solution because it uses the gcc facets. So for now, we don't compile that bit if gcc is too old.
This commit is contained in:
parent
cbe52dad34
commit
75e6a41bd7
@ -26,6 +26,7 @@
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <locale>
|
||||
#include <typeinfo> // For std::bad_cast exception
|
||||
#include "gnc-rational-rounding.hpp"
|
||||
|
||||
class GncRational;
|
||||
@ -349,12 +350,13 @@ std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>&
|
||||
std::locale loc = s.getloc();
|
||||
ss.imbue(loc);
|
||||
char dec_pt = '.';
|
||||
#if __GNUC__ >= 5
|
||||
try
|
||||
{
|
||||
dec_pt = std::use_facet<std::numpunct<char>>(loc).decimal_point();
|
||||
}
|
||||
catch(const std::bad_cast& err) {} //Don't do anything, num_sep is already set.
|
||||
|
||||
#endif
|
||||
ss.copyfmt(s);
|
||||
ss.width(0);
|
||||
if (n.denom() == 1)
|
||||
|
@ -211,6 +211,7 @@ TEST(gncnumeric_stream, output_stream)
|
||||
GncNumeric rational_string(123, 456);
|
||||
output << rational_string;
|
||||
EXPECT_EQ("123/456", output.str());
|
||||
#if __GNUC__ >= 5
|
||||
output.imbue(std::locale("de_DE"));
|
||||
output.str("");
|
||||
output << simple_int;
|
||||
@ -221,6 +222,7 @@ TEST(gncnumeric_stream, output_stream)
|
||||
output.str("");
|
||||
output << rational_string;
|
||||
EXPECT_EQ("123/456", output.str());
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(gncnumeric_stream, input_stream)
|
||||
|
Loading…
Reference in New Issue
Block a user