bug-texinfo
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using iconv in stand-alone info


From: Eli Zaretskii
Subject: Re: Using iconv in stand-alone info
Date: Wed, 23 Dec 2015 19:38:52 +0200

> Date: Mon, 21 Dec 2015 22:24:01 +0200
> From: Eli Zaretskii <address@hidden>
> Cc: address@hidden
> 
> > Date: Mon, 21 Dec 2015 19:51:56 +0000
> > From: Gavin Smith <address@hidden>
> > Cc: Texinfo <address@hidden>
> > 
> > >   http://lists.gnu.org/archive/html/bug-wget/2015-12/msg00111.html
> > >   http://lists.gnu.org/archive/html/bug-wget/2015-12/msg00113.html
> > >
> > > So I suggest we fix this in Info by adding a call to 'iconv' when the
> > > conversion returns with success.
> > 
> > Sounds good, I'm not opposed to such a change. Will you write the
> > change?
> 
> OK.

Attached.  OK to commit?

--- info/info-utils.c~0 2015-12-19 18:47:40.000000000 +0200
+++ info/info-utils.c   2015-12-23 18:52:38.883781500 +0200
@@ -852,7 +852,9 @@ copy_converting (long n)
       iconv_ret = text_buffer_iconv (&output_buf, iconv_to_output,
                                      &inptr, &bytes_left);
 
-      if (iconv_ret != (size_t) -1)
+      if (iconv_ret != (size_t) -1
+         && text_buffer_iconv (&output_buf, iconv_to_output,
+                               NULL, NULL) != (size_t) -1)
         /* Success: all of input converted. */
         break;
 
@@ -918,7 +920,13 @@ copy_converting (long n)
           iconv_ret = iconv (iconv_to_utf8, &inptr, &bytes_left,
                              &utf8_char_ptr, &utf8_char_free);
           /* If we managed to write a character: */
-          if (utf8_char_ptr > utf8_char) break;
+          if (utf8_char_ptr > utf8_char)
+           {
+             if (iconv_ret == (size_t) -1)
+               iconv_ret = iconv (iconv_to_utf8, NULL, NULL,
+                                  &utf8_char_ptr, &utf8_char_free);
+             break;
+           }
         }
 
       /* errno == E2BIG if iconv ran out of output buffer,
@@ -1933,7 +1941,7 @@ text_buffer_iconv (struct text_buffer *b
 
   outptr = text_buffer_base (buf) + text_buffer_off (buf);
   out_bytes_left = text_buffer_space_left (buf);
-  iconv_ret = iconv (iconv_to_output, inbuf, inbytesleft,
+  iconv_ret = iconv (iconv_state, inbuf, inbytesleft,
                      &outptr, &out_bytes_left);
 
   text_buffer_off (buf) = outptr - text_buffer_base (buf);    



reply via email to

[Prev in Thread] Current Thread [Next in Thread]