Skip to content

Commit

Permalink
Fix line count for CRLF.
Browse files Browse the repository at this point in the history
  • Loading branch information
radcortez committed Sep 29, 2020
1 parent 261d96d commit 13efd6d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
Expand Up @@ -146,7 +146,6 @@ int readLine() throws IOException {
if (skipLF) {
skipLF = false;
if (c == '\n') {
lineNumber++;
continue;
}
}
Expand All @@ -155,7 +154,9 @@ int readLine() throws IOException {
continue;
}
if (!appendedLineBegin && (c == '\r' || c == '\n')) {
lineNumber++;
if (c == '\n') {
lineNumber++;
}
continue;
}
skipWhiteSpace = false;
Expand Down Expand Up @@ -219,6 +220,10 @@ int readLine() throws IOException {
skipLF = true;
}
} else {
if (c == '\r') {
inOff++;
}

return len;
}
}
Expand Down
Expand Up @@ -38,7 +38,7 @@ public void multipleLines() throws Exception {
"\n" +
"\n" +
"\n" +
"key20=value"));
"key20=value\n"));

assertEquals(1, map.get("key").getLineNumber());
assertEquals(2, map.get("key2").getLineNumber());
Expand All @@ -55,7 +55,7 @@ public void comments() throws Exception {
"#comment\n" +
"#comment\n" +
"#comment\n" +
"key3=value"));
"key3=value\n"));

assertEquals(1, map.get("key").getLineNumber());
assertEquals(2, map.get("key2").getLineNumber());
Expand All @@ -67,14 +67,14 @@ public void wrapValue() throws Exception {
final ConfigValueProperties map = new ConfigValueProperties("config", 1);
map.load(new StringReader(
"key=value\\wrap\n" +
"key2=value\\\rwrap\n" +
"key2=value\\\nwrap\n" +
"#comment\f\t\n" +
"#comment\r\n" +
"\\key3=value"));
"#comment\n" +
"\\key3=value\n"));

assertEquals(1, map.get("key").getLineNumber());
assertEquals(2, map.get("key2").getLineNumber());
assertEquals("valuewrap", map.get("key2").getValue());
assertEquals(7, map.get("key3").getLineNumber());
assertEquals(2, map.get("key2").getLineNumber());
assertEquals(6, map.get("key3").getLineNumber());
}
}
4 changes: 2 additions & 2 deletions implementation/src/test/resources/config-values.properties
Expand Up @@ -7,8 +7,8 @@ my.prop=abc



secret=12345678

secret=1234567\
8



Expand Down

0 comments on commit 13efd6d

Please sign in to comment.