From b83089b91d29b3054cebd77ee5b8a09fbe13bb87 Mon Sep 17 00:00:00 2001 From: Chris Martin Date: Wed, 5 Nov 2014 14:35:42 -0500 Subject: [PATCH] Avoid awkward do-while in Tokenizer.pullQuotedString Not a big deal, but I think this reads more clearly now. --- .../main/java/com/typesafe/config/impl/Tokenizer.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/config/src/main/java/com/typesafe/config/impl/Tokenizer.java b/config/src/main/java/com/typesafe/config/impl/Tokenizer.java index 0da23070..03460ed7 100644 --- a/config/src/main/java/com/typesafe/config/impl/Tokenizer.java +++ b/config/src/main/java/com/typesafe/config/impl/Tokenizer.java @@ -457,23 +457,22 @@ final class Tokenizer { private Token pullQuotedString() throws ProblemException { // the open quote has already been consumed StringBuilder sb = new StringBuilder(); - int c = '\0'; // value doesn't get used - do { - c = nextCharRaw(); + while (true) { + int c = nextCharRaw(); if (c == -1) throw problem("End of input but string quote was still open"); if (c == '\\') { pullEscapeSequence(sb); } else if (c == '"') { - // end the loop, done! + break; } else if (Character.isISOControl(c)) { throw problem(asString(c), "JSON does not allow unescaped " + asString(c) + " in quoted strings, use a backslash escape"); } else { sb.appendCodePoint(c); } - } while (c != '"'); + } // maybe switch to triple-quoted string, sort of hacky... if (sb.length() == 0) {