To: vim-dev@vim.org Subject: Patch 6.1.216 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.1.216 Problem: When dynamically loading the iconv library, the error codes may be confused. Solution: Use specific error codes for iconv and redefine them for dynamic loading. (Yasuhiro Matsumoto) Files: src/fileio.c, src/mbyte.c, src/vim.h *** ../vim61.215/src/fileio.c Mon Oct 7 20:45:41 2002 --- src/fileio.c Sat Oct 12 15:27:42 2002 *************** *** 1194,1200 **** if (ret == (size_t)-1) /* need to reset the state after an error */ (void)iconv(iconv_fd, NULL, NULL, NULL, NULL); ! if ((ret == (size_t)-1 && ICONV_ERRNO != EINVAL) || from_size > CONV_RESTLEN) goto rewind_retry; --- 1215,1221 ---- if (ret == (size_t)-1) /* need to reset the state after an error */ (void)iconv(iconv_fd, NULL, NULL, NULL, NULL); ! if ((ret == (size_t)-1 && ICONV_ERRNO != ICONV_EINVAL) || from_size > CONV_RESTLEN) goto rewind_retry; *************** *** 4176,4182 **** * If iconv() has an error or there is not enough room, fail. */ if ((iconv(ip->bw_iconv_fd, &from, &fromlen, &to, &tolen) ! == (size_t)-1 && ICONV_ERRNO != EINVAL) || fromlen > CONV_RESTLEN) { ip->bw_conv_error = TRUE; --- 4335,4341 ---- * If iconv() has an error or there is not enough room, fail. */ if ((iconv(ip->bw_iconv_fd, &from, &fromlen, &to, &tolen) ! == (size_t)-1 && ICONV_ERRNO != ICONV_EINVAL) || fromlen > CONV_RESTLEN) { ip->bw_conv_error = TRUE; *** ../vim61.215/src/mbyte.c Mon Sep 16 21:05:55 2002 --- src/mbyte.c Sat Oct 12 15:33:10 2002 *************** *** 94,102 **** #ifdef X_LOCALE #include #endif - #ifndef EILSEQ - # define EILSEQ 123 - #endif #if defined(FEAT_MBYTE) || defined(PROTO) --- 94,99 ---- *************** *** 2551,2557 **** fromlen = slen; for (;;) { ! if (len == 0 || ICONV_ERRNO == E2BIG) { /* Allocate enough room for most conversions. When re-allocating * increase the buffer size. */ --- 2574,2580 ---- fromlen = slen; for (;;) { ! if (len == 0 || ICONV_ERRNO == ICONV_E2BIG) { /* Allocate enough room for most conversions. When re-allocating * increase the buffer size. */ *************** *** 2573,2579 **** *to = NUL; break; } ! if (ICONV_ERRNO == EILSEQ) { /* Can't convert: insert a '?' and skip a character. This assumes * conversion from 'encoding' to something else. In other --- 2596,2604 ---- *to = NUL; break; } ! /* Check both ICONV_EILSEQ and EILSEQ, because the dynamically loaded ! * iconv library may use one of them. */ ! if (ICONV_ERRNO == ICONV_EILSEQ || ICONV_ERRNO == EILSEQ) { /* Can't convert: insert a '?' and skip a character. This assumes * conversion from 'encoding' to something else. In other *************** *** 2585,2591 **** from += l; fromlen -= l; } ! else if (ICONV_ERRNO != E2BIG) { /* conversion failed */ vim_free(result); --- 2610,2616 ---- from += l; fromlen -= l; } ! else if (ICONV_ERRNO != ICONV_E2BIG) { /* conversion failed */ vim_free(result); *** ../vim61.215/src/vim.h Mon Sep 16 22:00:32 2002 --- src/vim.h Sat Oct 12 15:27:16 2002 *************** *** 1613,1623 **** # define ENC_LATIN1 0x200 /* Latin1 */ # ifdef USE_ICONV ! /* On Win32 iconv.dll is dynamically loaded. */ # ifdef DYNAMIC_ICONV # define ICONV_ERRNO (*iconv_errno()) # else # define ICONV_ERRNO errno # endif # endif --- 1613,1632 ---- # define ENC_LATIN1 0x200 /* Latin1 */ # ifdef USE_ICONV ! # ifndef EILSEQ ! # define EILSEQ 123 ! # endif # ifdef DYNAMIC_ICONV + /* On Win32 iconv.dll is dynamically loaded. */ # define ICONV_ERRNO (*iconv_errno()) + # define ICONV_E2BIG 7 + # define ICONV_EINVAL 22 + # define ICONV_EILSEQ 42 # else # define ICONV_ERRNO errno + # define ICONV_E2BIG E2BIG + # define ICONV_EINVAL EINVAL + # define ICONV_EILSEQ EILSEQ # endif # endif *** ../vim61.215/src/version.c Fri Oct 11 20:38:35 2002 --- src/version.c Sat Oct 12 15:45:14 2002 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 216, /**/ -- panic("Foooooooood fight!"); -- In the kernel source aha1542.c, after detecting a bad segment list /// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\ /// Creator of Vim - Vi IMproved -- http://www.vim.org \\\ \\\ Project leader for A-A-P -- http://www.a-a-p.org /// \\\ Lord Of The Rings helps Uganda - http://iccf-holland.org/lotr.html ///