Skip to content

Commit

Permalink
Fix parsing error in 2DA table reader
Browse files Browse the repository at this point in the history
  • Loading branch information
Argent77 committed Apr 8, 2022
1 parent 1deddde commit 6f641e6
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/org/infinity/util/Table2da.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.infinity.resource.ResourceFactory;
import org.infinity.resource.key.ResourceEntry;
Expand Down Expand Up @@ -203,14 +201,16 @@ private List<Entry> getSplitEntries(String line, int lineIndex) {
List<Entry> retVal = new ArrayList<>();

if (line != null) {
final Pattern pattern = Pattern.compile("\\b\\S+\\b");
final Matcher matcher = pattern.matcher(line);

while (matcher.find()) {
int start = matcher.start();
int end = matcher.end();
String value = line.substring(start, end);
retVal.add(new Entry(this, value, lineIndex, start));
String[] tokens = line.split("\\s+");
int fromIndex = 0;
for (final String token : tokens) {
fromIndex = line.indexOf(token, fromIndex);
if (fromIndex >= 0) {
retVal.add(new Entry(this, token, lineIndex, fromIndex));
fromIndex += token.length();
} else {
break;
}
}
}

Expand Down

0 comments on commit 6f641e6

Please sign in to comment.