Unverified Commit 43c3abf0 authored by Adam Cozzette's avatar Adam Cozzette Committed by GitHub

Merge pull request #5489 from aaron-bray/master

Use NoLocalStrtod for international compliance
parents 152c8301 42430821
......@@ -7,6 +7,7 @@ set(libprotobuf_lite_files
${protobuf_source_dir}/src/google/protobuf/implicit_weak_message.cc
${protobuf_source_dir}/src/google/protobuf/parse_context.cc
${protobuf_source_dir}/src/google/protobuf/io/coded_stream.cc
${protobuf_source_dir}/src/google/protobuf/io/strtod.cc
${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream.cc
${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_impl_lite.cc
${protobuf_source_dir}/src/google/protobuf/message_lite.cc
......@@ -33,6 +34,7 @@ set(libprotobuf_lite_includes
${protobuf_source_dir}/src/google/protobuf/implicit_weak_message.h
${protobuf_source_dir}/src/google/protobuf/parse_context.h
${protobuf_source_dir}/src/google/protobuf/io/coded_stream.h
${protobuf_source_dir}/src/google/protobuf/io/strtod.h
${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream.h
${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_impl_lite.h
${protobuf_source_dir}/src/google/protobuf/message_lite.h
......
......@@ -16,7 +16,6 @@ set(libprotobuf_files
${protobuf_source_dir}/src/google/protobuf/generated_message_table_driven.cc
${protobuf_source_dir}/src/google/protobuf/io/gzip_stream.cc
${protobuf_source_dir}/src/google/protobuf/io/printer.cc
${protobuf_source_dir}/src/google/protobuf/io/strtod.cc
${protobuf_source_dir}/src/google/protobuf/io/tokenizer.cc
${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_impl.cc
${protobuf_source_dir}/src/google/protobuf/map_field.cc
......@@ -72,7 +71,6 @@ set(libprotobuf_includes
${protobuf_source_dir}/src/google/protobuf/generated_message_reflection.h
${protobuf_source_dir}/src/google/protobuf/io/gzip_stream.h
${protobuf_source_dir}/src/google/protobuf/io/printer.h
${protobuf_source_dir}/src/google/protobuf/io/strtod.h
${protobuf_source_dir}/src/google/protobuf/io/tokenizer.h
${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_impl.h
${protobuf_source_dir}/src/google/protobuf/map_field.h
......
......@@ -213,6 +213,7 @@ libprotobuf_lite_la_SOURCES = \
google/protobuf/wire_format_lite.cc \
google/protobuf/io/coded_stream.cc \
google/protobuf/io/coded_stream_inl.h \
google/protobuf/io/strtod.cc \
google/protobuf/io/zero_copy_stream.cc \
google/protobuf/io/zero_copy_stream_impl_lite.cc
......@@ -257,7 +258,6 @@ libprotobuf_la_SOURCES = \
google/protobuf/wrappers.pb.cc \
google/protobuf/io/gzip_stream.cc \
google/protobuf/io/printer.cc \
google/protobuf/io/strtod.cc \
google/protobuf/io/tokenizer.cc \
google/protobuf/io/zero_copy_stream_impl.cc \
google/protobuf/compiler/importer.cc \
......
......@@ -42,6 +42,7 @@
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/stl_util.h>
#include <google/protobuf/io/strtod.h>
#ifdef _WIN32
// MSVC has only _snprintf, not snprintf.
......@@ -1287,7 +1288,7 @@ char* DoubleToBuffer(double value, char* buffer) {
// of a double. This long double may have extra bits that make it compare
// unequal to "value" even though it would be exactly equal if it were
// truncated to a double.
volatile double parsed_value = strtod(buffer, nullptr);
volatile double parsed_value = io::NoLocaleStrtod(buffer, nullptr);
if (parsed_value != value) {
int snprintf_result =
snprintf(buffer, kDoubleToBufferSize, "%.*g", DBL_DIG+2, value);
......@@ -1339,7 +1340,7 @@ bool safe_strtof(const char* str, float* value) {
char* endptr;
errno = 0; // errno only gets set on errors
#if defined(_WIN32) || defined (__hpux) // has no strtof()
*value = strtod(str, &endptr);
*value = io::NoLocaleStrtod(str, &endptr);
#else
*value = strtof(str, &endptr);
#endif
......@@ -1348,7 +1349,7 @@ bool safe_strtof(const char* str, float* value) {
bool safe_strtod(const char* str, double* value) {
char* endptr;
*value = strtod(str, &endptr);
*value = io::NoLocaleStrtod(str, &endptr);
if (endptr != str) {
while (ascii_isspace(*endptr)) ++endptr;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment