diff options
author | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-03-12 19:48:32 +0000 |
---|---|---|
committer | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-03-12 19:48:32 +0000 |
commit | 6ea1cf4877fe35353386fb349d1d2db4f7fa475a (patch) | |
tree | 58a95a38cf44e5e20d4c340b3c31889ac3db3fa6 /libjava/java | |
parent | 154480b16c909e4cd559739cf3753f587d603a69 (diff) | |
download | ppe42-gcc-6ea1cf4877fe35353386fb349d1d2db4f7fa475a.tar.gz ppe42-gcc-6ea1cf4877fe35353386fb349d1d2db4f7fa475a.zip |
2007-03-12 Marco Trudel <mtrudel@gmx.ch>
* java/lang/natString.cc (getBytes (jstring enc)):
Fixed the loop for multiple cycles, Code cleanup
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@122859 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java')
-rw-r--r-- | libjava/java/lang/natString.cc | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/libjava/java/lang/natString.cc b/libjava/java/lang/natString.cc index f86abd8bc2d..39590a3e4e0 100644 --- a/libjava/java/lang/natString.cc +++ b/libjava/java/lang/natString.cc @@ -1,6 +1,6 @@ // 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. @@ -615,11 +615,9 @@ java::lang::String::getBytes (jstring enc) while (todo > 0 || converter->havePendingBytes()) { converter->setOutput(buffer, bufpos); - // We only really need to do a single write. - converter->setFinished(); int converted = converter->write(this, offset, todo, NULL); bufpos = converter->count; - if (converted == 0 && bufpos == converter->count) + if (converted == 0) { buflen *= 2; jbyteArray newbuffer = JvNewByteArray(buflen); @@ -627,10 +625,15 @@ java::lang::String::getBytes (jstring enc) buffer = newbuffer; } else - bufpos = converter->count; - - offset += converted; - todo -= converted; + { + offset += converted; + todo -= converted; + } + } + if (length() > 0) + { + converter->setFinished(); + converter->write(this, 0, 0, NULL); } converter->done (); if (bufpos == buflen) |