mirror of
https://github.com/plexusorg/toml4j.git
synced 2024-06-01 01:11:36 +00:00
Removed duplicate comment checks
This commit is contained in:
parent
b7b546dc83
commit
e0762bf82a
|
@ -1,6 +1,7 @@
|
||||||
package com.moandjiezana.toml;
|
package com.moandjiezana.toml;
|
||||||
|
|
||||||
import static com.moandjiezana.toml.ValueConverterUtils.INVALID;
|
import static com.moandjiezana.toml.ValueConverterUtils.INVALID;
|
||||||
|
import static com.moandjiezana.toml.ValueConverterUtils.isComment;
|
||||||
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@ -39,10 +40,6 @@ class TomlParser {
|
||||||
String tableName = Keys.getTableArrayName(line);
|
String tableName = Keys.getTableArrayName(line);
|
||||||
if (tableName != null) {
|
if (tableName != null) {
|
||||||
results.startTableArray(tableName);
|
results.startTableArray(tableName);
|
||||||
String afterTableName = line.substring(tableName.length() + 4);
|
|
||||||
if (!isComment(afterTableName)) {
|
|
||||||
results.errors.append("Invalid table array definition: " + line + "\n\n");
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
results.errors.append("Invalid table array definition: " + line + "\n\n");
|
results.errors.append("Invalid table array definition: " + line + "\n\n");
|
||||||
}
|
}
|
||||||
|
@ -173,24 +170,6 @@ class TomlParser {
|
||||||
return line.startsWith("[");
|
return line.startsWith("[");
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isComment(String line) {
|
|
||||||
if (line == null || line.isEmpty()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
char[] chars = line.toCharArray();
|
|
||||||
|
|
||||||
for (char c : chars) {
|
|
||||||
if (Character.isWhitespace(c)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
return c == '#';
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String removeComment(String line) {
|
private String removeComment(String line) {
|
||||||
line = line.trim();
|
line = line.trim();
|
||||||
if (line.startsWith("\"")) {
|
if (line.startsWith("\"")) {
|
||||||
|
|
Loading…
Reference in a new issue