Skip to content
This repository has been archived by the owner on Jul 16, 2022. It is now read-only.

Commit

Permalink
Merge pull request #67 from eb4j/topic/miurahr/dictzip-0.12.1
Browse files Browse the repository at this point in the history
Bump dictzip@0.12.1
  • Loading branch information
miurahr authored Feb 28, 2022
2 parents d67b4e8 + 6e5471a commit 5e6be1f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ dependencies {
implementation("org.jetbrains:annotations:23.0.0")
implementation("com.github.takawitter:trie4j:0.9.8")
implementation("commons-io:commons-io:2.11.0")
implementation("io.github.dictzip:dictzip:0.11.2")
implementation("io.github.dictzip:dictzip:0.12.1")
implementation("com.google.protobuf:protobuf-java:$protobufVersion")
testImplementation("org.codehaus.groovy:groovy-all:3.0.9")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.2")
Expand Down
20 changes: 5 additions & 15 deletions src/main/java/io/github/eb4j/dsl/impl/EntriesLoaderImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -344,42 +344,32 @@ private int skipEmptyLine() throws IOException {
private long eolSearch() throws IOException {
int b;
InputStream stream;
boolean isUTF16 = StandardCharsets.UTF_16LE.equals(charset);
long current;
if (isDictZip) {
stream = dzis;
current = dzis.position();
} else {
stream = rais;
current = rais.position();
}
long current = position();
boolean isUTF16 = StandardCharsets.UTF_16LE.equals(charset);
while ((b = stream.read()) != -1) {
if ((byte) b != 0x0a) {
continue;
}
if (!isUTF16) {
// LF found when UTF-8 and ANSI charsets
if (isDictZip) {
return dzis.position() - current;
} else {
return rais.position() - current;
}
return position() - current;
}
// check second byte
if ((b = stream.read()) == -1) {
// eof detected after 0x0a found in UTF-16 case.
// eof detected after 0x0a found in UTF-16 case. data seems broken
return -1;
}
if (b != 0x00) {
// it is other than LF, just lower byte is 0x0a
continue;
}
// Found LF in UTF-16LE
if (isDictZip) {
return dzis.position() - current;
} else {
return rais.position() - current;
}
return position() - current;
}
// no dice, eof found.
return -1;
Expand Down

0 comments on commit 5e6be1f

Please sign in to comment.