diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/AutoCRLFInputStream.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/AutoCRLFInputStream.java index 7c77a2426..98c5477de 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/AutoCRLFInputStream.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/AutoCRLFInputStream.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2012, Robin Rosenberg - * Copyright (C) 2010, Marc Strapetz + * Copyright (C) 2010, 2013 Marc Strapetz * and other copyright owners as documented in the project's IP log. * * This program and the accompanying materials are made available @@ -98,40 +98,40 @@ public int read() throws IOException { } @Override - public int read(byte[] bs, int off, int len) throws IOException { + public int read(byte[] bs, final int off, final int len) throws IOException { if (len == 0) return 0; if (cnt == -1) return -1; - final int startOff = off; + int i = off; final int end = off + len; - while (off < end) { + while (i < end) { if (ptr == cnt && !fillBuffer()) break; byte b = buf[ptr++]; if (isBinary || b != '\n') { // Logic for binary files ends here - bs[off++] = last = b; + bs[i++] = last = b; continue; } if (b == '\n') { if (last == '\r') { - bs[off++] = last = b; + bs[i++] = last = b; continue; } - bs[off++] = last = '\r'; + bs[i++] = last = '\r'; ptr--; } else - bs[off++] = last = b; + bs[i++] = last = b; } - int n = startOff == off ? -1 : off - startOff; + int n = i == off ? -1 : i - off; if (n > 0) - last = bs[off - 1]; + last = bs[i - 1]; return n; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/AutoCRLFOutputStream.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/AutoCRLFOutputStream.java index 1ce277439..f05da1c73 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/AutoCRLFOutputStream.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/AutoCRLFOutputStream.java @@ -90,12 +90,13 @@ public void write(byte[] b) throws IOException { } @Override - public void write(byte[] b, int off, int len) throws IOException { - int overflow = buffer(b, off, len); + public void write(byte[] b, final int startOff, final int startLen) + throws IOException { + final int overflow = buffer(b, startOff, startLen); if (overflow < 0) return; - off = off + len - overflow; - len = overflow; + final int off = startOff + startLen - overflow; + final int len = overflow; if (len == 0) return; int lastw = off; @@ -104,7 +105,7 @@ public void write(byte[] b, int off, int len) throws IOException { return; } for (int i = off; i < off + len; ++i) { - byte c = b[i]; + final byte c = b[i]; if (c == '\r') { buf = '\r'; } else if (c == '\n') { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/EolCanonicalizingInputStream.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/EolCanonicalizingInputStream.java index 592183658..f87ab6896 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/EolCanonicalizingInputStream.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/EolCanonicalizingInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010, Marc Strapetz + * Copyright (C) 2010, 2013 Marc Strapetz * and other copyright owners as documented in the project's IP log. * * This program and the accompanying materials are made available @@ -91,17 +91,17 @@ public int read() throws IOException { } @Override - public int read(byte[] bs, int off, int len) throws IOException { + public int read(byte[] bs, final int off, final int len) throws IOException { if (len == 0) return 0; if (cnt == -1) return -1; - final int startOff = off; + int i = off; final int end = off + len; - while (off < end) { + while (i < end) { if (ptr == cnt && !fillBuffer()) { break; } @@ -109,23 +109,23 @@ public int read(byte[] bs, int off, int len) throws IOException { byte b = buf[ptr++]; if (isBinary || b != '\r') { // Logic for binary files ends here - bs[off++] = b; + bs[i++] = b; continue; } if (ptr == cnt && !fillBuffer()) { - bs[off++] = '\r'; + bs[i++] = '\r'; break; } if (buf[ptr] == '\n') { - bs[off++] = '\n'; + bs[i++] = '\n'; ptr++; } else - bs[off++] = '\r'; + bs[i++] = '\r'; } - return startOff == off ? -1 : off - startOff; + return i == off ? -1 : i - off; } @Override diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/TeeInputStream.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/TeeInputStream.java index 16ed9c6eb..6adadbbb8 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/TeeInputStream.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/TeeInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010, Google Inc. + * Copyright (C) 2010, 2013 Google Inc. * and other copyright owners as documented in the project's IP log. * * This program and the accompanying materials are made available @@ -89,11 +89,12 @@ public int read() throws IOException { } @Override - public long skip(long cnt) throws IOException { + public long skip(final long count) throws IOException { long skipped = 0; - byte[] b = skipBuffer(); + long cnt = count; + final byte[] b = skipBuffer(); while (0 < cnt) { - int n = src.read(b, 0, (int) Math.min(b.length, cnt)); + final int n = src.read(b, 0, (int) Math.min(b.length, cnt)); if (n <= 0) break; dst.write(b, 0, n); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/UnionInputStream.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/UnionInputStream.java index 20dcd4659..0319afd5a 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/UnionInputStream.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/UnionInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009, Google Inc. + * Copyright (C) 2009, 2013 Google Inc. * and other copyright owners as documented in the project's IP log. * * This program and the accompanying materials are made available @@ -158,17 +158,18 @@ public int available() throws IOException { } @Override - public long skip(long len) throws IOException { - long cnt = 0; - while (0 < len) { + public long skip(final long count) throws IOException { + long skipped = 0; + long cnt = count; + while (0 < cnt) { final InputStream in = head(); - final long n = in.skip(len); + final long n = in.skip(cnt); if (0 < n) { - cnt += n; - len -= n; + skipped += n; + cnt -= n; } else if (in == EOF) { - return cnt; + return skipped; } else { // Is this stream at EOF? We can't tell from skip alone. @@ -178,15 +179,15 @@ public long skip(long len) throws IOException { final int r = in.read(); if (r < 0) { pop(); - if (0 < cnt) + if (0 < skipped) break; } else { - cnt += 1; - len -= 1; + skipped += 1; + cnt -= 1; } } } - return cnt; + return skipped; } @Override