Re: Implementing cairo_read_func_t/cairo_write_func_t properly

Bernhard Fischer <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <2455955.1x9VdR2gzp@winnie>
On Monday 04 January 2016 10:24:36 Bill Spitzak wrote:
> On Sun, Jan 3, 2016 at 11:50 PM, Bernhard Fischer <[email protected]>
> 
> wrote:
> > On Sunday 03 January 2016 14:29:57 Behdad Esfahbod wrote:
> > > On 16-01-02 09:34 PM, Bill Spitzak wrote:
> > > > On 01/02/2016 01:27 PM, Bernhard Fischer wrote:
> > > >> On Saturday 02 January 2016 13:01:39 Bill Spitzak wrote:
> > > >>> I think the api has to be changed to return number of bytes read,
> > 
> > and a
> > 
> > > >>> negative number for eof.
> > > >> 
> > > >> The return value should be the number of bytes read and on eof it is
> > > >> something between 0 and length. If it is called again at/after eof it
> > > >> returns 0 again. A negative value (-1) is only returned in case of
> > 
> > error
> > 
> > > >> (but not EOF). This is exactly like read(3) behaves.
> > > > 
> > > > Yes you are correct, I made a typo, I meant to say "error" where I
> > 
> > wrote
> > 
> > > > "eof". I fully agree with your description.
> > > 
> > > Given that we cannot change the signature now, I suggest we hack it up
> > > to
> > > interpret negative numbers returned from the callback to be interpreted
> > 
> > as a
> > 
> > > short read; the absolute value of the returned negative number is the
> > > number of bytes read.
> > > 
> > > Cairo itself won't need to be updated, but clients should be encouraged
> > 
> > to
> > 
> > > implement the new behaviour.
> > > 
> > > b
> > 
> > I agree, that is a backwards compatible solution.
> 
> I think you need to make negative number mean "it was this short". Ie if a
> request to read 10 bytes only reads 8, it returns -2.


That's exactly what Behdad said.

-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.