File tree 1 file changed +10
-3
lines changed 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 14
14
#include < cassert>
15
15
#include < cstring>
16
16
#include < istream>
17
+ #include < sstream>
17
18
18
19
#if defined(_MSC_VER) && _MSC_VER < 1500 // VC++ 8.0 and below
19
20
#define snprintf _snprintf
@@ -589,16 +590,22 @@ bool Reader::decodeDouble(Token& token, Value& decoded) {
589
590
// info:
590
591
//
591
592
// http://developer.apple.com/library/mac/#DOCUMENTATION/DeveloperTools/gcc-4.0.1/gcc/Incompatibilities.html
592
- char format[] = " %lf" ;
593
+ // char format[] = "%lf";
593
594
594
595
if (length <= bufferSize) {
595
596
Char buffer[bufferSize + 1 ];
596
597
memcpy (buffer, token.start_ , length);
597
598
buffer[length] = 0 ;
598
- count = sscanf (buffer, format, &value);
599
+ std::istringstream is (buffer);
600
+ is.imbue (std::locale::classic ());
601
+ is >> value;
602
+ count = (is.good () || is.eof ());
599
603
} else {
600
604
std::string buffer (token.start_ , token.end_ );
601
- count = sscanf (buffer.c_str (), format, &value);
605
+ std::istringstream is (buffer);
606
+ is.imbue (std::locale::classic ());
607
+ is >> value;
608
+ count = (is.good () || is.eof ());
602
609
}
603
610
604
611
if (count != 1 )
You can’t perform that action at this time.
0 commit comments