summaryrefslogtreecommitdiff
path: root/src/reflection.cpp
diff options
context:
space:
mode:
authorWouter van Oortmerssen <aardappel@gmail.com>2020-01-09 11:47:02 -0800
committerWouter van Oortmerssen <aardappel@gmail.com>2020-01-09 11:48:09 -0800
commit55686100aa6f8b4867e8de62768d8fc0ecc5a541 (patch)
treee6308ea6cc02a0457a7b020424b0f4490531e721 /src/reflection.cpp
parent718351831dbb1c047d8f93e5181c3c083ca0b5d2 (diff)
downloadflatbuffers-55686100aa6f8b4867e8de62768d8fc0ecc5a541.tar.gz
flatbuffers-55686100aa6f8b4867e8de62768d8fc0ecc5a541.tar.bz2
flatbuffers-55686100aa6f8b4867e8de62768d8fc0ecc5a541.zip
Changed direct calls to strtod to use StringToNumber
StringToNumber will correctly use locale-insensitive functions when available. Change-Id: I6bde11039a541634186f8f791012af2eb0d86b8d
Diffstat (limited to 'src/reflection.cpp')
-rw-r--r--src/reflection.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/reflection.cpp b/src/reflection.cpp
index 409dbd03..77ea0dcf 100644
--- a/src/reflection.cpp
+++ b/src/reflection.cpp
@@ -56,7 +56,13 @@ double GetAnyValueF(reflection::BaseType type, const uint8_t *data) {
case reflection::String: {
auto s =
reinterpret_cast<const String *>(ReadScalar<uoffset_t>(data) + data);
- return s ? strtod(s->c_str(), nullptr) : 0.0;
+ if (s) {
+ double d;
+ StringToNumber(s->c_str(), &d);
+ return d;
+ } else {
+ return 0.0;
+ }
}
default: return static_cast<double>(GetAnyValueI(type, data));
}
@@ -149,9 +155,12 @@ void SetAnyValueF(reflection::BaseType type, uint8_t *data, double val) {
void SetAnyValueS(reflection::BaseType type, uint8_t *data, const char *val) {
switch (type) {
case reflection::Float:
- case reflection::Double:
- SetAnyValueF(type, data, strtod(val, nullptr));
+ case reflection::Double: {
+ double d;
+ StringToNumber(val, &d);
+ SetAnyValueF(type, data, d);
break;
+ }
// TODO: support strings.
default: SetAnyValueI(type, data, StringToInt(val)); break;
}