[cairo] SUMMARY of Implementing cairo_read_func_t/cairo_write_func_t properly

Bernhard R. Fischer bf at abenteuerland.at
Sat Mar 12 10:20:17 UTC 2016


On 2016-03-11 18:17, Bill Spitzak wrote:
> On Wed, Mar 9, 2016 at 10:46 PM, Bernhard R. Fischer <bf at abenteuerland.at>
> wrote:
> 
>>
>>>>>>       if (unlikely (status)) {
>>>>>> +        if ((int) status < 0) status = CAIRO_STATUS_READ_ERROR;
>>>>>>         cairo_status_t *error = png_get_error_ptr (png);
>>>>>>         if (*error == CAIRO_STATUS_SUCCESS)
>>>>>>             *error = status;
>>>>>
>>>>> This would probably need to look more like:
>>>>>
>>>>>     status = png_closure->read_func (png_closure->closure, data, size);
>>>>>     if (unlikely (status)) {
>>>>>         cairo_status_t *error;
>>>>>         if ((int) status < 0)
>>>>>             status = CAIRO_STATUS_READ_ERROR;
>>>>>         error = png_get_error_ptr (png);
>>>>
>>>>
>>>> Why? It makes no difference.
>>>>
>>>
>>> The variables have to be declared first before any statements (required
>> by
>>> older C compilers).
>>
>> I just inserted the 1-line "if ( )..." statement. Everything else is as
>> it is in the current (1.14.6) cairo-png.c.
>>
> 
> The problem is that you have to put the declaration of the "error" variable
> before the statement. Annoying but Cairo is following these rules so that
> it works with some rather old compilers.
> 


I very well understand that.
But again, if you look at the current code (1.14.6) you will see that it
is not in there like that.
Thus, this is an additionally patch which basically has nothing to do
with the original discussion of this thread. But of course, it could be
changed at once together with my proposal.


Bernhard






More information about the cairo mailing list