Skip to content

Commit 4c5433e

Browse files
committed
Improve interactive behaviour of iconv program.
1 parent b918f35 commit 4c5433e

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2011-07-03 Bruno Haible <bruno@clisp.org>
2+
3+
Improve interactive behaviour of iconv program.
4+
* src/iconv.c (convert): Flush the output before starting a possibly
5+
blocking safe_read call.
6+
17
2011-07-03 Bruno Haible <bruno@clisp.org>
28

39
Fix interactive behaviour of iconv program.

src/iconv.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,11 @@ static int convert (iconv_t cd, int infile, const char* infilename)
684684
line = 1; column = 0;
685685
iconv(cd,NULL,NULL,NULL,NULL);
686686
for (;;) {
687-
size_t inbufsize = safe_read(infile,inbuf+4096,4096);
687+
size_t inbufsize;
688+
/* Transfer the accumulated output to its destination, in case the
689+
safe_read() call will block. */
690+
fflush(stdout);
691+
inbufsize = safe_read(infile,inbuf+4096,4096);
688692
if (inbufsize == 0 || inbufsize == SAFE_READ_ERROR) {
689693
infile_error = (inbufsize == SAFE_READ_ERROR ? errno : 0);
690694
if (inbufrest == 0)

0 commit comments

Comments
 (0)