Skip to content

Commit b83000e

Browse files
committed
Accept byte instead of int for byte value params
Fix #35
1 parent d1b1bd9 commit b83000e

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/main/java/io/kaitai/struct/ByteBufferKaitaiStream.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ public byte[] readBytesFull() {
337337
}
338338

339339
@Override
340-
public byte[] readBytesTerm(int term, boolean includeTerm, boolean consumeTerm, boolean eosError) {
340+
public byte[] readBytesTerm(byte term, boolean includeTerm, boolean consumeTerm, boolean eosError) {
341341
ByteArrayOutputStream buf = new ByteArrayOutputStream();
342342
while (true) {
343343
if (!bb.hasRemaining()) {
@@ -347,7 +347,7 @@ public byte[] readBytesTerm(int term, boolean includeTerm, boolean consumeTerm,
347347
return buf.toByteArray();
348348
}
349349
}
350-
int c = bb.get();
350+
byte c = bb.get();
351351
if (c == term) {
352352
if (includeTerm)
353353
buf.write(c);

src/main/java/io/kaitai/struct/KaitaiStream.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ private static long getMaskOnes(int n) {
278278
*/
279279
abstract public byte[] readBytesFull();
280280

281-
abstract public byte[] readBytesTerm(int term, boolean includeTerm, boolean consumeTerm, boolean eosError);
281+
abstract public byte[] readBytesTerm(byte term, boolean includeTerm, boolean consumeTerm, boolean eosError);
282282

283283
/**
284284
* Checks that next bytes in the stream match match expected fixed byte array.
@@ -346,7 +346,7 @@ protected int toByteArrayLength(long n) {
346346
* @param key value to XOR with
347347
* @return processed data
348348
*/
349-
public static byte[] processXor(byte[] data, int key) {
349+
public static byte[] processXor(byte[] data, byte key) {
350350
int dataLen = data.length;
351351
byte[] r = new byte[dataLen];
352352
for (int i = 0; i < dataLen; i++)

src/main/java/io/kaitai/struct/RandomAccessFileKaitaiStream.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ public byte[] readBytesFull() {
338338
}
339339

340340
@Override
341-
public byte[] readBytesTerm(int term, boolean includeTerm, boolean consumeTerm, boolean eosError) {
341+
public byte[] readBytesTerm(byte term, boolean includeTerm, boolean consumeTerm, boolean eosError) {
342342
try {
343343
ByteArrayOutputStream buf = new ByteArrayOutputStream();
344344
while (true) {
@@ -349,7 +349,7 @@ public byte[] readBytesTerm(int term, boolean includeTerm, boolean consumeTerm,
349349
} else {
350350
return buf.toByteArray();
351351
}
352-
} else if (c == term) {
352+
} else if ((byte) c == term) {
353353
if (includeTerm)
354354
buf.write(c);
355355
if (!consumeTerm)

0 commit comments

Comments
 (0)