From e8aa025d6e3e7399a5db89fc40fca45ad25a26f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Barzowski?= Date: Wed, 30 Oct 2019 23:05:59 +0100 Subject: [PATCH] Set the stream locale to "C" locally So that even if there is a global locale set by the library user, Jsonnet output is still the same. --- core/parser.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/parser.cpp b/core/parser.cpp index 41e28ecaf..2b6b9edf4 100644 --- a/core/parser.cpp +++ b/core/parser.cpp @@ -23,6 +23,7 @@ limitations under the License. #include #include #include +#include #include #include "ast.h" @@ -34,6 +35,9 @@ limitations under the License. std::string jsonnet_unparse_number(double v) { std::stringstream ss; + // Make sure we output the same thing, even if the user + // of the library changed the global locale + ss.imbue(std::locale::classic()); if (v == floor(v)) { ss << std::fixed << std::setprecision(0) << v; } else {