* 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
This commit is contained in:
@@ -682,9 +682,9 @@ BTranslatorRoster::Private::Identify(BPositionIO* source,
|
|||||||
while (iterator != fTranslators.end()) {
|
while (iterator != fTranslators.end()) {
|
||||||
BTranslator& translator = *iterator->second.translator;
|
BTranslator& translator = *iterator->second.translator;
|
||||||
|
|
||||||
status_t status = source->Seek(0, SEEK_SET);
|
off_t pos = source->Seek(0, SEEK_SET);
|
||||||
if (status != B_OK)
|
if (pos != 0)
|
||||||
return status;
|
return pos < 0 ? (status_t)pos : B_IO_ERROR;
|
||||||
|
|
||||||
int32 formatsCount = 0;
|
int32 formatsCount = 0;
|
||||||
const translation_format* formats = translator.InputFormats(&formatsCount);
|
const translation_format* formats = translator.InputFormats(&formatsCount);
|
||||||
@@ -735,10 +735,10 @@ BTranslatorRoster::Private::GetTranslators(BPositionIO* source,
|
|||||||
while (iterator != fTranslators.end()) {
|
while (iterator != fTranslators.end()) {
|
||||||
BTranslator& translator = *iterator->second.translator;
|
BTranslator& translator = *iterator->second.translator;
|
||||||
|
|
||||||
status_t status = source->Seek(0, SEEK_SET);
|
off_t pos = source->Seek(0, SEEK_SET);
|
||||||
if (status < B_OK) {
|
if (pos != 0) {
|
||||||
delete[] array;
|
delete[] array;
|
||||||
return status;
|
return pos < 0 ? status_t(pos) : B_IO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 formatsCount = 0;
|
int32 formatsCount = 0;
|
||||||
@@ -1516,7 +1516,10 @@ BTranslatorRoster::Translate(BPositionIO* source, const translator_info* info,
|
|||||||
if (translator == NULL)
|
if (translator == NULL)
|
||||||
return B_NO_TRANSLATOR;
|
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) {
|
if (status == B_OK) {
|
||||||
status = translator->Translate(source, info, ioExtension, wantOutType,
|
status = translator->Translate(source, info, ioExtension, wantOutType,
|
||||||
destination);
|
destination);
|
||||||
@@ -1565,15 +1568,22 @@ BTranslatorRoster::Translate(translator_id id, BPositionIO* source,
|
|||||||
if (translator == NULL)
|
if (translator == NULL)
|
||||||
return B_NO_TRANSLATOR;
|
return B_NO_TRANSLATOR;
|
||||||
|
|
||||||
status_t status = source->Seek(0, SEEK_SET);
|
status_t status;
|
||||||
if (status == B_OK) {
|
off_t pos = source->Seek(0, SEEK_SET);
|
||||||
|
if (pos == 0) {
|
||||||
translator_info info;
|
translator_info info;
|
||||||
status = translator->Identify(source, NULL, ioExtension, &info, wantOutType);
|
status = translator->Identify(source, NULL, ioExtension, &info, wantOutType);
|
||||||
if (status >= B_OK) {
|
if (status >= B_OK) {
|
||||||
status = translator->Translate(source, &info, ioExtension, wantOutType,
|
off_t pos = source->Seek(0, SEEK_SET);
|
||||||
destination);
|
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();
|
translator->Release();
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
|
|||||||
Reference in New Issue
Block a user