This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [dthorpe@inprise.com] libc/1840: Function result of iconv() is always zero in non-error case.


Andreas Jäger writes:

> the return value of the iconv
> function in this example is 0.  AFAIK this is correct, isn't it?

Yes it is.

> In glibc 2.1.2, iconv() returned the number of bytes written to the
> output buffer, or -1 on error.  In glibc 2.1.3, iconv() returns zero
> or -1.  The 2.1.2 documentation (in manual/charset.texi) states that
> iconv() is to return the number of conversions performed.

The glibc-2.1.2 implementation and documentation was incorrect. The
new documentation states:

    the function returns the number of non-reversible conversions
    performed.

> This breaks existing code which used the function result as the indicator of 
> the output data length.

This code is incorrect anyway. The right measure how many output bytes
were produced is the amount by which the outbuf pointer was increased
(or, equivalently, the amount by which the outbytesleft value was
decreased) through the iconv() call.

Bruno

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]