+ if (errno == E2BIG) {
+ /*
+ * Bump up the buffer by at least a factor of 2
+ * over what we need.
+ */
+ size_t bumpup = inbytes * 2, ob_off = ob - dest_buffer;
+ dest_buffer_size += bumpup;
+ dest_buffer = mh_xrealloc(dest_buffer,
+ dest_buffer_size);
+ ob = dest_buffer + ob_off;
+ outbytes += bumpup;
+ outbytes_before += bumpup;
+ goto iconv_start;
+ }
+ if (errno == EINVAL) {
+ /* middle of multi-byte sequence */
+ if (write (fd, dest_buffer, outbytes_before - outbytes) < 0) {
+ advise (dest, "write");
+ }
+ fseeko (*fp, -inbytes, SEEK_CUR);
+ if (end > 0) bytes_to_read += inbytes;
+ /* advise(NULL, "convert_charset: EINVAL"); */
+ continue;
+ }
+ if (errno == EILSEQ) {
+ /* invalid multi-byte sequence */
+ if (fromutf8) {
+ for (++ib, --inbytes;
+ inbytes > 0 &&
+ (((unsigned char) *ib) & 0xc0) == 0x80;
+ ++ib, --inbytes)
+ continue;
+ } else {
+ ib++; inbytes--; /* skip it */
+ }
+ (*ob++) = '?'; outbytes --;
+ /* advise(NULL, "convert_charset: EILSEQ"); */
+ goto iconv_start;
+ }
+ advise (NULL, "convert_charset: errno = %d", errno);