blob: 573e6a87bf1ee8af6f828c5801ded8728a67157b [file] [log] [blame]
Index: lucene/core/src/java/org/apache/lucene/store/BufferedIndexInput.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/store/BufferedIndexInput.java (revision 1307763)
+++ lucene/core/src/java/org/apache/lucene/store/BufferedIndexInput.java (working copy)
@@ -199,17 +199,17 @@
public final int readVInt() throws IOException {
if (5 <= (bufferLength-bufferPosition)) {
byte b = buffer[bufferPosition++];
+ if (b >= 0) return b;
int i = b & 0x7F;
- if ((b & 0x80) == 0) return i;
b = buffer[bufferPosition++];
i |= (b & 0x7F) << 7;
- if ((b & 0x80) == 0) return i;
+ if (b >= 0) return i;
b = buffer[bufferPosition++];
i |= (b & 0x7F) << 14;
- if ((b & 0x80) == 0) return i;
+ if (b >= 0) return i;
b = buffer[bufferPosition++];
i |= (b & 0x7F) << 21;
- if ((b & 0x80) == 0) return i;
+ if (b >= 0) return i;
b = buffer[bufferPosition++];
// Warning: the next ands use 0x0F / 0xF0 - beware copy/paste errors:
i |= (b & 0x0F) << 28;
@@ -224,32 +224,32 @@
public final long readVLong() throws IOException {
if (9 <= bufferLength-bufferPosition) {
byte b = buffer[bufferPosition++];
+ if (b >= 0) return b;
long i = b & 0x7FL;
- if ((b & 0x80) == 0) return i;
b = buffer[bufferPosition++];
i |= (b & 0x7FL) << 7;
- if ((b & 0x80) == 0) return i;
+ if (b >= 0) return i;
b = buffer[bufferPosition++];
i |= (b & 0x7FL) << 14;
- if ((b & 0x80) == 0) return i;
+ if (b >= 0) return i;
b = buffer[bufferPosition++];
i |= (b & 0x7FL) << 21;
- if ((b & 0x80) == 0) return i;
+ if (b >= 0) return i;
b = buffer[bufferPosition++];
i |= (b & 0x7FL) << 28;
- if ((b & 0x80) == 0) return i;
+ if (b >= 0) return i;
b = buffer[bufferPosition++];
i |= (b & 0x7FL) << 35;
- if ((b & 0x80) == 0) return i;
+ if (b >= 0) return i;
b = buffer[bufferPosition++];
i |= (b & 0x7FL) << 42;
- if ((b & 0x80) == 0) return i;
+ if (b >= 0) return i;
b = buffer[bufferPosition++];
i |= (b & 0x7FL) << 49;
- if ((b & 0x80) == 0) return i;
+ if (b >= 0) return i;
b = buffer[bufferPosition++];
i |= (b & 0x7FL) << 56;
- if ((b & 0x80) == 0) return i;
+ if (b >= 0) return i;
throw new IOException("Invalid vLong detected (negative values disallowed)");
} else {
return super.readVLong();
Index: lucene/core/src/java/org/apache/lucene/store/ByteArrayDataInput.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/store/ByteArrayDataInput.java (revision 1307763)
+++ lucene/core/src/java/org/apache/lucene/store/ByteArrayDataInput.java (working copy)
@@ -102,17 +102,17 @@
@Override
public int readVInt() {
byte b = bytes[pos++];
+ if (b >= 0) return b;
int i = b & 0x7F;
- if ((b & 0x80) == 0) return i;
b = bytes[pos++];
i |= (b & 0x7F) << 7;
- if ((b & 0x80) == 0) return i;
+ if (b >= 0) return i;
b = bytes[pos++];
i |= (b & 0x7F) << 14;
- if ((b & 0x80) == 0) return i;
+ if (b >= 0) return i;
b = bytes[pos++];
i |= (b & 0x7F) << 21;
- if ((b & 0x80) == 0) return i;
+ if (b >= 0) return i;
b = bytes[pos++];
// Warning: the next ands use 0x0F / 0xF0 - beware copy/paste errors:
i |= (b & 0x0F) << 28;
@@ -123,32 +123,32 @@
@Override
public long readVLong() {
byte b = bytes[pos++];
+ if (b >= 0) return b;
long i = b & 0x7FL;
- if ((b & 0x80) == 0) return i;
b = bytes[pos++];
i |= (b & 0x7FL) << 7;
- if ((b & 0x80) == 0) return i;
+ if (b >= 0) return i;
b = bytes[pos++];
i |= (b & 0x7FL) << 14;
- if ((b & 0x80) == 0) return i;
+ if (b >= 0) return i;
b = bytes[pos++];
i |= (b & 0x7FL) << 21;
- if ((b & 0x80) == 0) return i;
+ if (b >= 0) return i;
b = bytes[pos++];
i |= (b & 0x7FL) << 28;
- if ((b & 0x80) == 0) return i;
+ if (b >= 0) return i;
b = bytes[pos++];
i |= (b & 0x7FL) << 35;
- if ((b & 0x80) == 0) return i;
+ if (b >= 0) return i;
b = bytes[pos++];
i |= (b & 0x7FL) << 42;
- if ((b & 0x80) == 0) return i;
+ if (b >= 0) return i;
b = bytes[pos++];
i |= (b & 0x7FL) << 49;
- if ((b & 0x80) == 0) return i;
+ if (b >= 0) return i;
b = bytes[pos++];
i |= (b & 0x7FL) << 56;
- if ((b & 0x80) == 0) return i;
+ if (b >= 0) return i;
throw new RuntimeException("Invalid vLong detected (negative values disallowed)");
}
Index: lucene/core/src/java/org/apache/lucene/store/DataInput.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/store/DataInput.java (revision 1307763)
+++ lucene/core/src/java/org/apache/lucene/store/DataInput.java (working copy)
@@ -94,17 +94,17 @@
return i;
*/
byte b = readByte();
+ if (b >= 0) return b;
int i = b & 0x7F;
- if ((b & 0x80) == 0) return i;
b = readByte();
i |= (b & 0x7F) << 7;
- if ((b & 0x80) == 0) return i;
+ if (b >= 0) return i;
b = readByte();
i |= (b & 0x7F) << 14;
- if ((b & 0x80) == 0) return i;
+ if (b >= 0) return i;
b = readByte();
i |= (b & 0x7F) << 21;
- if ((b & 0x80) == 0) return i;
+ if (b >= 0) return i;
b = readByte();
// Warning: the next ands use 0x0F / 0xF0 - beware copy/paste errors:
i |= (b & 0x0F) << 28;
@@ -135,32 +135,32 @@
return i;
*/
byte b = readByte();
+ if (b >= 0) return b;
long i = b & 0x7FL;
- if ((b & 0x80) == 0) return i;
b = readByte();
i |= (b & 0x7FL) << 7;
- if ((b & 0x80) == 0) return i;
+ if (b >= 0) return i;
b = readByte();
i |= (b & 0x7FL) << 14;
- if ((b & 0x80) == 0) return i;
+ if (b >= 0) return i;
b = readByte();
i |= (b & 0x7FL) << 21;
- if ((b & 0x80) == 0) return i;
+ if (b >= 0) return i;
b = readByte();
i |= (b & 0x7FL) << 28;
- if ((b & 0x80) == 0) return i;
+ if (b >= 0) return i;
b = readByte();
i |= (b & 0x7FL) << 35;
- if ((b & 0x80) == 0) return i;
+ if (b >= 0) return i;
b = readByte();
i |= (b & 0x7FL) << 42;
- if ((b & 0x80) == 0) return i;
+ if (b >= 0) return i;
b = readByte();
i |= (b & 0x7FL) << 49;
- if ((b & 0x80) == 0) return i;
+ if (b >= 0) return i;
b = readByte();
i |= (b & 0x7FL) << 56;
- if ((b & 0x80) == 0) return i;
+ if (b >= 0) return i;
throw new IOException("Invalid vLong detected (negative values disallowed)");
}