[interfacekit] more questions about BString
- From: Oliver Tappe <openbeos@xxxxxxxxxxxxxxx>
- To: interfacekit@xxxxxxxxxxxxx
- Date: Mon, 03 Nov 2003 17:25:42 +0100
Hi everyone,
when implementing the BString-patch we spoke about earlier, I tried to
follow the idea that the BString-class should clamp all input values
(offsets) to sensible values (0 <= offset <= length).
As the resulting testrun shows, this causes the resulting behaviour to
differ from R5-BString in some ways:
- R5 allows calls to Insert( const char* str, int32 pos) with negative
positions, giving IMHO weird results...
Insert( "INSERT THIS", -1)
on an empty BString yields a string that contains "NSERT THIS".
This behaviour ist not at all documented by the BeBook.
My suggestion would be to clamp negative offsets to 0 (yielding "INSERT
THIS" for the given example).
- Remove( int32 fromOffset, int32 length)
silently accepts fromOffset<0 (using 0), but doesn't clamp length likewise:
BString s("A String");
s.Remove( 4, 30);
yields "A String" instead of "A St".
- the (I)Find...()-methods seem to always return B_ERROR if you pass a
negative fromOffset. My patched methods clamp fromOffset to 0 and then
execute the search, possibly yielding positive results.
No I wonder what to do with that, since the BeBook doesn't have any info on
that...
Should I try to stick to R5 as much as possible (be as compatible as can
be)?
Or is it better to try to implement consistent behaviour and clamp *all*
offset parameters?
cheers,
Oliver
- Follow-Ups:
- [interfacekit] Re: more questions about BString
- From: Erik Jaesler
- [interfacekit] Re: more questions about BString
- From: Axel Dörfler
- [interfacekit] Re: more questions about BString
- From: Andrew Bachmann
Other related posts:
- » [interfacekit] more questions about BString
- » [interfacekit] Re: more questions about BString
- » [interfacekit] Re: more questions about BString
- » [interfacekit] Re: more questions about BString
- » [interfacekit] Re: more questions about BString
- » [interfacekit] Re: more questions about BString
- » [interfacekit] Re: more questions about BString
- [interfacekit] Re: more questions about BString
- From: Erik Jaesler
- [interfacekit] Re: more questions about BString
- From: Axel Dörfler
- [interfacekit] Re: more questions about BString
- From: Andrew Bachmann