This is the mail archive of the
mailing list for the glibc project.
[PATCH 0/2] iconv_prog: don't slurp input; fix -c exit status
- From: Benjamin Herr <ben at 0x539 dot de>
- To: libc-alpha at sourceware dot org
- Date: Mon, 10 Aug 2015 00:14:22 +0200
- Subject: [PATCH 0/2] iconv_prog: don't slurp input; fix -c exit status
- Authentication-results: sourceware.org; auth=none
I'd like to submit two patches for your consideration.
The first patch attempts to address bug #6050 that I recently ran into.
The iconv program currently read its entire input into a single buffer before
doing anything with it, which prevents its use in pipelines or with very large
files. As far as I can tell, this limitation is based on the unwillingness to
feed incomplete multibyte sequences to the iconv function, which is actually
not a problem, as is outlined in the comments to the bug report.
My patch changes the iconv program to use a statically sized input buffer, call
the iconv function repeatedly, and preserve incomplete multibyte sequences
between calls in the hope that they get completed by subsequently read input.
The second patch changes how the exit status is determined in the presence of
the -c option. I believe the intention has always been to track whether an
invalid input sequence has been encountered and skipped, and exit with non-zero
exit status if so. However this only seems to work in some circumstances
As the first patch affects in which situations that works, I thought it was
necessary to try to do it "properly", so that this second patch makes some
changes to more explicitly track the "have we seen invalid input sequences"
This is my first attempt at contributing to glibc, so please do not hesitate to
let me know just how badly I have messed this up. I would also appreciate any
guidance as to how to set up copyright assignment, if that is necessary for
such a small change.
Benjamin Herr (2):
iconv_prog: Don't slurp whole input at once [BZ #6050]
iconv_prog: Track if invalid sequences were seen.
iconv/iconv_prog.c | 292 +++++++++++++++++++++++++++++++----------------------
1 file changed, 170 insertions(+), 122 deletions(-)