Commit 20afd475 by Michael Koch Committed by Michael Koch

2003-06-24 Michael Koch <konqueror@gmx.de>

	* java/io/LineNumberReader.java
	(skip): Dont do line number accounting here as this is already done in
	read(), simplified.

From-SVN: r68408
parent d1a2c4d6
2003-06-24 Michael Koch <konqueror@gmx.de>
* java/io/LineNumberReader.java
(skip): Dont do line number accounting here as this is already done in
read(), simplified.
2003-06-21 Michael Koch <konqueror@gmx.de> 2003-06-21 Michael Koch <konqueror@gmx.de>
* java/io/File.java * java/io/File.java
......
...@@ -374,37 +374,22 @@ public class LineNumberReader extends BufferedReader ...@@ -374,37 +374,22 @@ public class LineNumberReader extends BufferedReader
* *
* @exception IOException If an error occurs * @exception IOException If an error occurs
*/ */
public long skip(long count) throws IOException public long skip (long count) throws IOException
{ {
if (count <= 0) if (count <= 0)
return 0; return 0;
long to_do = count;
do int skipped;
for (skipped = 0; skipped < count; skipped++)
{ {
int ch = read(); int ch = read();
if (ch < 0) if (ch < 0)
break; 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;
} }
}
while (to_do > 0); return skipped;
return count - to_do;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment