]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
(process_block): For stateful charsets write out byte sequence to get
authorUlrich Drepper <drepper@redhat.com>
Fri, 26 Nov 1999 06:18:29 +0000 (06:18 +0000)
committerUlrich Drepper <drepper@redhat.com>
Fri, 26 Nov 1999 06:18:29 +0000 (06:18 +0000)
to initial state at the end of the file.

iconv/iconv_prog.c

index fa226059191cbd0472df81f28f586f244d193968..f17c46238782094f3e172a44aa28098b3a2a6fa4 100644 (file)
@@ -334,8 +334,32 @@ conversion stopped due to problem in writing the output"));
        }
 
       if (n != (size_t) -1)
-       /* Everything is processed.  */
-       break;
+       {
+         /* All the input test is processed.  For state-dependent
+             character sets we have to flush the state now.  */
+         outptr = outbuf;
+         outlen = OUTBUF_SIZE;
+         n = iconv (cd, NULL, NULL, &outptr, &outlen);
+
+         if (outptr != outbuf)
+           {
+             /* We have something to write out.  */
+             int errno_save = errno;
+
+             if (fwrite (outbuf, 1, outptr - outbuf, output) < outptr - outbuf
+                 || ferror (output))
+               {
+                 /* Error occurred while printing the result.  */
+                 error (0, 0, _("\
+conversion stopped due to problem in writing the output"));
+                 return -1;
+               }
+
+             errno = errno_save;
+           }
+
+         break;
+       }
 
       if (errno != E2BIG)
        {