[Scummvm-devel] incorrect use of stream functions

Norbert Lange lange at chello.at
Sun Aug 16 17:49:01 CEST 2009


Am 15.08.2009, 17:40 Uhr, schrieb Johannes Schickel <lordhoto at scummvm.org>:

> Norbert Lange wrote:
>> So there are 3 ways to deal with that:
>> *) update the comments and make sure streams behave the defined way.
>>
>
> Actually that sounds wrong. It makes IMHO no sense to change the defined
> behavior of certain code, just because some code violates the currently
> defined behavior.
>
>> *) the code that depends on Stream::readXX returning 0 for eos is surely
>> reading character-streams, so keep the Stream::readXX returnin undefined
>> values on eos, and define a function analog to C`s getchar() which  
>> returns
>> -1 in case of error. And make the illbehaving code use that instead.
>>
>
> That sounds fine, but of course we could just change the XMLParser code
> to use Stream::err and Stream::eos instead of checking the return value.

or use the Stream::read which additionally reports back if the requested  
byte really got read in 1 single functioncall.

I agree that fixing the code which incorrectly uses the streams would be  
the best way to go,
but the problem here is detecting all code which has to be changed.
I found the XMLParser easily because its run everytime ScummVM starts, but  
what about code hidden in engines thats only called under certain  
conditions?

I just uploaded the patch btw:
https://sourceforge.net/tracker/?func=detail&aid=2838562&group_id=37116&atid=418822

Cheers, Norbert




More information about the Scummvm-devel mailing list