Skip to content

Commit dee145a

Browse files
sbarzowskijohnbartholomew
authored andcommitted
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.
1 parent 8c53f3c commit dee145a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

core/parser.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ limitations under the License.
2323
#include <memory>
2424
#include <set>
2525
#include <sstream>
26+
#include <locale>
2627
#include <string>
2728

2829
#include "ast.h"
@@ -36,6 +37,9 @@ namespace jsonnet::internal {
3637
std::string jsonnet_unparse_number(double v)
3738
{
3839
std::stringstream ss;
40+
// Make sure we output the same thing, even if the user
41+
// of the library changed the global locale
42+
ss.imbue(std::locale::classic());
3943
if (v == floor(v)) {
4044
ss << std::fixed << std::setprecision(0) << v;
4145
} else {

0 commit comments

Comments
 (0)