From bac3d43cece3a6207152bd86c217998d782f230c Mon Sep 17 00:00:00 2001 From: Dave Cunningham Date: Thu, 23 Jun 2016 12:12:40 -0400 Subject: [PATCH] Fix #197 --- core/formatter.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/core/formatter.cpp b/core/formatter.cpp index 48b61e6c8..064d77e29 100644 --- a/core/formatter.cpp +++ b/core/formatter.cpp @@ -990,16 +990,16 @@ class EnforceStringStyle : public Pass { if (c == '\'') num_single++; if (c == '"') num_double++; } - if (num_single > 0 && num_double > 0) return; - char style = opts.stringStyle == 's'; + if (num_single > 0 && num_double > 0) return; // Don't change it. + bool use_single = opts.stringStyle == 's'; if (num_single > 0) - style = 'd'; + use_single = false; if (num_double > 0) - style = 's'; + use_single = true; - // Change it - lit->value = jsonnet_string_escape(canonical, style == 's'); - lit->tokenKind = style ? LiteralString::SINGLE : LiteralString::DOUBLE; + // Change it. + lit->value = jsonnet_string_escape(canonical, use_single); + lit->tokenKind = use_single ? LiteralString::SINGLE : LiteralString::DOUBLE; } };