From 691e54b4abb99b75211780a12a9329ba27230b2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 17 Jan 2007 12:02:06 +0000 Subject: [PATCH] Minor fixes: * the "state" variable was reset for each loop cycle. * since the inner loop tested for "bytes" instead of "bytesLeft", convert_to_utf8() was called twice for each chunk read. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19846 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/translators/stxt/STXTTranslator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/add-ons/translators/stxt/STXTTranslator.cpp b/src/add-ons/translators/stxt/STXTTranslator.cpp index 316cfc366b..c51de576d0 100644 --- a/src/add-ons/translators/stxt/STXTTranslator.cpp +++ b/src/add-ons/translators/stxt/STXTTranslator.cpp @@ -1180,6 +1180,7 @@ translate_from_text(BPositionIO* source, const char* encoding, bool forceEncodin off_t outputSize = 0; ssize_t bytesRead; + int32 state = 0; // output the actual text part of the data do { @@ -1205,7 +1206,6 @@ translate_from_text(BPositionIO* source, const char* encoding, bool forceEncodin // decode text file to UTF-8 char* pos = (char*)buffer; int32 encodingLength = encodingIO.BufferLength(); - int32 state = 0; int32 bytesLeft = bytesRead; int32 bytes; do { @@ -1229,7 +1229,7 @@ translate_from_text(BPositionIO* source, const char* encoding, bool forceEncodin pos += bytes; bytesLeft -= bytes; outputSize += encodingLength; - } while (encodingLength > 0 && bytes > 0); + } while (encodingLength > 0 && bytesLeft > 0); } } while (bytesRead > 0);