This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: iconv_open behaviour on EILSEQ
- From: Andreas Schwab <schwab at suse dot de>
- To: Stefan Hoffmeister <bug dot glibc-gnu dot org at econos dot de>
- Cc: libc-alpha at sources dot redhat dot com
- Date: Sat, 04 May 2002 21:21:10 +0200
- Subject: Re: iconv_open behaviour on EILSEQ
- References: <hq58ducfaii8opja2aehdrnrflpg2uucff@4ax.com>
Stefan Hoffmeister <bug.glibc-gnu.org@econos.de> writes:
|> Hi,
|>
|> the glibc documentation for iconv_open states
|>
|> <quote>
|>
|> EILSEQ
|>
|> The conversion stopped because of an invalid byte sequence in the input.
|> After the call *inbuf points at the first byte of the invalid byte
|> sequence.
|>
|> </quote>
|>
|> Empirically, I can see that *outbuf and *outbytesleft have been modified
|> to reflect the successful conversions up to the point where the
|> character triggering EILSEQ is located.
|>
|> Is this behaviour merely a side-effect of the current implementation, or
|> is that behaviour that should be documented for glibc (and that one can
|> rely on)?
|>
|> SUSv2 is completely silent about the state of anything in the presence
|> of EILSEQ; same problem in the last publicly accessible draft of SUSv3.
POSIX.1-2001 says:
If a sequence of input bytes does not form a valid character in the
specified codeset, conversion shall stop after the previous
successfully converted character. [...] The variable pointed to by
outbuf shall be updated to point to the byte following the last byte
of converted output data. The value pointed to by outbytesleft shall
be decremented to reflect the number of bytes still available in the
output buffer. [...]
RETURN VALUE
The iconv() function shall update the variables pointed to by the
arguments to reflect the extent of the conversion and return the
number of non-identical conversions performed. If the entire string
in the input buffer is converted, the value pointed to by inbytesleft
shall be 0. If the input conversion is stopped due to any conditions
mentioned above, the value pointed to by inbytesleft shall be non-zero
and errno shall be set to indicate the condition. If an error occurs,
iconv() shall return (size_t) 1 and set errno to indicate the error.
This is pretty unambiguous, IMHO. Even in presence of errors the argument
pointers must be updated.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE GmbH, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."