You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2020/12/12 16:05:02 UTC

[commons-io] 03/05: Replace magic number with constant.

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git

commit c604d60e0f41a91707cac93cff04ad15874280df
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Dec 12 10:59:18 2020 -0500

    Replace magic number with constant.
---
 .../org/apache/commons/io/input/UnixLineEndingInputStream.java    | 7 ++++---
 .../org/apache/commons/io/input/WindowsLineEndingInputStream.java | 8 +++++---
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/commons/io/input/UnixLineEndingInputStream.java b/src/main/java/org/apache/commons/io/input/UnixLineEndingInputStream.java
index 8fc1d11..56a1b86 100644
--- a/src/main/java/org/apache/commons/io/input/UnixLineEndingInputStream.java
+++ b/src/main/java/org/apache/commons/io/input/UnixLineEndingInputStream.java
@@ -16,6 +16,7 @@
  */
 package org.apache.commons.io.input;
 
+import static org.apache.commons.io.IOUtils.EOF;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -55,7 +56,7 @@ public class UnixLineEndingInputStream extends InputStream {
      */
     private int readWithUpdate() throws IOException {
         final int target = this.target.read();
-        eofSeen = target == -1;
+        eofSeen = target == EOF;
         if (eofSeen) {
             return target;
         }
@@ -95,13 +96,13 @@ public class UnixLineEndingInputStream extends InputStream {
      */
     private int eofGame(final boolean previousWasSlashR) {
         if (previousWasSlashR || !ensureLineFeedAtEndOfFile) {
-            return -1;
+            return EOF;
         }
         if (!slashNSeen) {
             slashNSeen = true;
             return '\n';
         }
-        return -1;
+        return EOF;
     }
 
     /**
diff --git a/src/main/java/org/apache/commons/io/input/WindowsLineEndingInputStream.java b/src/main/java/org/apache/commons/io/input/WindowsLineEndingInputStream.java
index 85405d2..9253fd8 100644
--- a/src/main/java/org/apache/commons/io/input/WindowsLineEndingInputStream.java
+++ b/src/main/java/org/apache/commons/io/input/WindowsLineEndingInputStream.java
@@ -16,6 +16,8 @@
  */
 package org.apache.commons.io.input;
 
+import static org.apache.commons.io.IOUtils.EOF;
+
 import java.io.IOException;
 import java.io.InputStream;
 
@@ -56,7 +58,7 @@ public class WindowsLineEndingInputStream  extends InputStream {
      */
     private int readWithUpdate() throws IOException {
         final int target = this.target.read();
-        eofSeen = target == -1;
+        eofSeen = target == EOF;
         if (eofSeen) {
             return target;
         }
@@ -98,7 +100,7 @@ public class WindowsLineEndingInputStream  extends InputStream {
 
     private int eofGame() {
         if (!ensureLineFeedAtEndOfFile) {
-            return -1;
+            return EOF;
         }
         if (!slashNSeen && !slashRSeen) {
             slashRSeen = true;
@@ -109,7 +111,7 @@ public class WindowsLineEndingInputStream  extends InputStream {
             slashNSeen = true;
             return '\n';
         }
-        return -1;
+        return EOF;
     }
 
     /**