[haiku-development] BString::CopyInto

  • From: "François Revol" <revol@xxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Thu, 08 May 2008 02:28:44 +0200 CEST

I used CopyInto like this in CamDevice.cpp, and though it works in BeOS
it doesn't in Haiku :

#include <String.h>
#include <stdio.h>

int main(void)
{
        BString str("aaa,bee,cee");
        int32 i;
        for (i = 0; i > -1 && i < str.Length(); ) {
                BString name;
                str.CopyInto(name, i, str.FindFirst(',', i) - i);
                printf("@%d:'%s'\n", i, name.String());

                i = str.FindFirst(',', i+1);
                if (i > - 1)
                        i++;
        }
}

In BeOS it gives:
@0:'aaa'
@4:'bee'
@8:'cee'

in Haiku:
@0:'aaa'
@4:'bee'
@8:''


CopyInto() just takes charCount < 0 as = 0 instead of "until last" as
BeOS does.
Oddly the behaviour when < 0 isn't documented in the Bebook.

I know I can change my code, but surely some other code exists that
does it too...

François.

Other related posts: