From d843ceba5a5a29ab4424a0d49a7545f064b33f46 Mon Sep 17 00:00:00 2001 From: mkoch Date: Tue, 24 Jun 2003 07:25:24 +0000 Subject: 2003-06-24 Michael Koch * java/io/LineNumberReader.java (skip): Dont do line number accounting here as this is already done in read(), simplified. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@68408 138bc75d-0d04-0410-961f-82ee72b054a4 --- libjava/java/io/LineNumberReader.java | 37 +++++++++++------------------------ 1 file changed, 11 insertions(+), 26 deletions(-) (limited to 'libjava/java/io') diff --git a/libjava/java/io/LineNumberReader.java b/libjava/java/io/LineNumberReader.java index 9d80745d2fa..12bafe39675 100644 --- a/libjava/java/io/LineNumberReader.java +++ b/libjava/java/io/LineNumberReader.java @@ -374,37 +374,22 @@ public class LineNumberReader extends BufferedReader * * @exception IOException If an error occurs */ - public long skip(long count) throws IOException + public long skip (long count) throws IOException { if (count <= 0) return 0; - long to_do = count; - do + + int skipped; + + for (skipped = 0; skipped < count; skipped++) { - int ch = read(); - if (ch < 0) - break; - to_do--; - if (ch == '\n' || ch == '\r') - lineNumber++; - else - { - long fence = pos + to_do; - if (limit < fence) - fence = limit; - int end = pos; - for (; end < fence; end++) - { - char endch = buffer[end]; - if (endch == '\n' || endch == '\r') - break; - } - to_do -= end - pos; - pos = end; - } + int ch = read(); + + if (ch < 0) + break; } - while (to_do > 0); - return count - to_do; + + return skipped; } } -- cgit v1.2.3