From 63d618eebca7e8f1d9bcf89c4c4af0e834c5c765 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Sun, 16 Nov 2008 22:52:22 +0000 Subject: [PATCH] * Fixed wrong usage of Seek(). The return type is off_t, not status_t. It only worked because (status_t)B_OK == (off_t)0. * The translator_id version of Translate() does a (probably unnecessary?) Identify(), but then forgets to seek the source BPositionIO back to 0 before calling translator's Translate(). This was the reason for none of the WonderBrush Translation Kit export formats to work. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28676 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/translation/TranslatorRoster.cpp | 34 +++++++++++++++-------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/kits/translation/TranslatorRoster.cpp b/src/kits/translation/TranslatorRoster.cpp index 01b1e3f5ec..211360c22b 100644 --- a/src/kits/translation/TranslatorRoster.cpp +++ b/src/kits/translation/TranslatorRoster.cpp @@ -682,9 +682,9 @@ BTranslatorRoster::Private::Identify(BPositionIO* source, while (iterator != fTranslators.end()) { BTranslator& translator = *iterator->second.translator; - status_t status = source->Seek(0, SEEK_SET); - if (status != B_OK) - return status; + off_t pos = source->Seek(0, SEEK_SET); + if (pos != 0) + return pos < 0 ? (status_t)pos : B_IO_ERROR; int32 formatsCount = 0; const translation_format* formats = translator.InputFormats(&formatsCount); @@ -735,10 +735,10 @@ BTranslatorRoster::Private::GetTranslators(BPositionIO* source, while (iterator != fTranslators.end()) { BTranslator& translator = *iterator->second.translator; - status_t status = source->Seek(0, SEEK_SET); - if (status < B_OK) { + off_t pos = source->Seek(0, SEEK_SET); + if (pos != 0) { delete[] array; - return status; + return pos < 0 ? status_t(pos) : B_IO_ERROR; } int32 formatsCount = 0; @@ -1516,7 +1516,10 @@ BTranslatorRoster::Translate(BPositionIO* source, const translator_info* info, if (translator == NULL) return B_NO_TRANSLATOR; - status_t status = source->Seek(0, SEEK_SET); + status_t status = B_OK; + off_t pos = source->Seek(0, SEEK_SET); + if (pos != 0) + status = pos < 0 ? (status_t)pos : B_IO_ERROR; if (status == B_OK) { status = translator->Translate(source, info, ioExtension, wantOutType, destination); @@ -1565,15 +1568,22 @@ BTranslatorRoster::Translate(translator_id id, BPositionIO* source, if (translator == NULL) return B_NO_TRANSLATOR; - status_t status = source->Seek(0, SEEK_SET); - if (status == B_OK) { + status_t status; + off_t pos = source->Seek(0, SEEK_SET); + if (pos == 0) { translator_info info; status = translator->Identify(source, NULL, ioExtension, &info, wantOutType); if (status >= B_OK) { - status = translator->Translate(source, &info, ioExtension, wantOutType, - destination); + off_t pos = source->Seek(0, SEEK_SET); + if (pos != 0) + status = pos < 0 ? (status_t)pos : B_IO_ERROR; + else { + status = translator->Translate(source, &info, ioExtension, wantOutType, + destination); + } } - } + } else + status = pos < 0 ? (status_t)pos : B_IO_ERROR; translator->Release(); return status;