- revert changes to ConfigValueType of numbers beginning with '.'

This commit is contained in:
Thomas Kaiser 2015-12-16 15:26:24 +01:00
parent 2e71d57e61
commit 93083e86ef
2 changed files with 4 additions and 4 deletions
config/src
main/java/com/typesafe/config/impl
test/scala/com/typesafe/config/impl

View File

@ -295,7 +295,7 @@ final class Tokenizer {
}
// chars JSON allows a number to start with
static final String firstNumberChars = "0123456789-.";
static final String firstNumberChars = "0123456789-";
// chars JSON allows to be part of a number
static final String numberChars = "0123456789eE+-.";
// chars that stop an unquoted string
@ -350,7 +350,7 @@ final class Tokenizer {
private Token pullNumber(int firstChar) throws ProblemException {
StringBuilder sb = new StringBuilder();
sb.appendCodePoint(firstChar);
boolean containedDecimalOrE = firstChar == '.';
boolean containedDecimalOrE = false;
int c = nextCharRaw();
while (c != -1 && numberChars.indexOf(c) >= 0) {
if (c == '.' || c == 'e' || c == 'E')

View File

@ -606,8 +606,8 @@ class ConfigTest extends TestUtils {
assertEquals(Seq(intValue(1), intValue(2), intValue(3)), conf.getList("arrays.ofInt").asScala)
assertEquals(Seq(stringValue("a"), stringValue("b"), stringValue("c")), conf.getList("arrays.ofString").asScala)
// make sure floats starting with a '.' are parsed as numbers
assertEquals(ConfigValueType.NUMBER, conf.getValue("floats.pointThirtyThree").valueType())
// make sure floats starting with a '.' are parsed as strings (they will be converted to double on demand)
assertEquals(ConfigValueType.STRING, conf.getValue("floats.pointThirtyThree").valueType())
}
@Test