diff --git a/cmake/libprotobuf-lite.cmake b/cmake/libprotobuf-lite.cmake index 7bd8332f7..22d557850 100644 --- a/cmake/libprotobuf-lite.cmake +++ b/cmake/libprotobuf-lite.cmake @@ -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 diff --git a/cmake/libprotobuf.cmake b/cmake/libprotobuf.cmake index bd570be7d..9a434a7db 100644 --- a/cmake/libprotobuf.cmake +++ b/cmake/libprotobuf.cmake @@ -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 diff --git a/src/Makefile.am b/src/Makefile.am index 9251d121a..16cbe0ce3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 \ diff --git a/src/google/protobuf/stubs/strutil.cc b/src/google/protobuf/stubs/strutil.cc index 127767d5b..1d34870de 100644 --- a/src/google/protobuf/stubs/strutil.cc +++ b/src/google/protobuf/stubs/strutil.cc @@ -42,6 +42,7 @@ #include #include +#include #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; }