Commit ff4b07ef by Marco Trudel Committed by Tom Tromey

natString.cc (getBytes (jstring enc)): Fixed the loop for multiple cycles, Code cleanup

2007-03-12  Marco Trudel  <mtrudel@gmx.ch>

	* java/lang/natString.cc (getBytes (jstring enc)):
	Fixed the loop for multiple cycles, Code cleanup

From-SVN: r122859
parent dacb3cda
2007-03-12 Marco Trudel <mtrudel@gmx.ch>
* java/lang/natString.cc (getBytes (jstring enc)):
Fixed the loop for multiple cycles, Code cleanup
2007-03-09 Tom Tromey <tromey@redhat.com> 2007-03-09 Tom Tromey <tromey@redhat.com>
* sources.am, Makefile.in: Rebuilt. * sources.am, Makefile.in: Rebuilt.
......
// natString.cc - Implementation of java.lang.String native methods. // natString.cc - Implementation of java.lang.String native methods.
/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation /* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation
This file is part of libgcj. This file is part of libgcj.
...@@ -615,11 +615,9 @@ java::lang::String::getBytes (jstring enc) ...@@ -615,11 +615,9 @@ java::lang::String::getBytes (jstring enc)
while (todo > 0 || converter->havePendingBytes()) while (todo > 0 || converter->havePendingBytes())
{ {
converter->setOutput(buffer, bufpos); converter->setOutput(buffer, bufpos);
// We only really need to do a single write.
converter->setFinished();
int converted = converter->write(this, offset, todo, NULL); int converted = converter->write(this, offset, todo, NULL);
bufpos = converter->count; bufpos = converter->count;
if (converted == 0 && bufpos == converter->count) if (converted == 0)
{ {
buflen *= 2; buflen *= 2;
jbyteArray newbuffer = JvNewByteArray(buflen); jbyteArray newbuffer = JvNewByteArray(buflen);
...@@ -627,10 +625,15 @@ java::lang::String::getBytes (jstring enc) ...@@ -627,10 +625,15 @@ java::lang::String::getBytes (jstring enc)
buffer = newbuffer; buffer = newbuffer;
} }
else else
bufpos = converter->count; {
offset += converted;
offset += converted; todo -= converted;
todo -= converted; }
}
if (length() > 0)
{
converter->setFinished();
converter->write(this, 0, 0, NULL);
} }
converter->done (); converter->done ();
if (bufpos == buflen) if (bufpos == buflen)
......
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