From def57f9da8f8d2f949f6801d19416b68e0c27a8f Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Mon, 28 Jan 2002 16:42:07 +0000 Subject: [PATCH] Don't reposition the input stream when a \r is immediately followed by the end of input. Without that change, the unit test testMacLines would cause an endless loop for JDK 1.1, at least with: $ java -fullversion java full version "Linux_JDK_1.1.8_v3_green_threads" git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270995 13f79535-47bb-0310-9956-ffa450edef68 --- src/main/org/apache/tools/ant/taskdefs/FixCRLF.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java b/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java index 02dcf7d45..7008468fd 100644 --- a/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java +++ b/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java @@ -853,7 +853,7 @@ public class FixCRLF extends MatchingTask { ++eolcount; eolStr.append('\r'); reader.mark(2); - switch ((char)(ch = reader.read())) { + switch ((ch = reader.read())) { case '\r': if ((char)(ch = reader.read()) == '\n') { eolcount += 2; @@ -864,6 +864,10 @@ public class FixCRLF extends MatchingTask { ++eolcount; eolStr.append('\n'); break; + case -1: + // don't reposition when we've reached the end + // of the stream + break; default: reader.reset(); break;