From d390baeedeb0a1f53d87ac0826b623b7ef5bb96f Mon Sep 17 00:00:00 2001 From: Matthew Wilber Date: Thu, 2 Jan 2003 02:31:49 +0000 Subject: [PATCH] added comments, made minor changes to error handling, changed a buffer type from char to uint8 git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2346 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../translators/stxttranslator/STXTTranslator.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/add-ons/translators/stxttranslator/STXTTranslator.cpp b/src/add-ons/translators/stxttranslator/STXTTranslator.cpp index 29d9956b58..34f898ff3d 100644 --- a/src/add-ons/translators/stxttranslator/STXTTranslator.cpp +++ b/src/add-ons/translators/stxttranslator/STXTTranslator.cpp @@ -291,7 +291,8 @@ STXTTranslator::OutputFormats(int32 *out_count) const // Returns: B_OK, if the data appears to be in the STXT format, // B_NO_TRANSLATOR, if the data is not in the STXT format or // returns B_ERROR if errors were encountered in trying to -// determine the format +// determine the format, or another error code if there was an +// error calling BPostionIO::Read() // --------------------------------------------------------------- status_t identify_stxt_header(const TranslatorStyledTextStreamHeader &header, @@ -301,7 +302,7 @@ identify_stxt_header(const TranslatorStyledTextStreamHeader &header, const ssize_t ktxtsize = sizeof(TranslatorStyledTextTextHeader); const ssize_t kstylsize = sizeof(TranslatorStyledTextStyleHeader); - char buffer[max(ktxtsize, kstylsize)]; + uint8 buffer[max(ktxtsize, kstylsize)]; // Check the TEXT header TranslatorStyledTextTextHeader txtheader; @@ -335,6 +336,8 @@ identify_stxt_header(const TranslatorStyledTextStreamHeader &header, ssize_t read = 0; TranslatorStyledTextStyleHeader stylheader; read = inSource->Read(buffer, kstylsize); + if (read < 0) + return read; if (read != kstylsize && read != 0) return B_NO_TRANSLATOR; @@ -477,6 +480,8 @@ identify_txt_header(uint8 *data, int32 nread, // // B_OK, if this translator understand the data and there were // no errors found +// +// Other errors if BPositionIO::Read() returned an error value // --------------------------------------------------------------- status_t STXTTranslator::Identify(BPositionIO *inSource, @@ -538,7 +543,7 @@ STXTTranslator::Identify(BPositionIO *inSource, // // Postconditions: // -// Returns: B_BAD_VALUE, if the options in ioExtension are bad +// Returns: B_BAD_VALUE, if outType is invalid // // B_NO_TRANSLATOR, if this translator doesn't understand the data //