[haiku-development] Re: Teapot diff

  • From: Fredrik Modéen <fredrik@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Thu, 25 Oct 2007 14:00:57 +0200 (CEST)

> Hi Fredrik,
>
> wow, that's been a lot of work! Thanks! I am going to apply and commit
> your
> patch. Just a few comments for the future:
>
> Occasionally, you write this:
>
>       if (fObjectView)
>               fObjectView->DirectConnected( info );
>       fObjectView->EnableDirectMode( true );
>
> Should be:
>
>       if (fObjectView)
>               fObjectView->DirectConnected(info);
>       fObjectView->EnableDirectMode(true);
>
> Most of the times you did this, but sometimes, you would have no space
> behind a comma (probably leftover from the old code, but I mention it
> anyways):
>
>       msg.ReplaceInt32("color",lightGreen);
>       sm->AddItem(item = new BMenuItem("Green",new BMessage(msg)));
>       item->SetTarget(fObjectView);
>
> Should be:
>
>       msg.ReplaceInt32("color", lightGreen);
>       sm->AddItem(item = new BMenuItem("Green", new BMessage(msg)));
>       item->SetTarget(fObjectView);
>
> And there should be spaces between operators:
>
>       float f = mb->Bounds().IntegerHeight()+1;
>       SetSizeLimits(32,1024,32+f,1024+f);
>
> Should be:
>
>       float f = mb->Bounds().IntegerHeight() + 1;
>       SetSizeLimits(32, 1024, 32 + f, 1024 + f);
>
> (The naming should be fixed too, but I know that is leftover from the old
> code, and I am happy it has improved much already with your patch.)
Naming like in bad? yea those are not main ;) like you said :)

May patches are improving :)

By the way does BeOS/Haiku API have any way of reading line by line from a
file? I'm thinking of continue the playlist save/load and settings
asve/Load. This mailing list gave me something like this along time ago to
my other project. Would this do? (after changing it to follow our guide
lines)

bool FileHandeler::getline(BFile *file, BString& string, bool useConvertUTF8)
{
        BString temp;
        static char buffer[4096];
        static off_t positionInBuffer;
        static ssize_t amt_read;
        string = "";    // Clear out old string
        // Fill up the buffer with the first chunk of code
        if (positionInBuffer == 0)
                amt_read = file->Read(&buffer, sizeof(buffer));
        while(amt_read > 0)
        {
                while(positionInBuffer < amt_read)
                {
                        // Return true if we hit a newline or the end of the 
file
                        if (buffer[positionInBuffer] == '\n')
                        {
                                positionInBuffer++;
                                //Convert begin
                                int32 state = 0;
                                int32 bufferLen = string.Length();
                                int32 destBufferLen = bufferLen;
                                char destination[destBufferLen];
                                if(useConvertUTF8)
                                        
convert_to_utf8(B_MS_WINDOWS_1252_CONVERSION, string.String(),
&bufferLen, destination, &destBufferLen, &state);
                                string = destination;
                                //Convert ends
                                return true;
                        }
                        string += buffer[positionInBuffer];
                        positionInBuffer++;
                }

                // Once the buffer runs out, grab some more and start again
                amt_read = file->Read(&buffer, sizeof(buffer));
                positionInBuffer = 0;
        }
        return false;
}

>
> Thanks a lot again!
>
> Best regards,
> -Stephan
>
>


-- 
MVH
Fredrik Modéen


Other related posts: