|
Karsten Hopp |
81c285 |
To: vim-dev@vim.org
|
|
Karsten Hopp |
81c285 |
Subject: Patch 7.2.244
|
|
Karsten Hopp |
81c285 |
Fcc: outbox
|
|
Karsten Hopp |
81c285 |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
Karsten Hopp |
81c285 |
Mime-Version: 1.0
|
|
Karsten Hopp |
81c285 |
Content-Type: text/plain; charset=UTF-8
|
|
Karsten Hopp |
81c285 |
Content-Transfer-Encoding: 8bit
|
|
Karsten Hopp |
81c285 |
------------
|
|
Karsten Hopp |
81c285 |
|
|
Karsten Hopp |
81c285 |
Patch 7.2.244
|
|
Karsten Hopp |
81c285 |
Problem: When 'enc' is utf-8 and 'fenc' is latin1, writing a non-latin1
|
|
Karsten Hopp |
81c285 |
character gives a conversion error without any hint what is wrong.
|
|
Karsten Hopp |
81c285 |
Solution: When known add the line number to the error message.
|
|
Karsten Hopp |
81c285 |
Files: src/fileio.c
|
|
Karsten Hopp |
81c285 |
|
|
Karsten Hopp |
81c285 |
|
|
Karsten Hopp |
81c285 |
*** ../vim-7.2.243/src/fileio.c 2009-07-29 12:09:49.000000000 +0200
|
|
Karsten Hopp |
81c285 |
--- src/fileio.c 2009-07-29 17:04:06.000000000 +0200
|
|
Karsten Hopp |
81c285 |
***************
|
|
Karsten Hopp |
81c285 |
*** 121,126 ****
|
|
Karsten Hopp |
81c285 |
--- 121,128 ----
|
|
Karsten Hopp |
81c285 |
char_u *bw_conv_buf; /* buffer for writing converted chars */
|
|
Karsten Hopp |
81c285 |
int bw_conv_buflen; /* size of bw_conv_buf */
|
|
Karsten Hopp |
81c285 |
int bw_conv_error; /* set for conversion error */
|
|
Karsten Hopp |
81c285 |
+ linenr_T bw_conv_error_lnum; /* first line with error or zero */
|
|
Karsten Hopp |
81c285 |
+ linenr_T bw_start_lnum; /* line number at start of buffer */
|
|
Karsten Hopp |
81c285 |
# ifdef USE_ICONV
|
|
Karsten Hopp |
81c285 |
iconv_t bw_iconv_fd; /* descriptor for iconv() or -1 */
|
|
Karsten Hopp |
81c285 |
# endif
|
|
Karsten Hopp |
81c285 |
***************
|
|
Karsten Hopp |
81c285 |
*** 2924,2929 ****
|
|
Karsten Hopp |
81c285 |
--- 2925,2931 ----
|
|
Karsten Hopp |
81c285 |
linenr_T lnum;
|
|
Karsten Hopp |
81c285 |
long nchars;
|
|
Karsten Hopp |
81c285 |
char_u *errmsg = NULL;
|
|
Karsten Hopp |
81c285 |
+ int errmsg_allocated = FALSE;
|
|
Karsten Hopp |
81c285 |
char_u *errnum = NULL;
|
|
Karsten Hopp |
81c285 |
char_u *buffer;
|
|
Karsten Hopp |
81c285 |
char_u smallbuf[SMBUFSIZE];
|
|
Karsten Hopp |
81c285 |
***************
|
|
Karsten Hopp |
81c285 |
*** 2987,2992 ****
|
|
Karsten Hopp |
81c285 |
--- 2989,2995 ----
|
|
Karsten Hopp |
81c285 |
/* must init bw_conv_buf and bw_iconv_fd before jumping to "fail" */
|
|
Karsten Hopp |
81c285 |
write_info.bw_conv_buf = NULL;
|
|
Karsten Hopp |
81c285 |
write_info.bw_conv_error = FALSE;
|
|
Karsten Hopp |
81c285 |
+ write_info.bw_conv_error_lnum = 0;
|
|
Karsten Hopp |
81c285 |
write_info.bw_restlen = 0;
|
|
Karsten Hopp |
81c285 |
# ifdef USE_ICONV
|
|
Karsten Hopp |
81c285 |
write_info.bw_iconv_fd = (iconv_t)-1;
|
|
Karsten Hopp |
81c285 |
***************
|
|
Karsten Hopp |
81c285 |
*** 4243,4248 ****
|
|
Karsten Hopp |
81c285 |
--- 4245,4251 ----
|
|
Karsten Hopp |
81c285 |
nchars += write_info.bw_len;
|
|
Karsten Hopp |
81c285 |
}
|
|
Karsten Hopp |
81c285 |
}
|
|
Karsten Hopp |
81c285 |
+ write_info.bw_start_lnum = start;
|
|
Karsten Hopp |
81c285 |
#endif
|
|
Karsten Hopp |
81c285 |
|
|
Karsten Hopp |
81c285 |
write_info.bw_len = bufsize;
|
|
Karsten Hopp |
81c285 |
***************
|
|
Karsten Hopp |
81c285 |
*** 4278,4283 ****
|
|
Karsten Hopp |
81c285 |
--- 4281,4289 ----
|
|
Karsten Hopp |
81c285 |
nchars += bufsize;
|
|
Karsten Hopp |
81c285 |
s = buffer;
|
|
Karsten Hopp |
81c285 |
len = 0;
|
|
Karsten Hopp |
81c285 |
+ #ifdef FEAT_MBYTE
|
|
Karsten Hopp |
81c285 |
+ write_info.bw_start_lnum = lnum;
|
|
Karsten Hopp |
81c285 |
+ #endif
|
|
Karsten Hopp |
81c285 |
}
|
|
Karsten Hopp |
81c285 |
/* write failed or last line has no EOL: stop here */
|
|
Karsten Hopp |
81c285 |
if (end == 0
|
|
Karsten Hopp |
81c285 |
***************
|
|
Karsten Hopp |
81c285 |
*** 4474,4480 ****
|
|
Karsten Hopp |
81c285 |
{
|
|
Karsten Hopp |
81c285 |
#ifdef FEAT_MBYTE
|
|
Karsten Hopp |
81c285 |
if (write_info.bw_conv_error)
|
|
Karsten Hopp |
81c285 |
! errmsg = (char_u *)_("E513: write error, conversion failed (make 'fenc' empty to override)");
|
|
Karsten Hopp |
81c285 |
else
|
|
Karsten Hopp |
81c285 |
#endif
|
|
Karsten Hopp |
81c285 |
if (got_int)
|
|
Karsten Hopp |
81c285 |
--- 4480,4496 ----
|
|
Karsten Hopp |
81c285 |
{
|
|
Karsten Hopp |
81c285 |
#ifdef FEAT_MBYTE
|
|
Karsten Hopp |
81c285 |
if (write_info.bw_conv_error)
|
|
Karsten Hopp |
81c285 |
! {
|
|
Karsten Hopp |
81c285 |
! if (write_info.bw_conv_error_lnum == 0)
|
|
Karsten Hopp |
81c285 |
! errmsg = (char_u *)_("E513: write error, conversion failed (make 'fenc' empty to override)");
|
|
Karsten Hopp |
81c285 |
! else
|
|
Karsten Hopp |
81c285 |
! {
|
|
Karsten Hopp |
81c285 |
! errmsg_allocated = TRUE;
|
|
Karsten Hopp |
81c285 |
! errmsg = alloc(300);
|
|
Karsten Hopp |
81c285 |
! vim_snprintf((char *)errmsg, 300, _("E513: write error, conversion failed in line %ld (make 'fenc' empty to override)"),
|
|
Karsten Hopp |
81c285 |
! (long)write_info.bw_conv_error_lnum);
|
|
Karsten Hopp |
81c285 |
! }
|
|
Karsten Hopp |
81c285 |
! }
|
|
Karsten Hopp |
81c285 |
else
|
|
Karsten Hopp |
81c285 |
#endif
|
|
Karsten Hopp |
81c285 |
if (got_int)
|
|
Karsten Hopp |
81c285 |
***************
|
|
Karsten Hopp |
81c285 |
*** 4550,4555 ****
|
|
Karsten Hopp |
81c285 |
--- 4566,4577 ----
|
|
Karsten Hopp |
81c285 |
{
|
|
Karsten Hopp |
81c285 |
STRCAT(IObuff, _(" CONVERSION ERROR"));
|
|
Karsten Hopp |
81c285 |
c = TRUE;
|
|
Karsten Hopp |
81c285 |
+ if (write_info.bw_conv_error_lnum != 0)
|
|
Karsten Hopp |
81c285 |
+ {
|
|
Karsten Hopp |
81c285 |
+ int l = STRLEN(IObuff);
|
|
Karsten Hopp |
81c285 |
+ vim_snprintf((char *)IObuff + l, IOSIZE - l, _(" in line %ld;"),
|
|
Karsten Hopp |
81c285 |
+ (long)write_info.bw_conv_error_lnum);
|
|
Karsten Hopp |
81c285 |
+ }
|
|
Karsten Hopp |
81c285 |
}
|
|
Karsten Hopp |
81c285 |
else if (notconverted)
|
|
Karsten Hopp |
81c285 |
{
|
|
Karsten Hopp |
81c285 |
***************
|
|
Karsten Hopp |
81c285 |
*** 4746,4751 ****
|
|
Karsten Hopp |
81c285 |
--- 4768,4775 ----
|
|
Karsten Hopp |
81c285 |
}
|
|
Karsten Hopp |
81c285 |
STRCAT(IObuff, errmsg);
|
|
Karsten Hopp |
81c285 |
emsg(IObuff);
|
|
Karsten Hopp |
81c285 |
+ if (errmsg_allocated)
|
|
Karsten Hopp |
81c285 |
+ vim_free(errmsg);
|
|
Karsten Hopp |
81c285 |
|
|
Karsten Hopp |
81c285 |
retval = FAIL;
|
|
Karsten Hopp |
81c285 |
if (end == 0)
|
|
Karsten Hopp |
81c285 |
***************
|
|
Karsten Hopp |
81c285 |
*** 5105,5111 ****
|
|
Karsten Hopp |
81c285 |
c = buf[wlen];
|
|
Karsten Hopp |
81c285 |
}
|
|
Karsten Hopp |
81c285 |
|
|
Karsten Hopp |
81c285 |
! ip->bw_conv_error |= ucs2bytes(c, &p, flags);
|
|
Karsten Hopp |
81c285 |
}
|
|
Karsten Hopp |
81c285 |
if (flags & FIO_LATIN1)
|
|
Karsten Hopp |
81c285 |
len = (int)(p - buf);
|
|
Karsten Hopp |
81c285 |
--- 5129,5141 ----
|
|
Karsten Hopp |
81c285 |
c = buf[wlen];
|
|
Karsten Hopp |
81c285 |
}
|
|
Karsten Hopp |
81c285 |
|
|
Karsten Hopp |
81c285 |
! if (ucs2bytes(c, &p, flags) && !ip->bw_conv_error)
|
|
Karsten Hopp |
81c285 |
! {
|
|
Karsten Hopp |
81c285 |
! ip->bw_conv_error = TRUE;
|
|
Karsten Hopp |
81c285 |
! ip->bw_conv_error_lnum = ip->bw_start_lnum;
|
|
Karsten Hopp |
81c285 |
! }
|
|
Karsten Hopp |
81c285 |
! if (c == NL)
|
|
Karsten Hopp |
81c285 |
! ++ip->bw_start_lnum;
|
|
Karsten Hopp |
81c285 |
}
|
|
Karsten Hopp |
81c285 |
if (flags & FIO_LATIN1)
|
|
Karsten Hopp |
81c285 |
len = (int)(p - buf);
|
|
Karsten Hopp |
81c285 |
***************
|
|
Karsten Hopp |
81c285 |
*** 5386,5391 ****
|
|
Karsten Hopp |
81c285 |
--- 5416,5422 ----
|
|
Karsten Hopp |
81c285 |
#ifdef FEAT_MBYTE
|
|
Karsten Hopp |
81c285 |
/*
|
|
Karsten Hopp |
81c285 |
* Convert a Unicode character to bytes.
|
|
Karsten Hopp |
81c285 |
+ * Return TRUE for an error, FALSE when it's OK.
|
|
Karsten Hopp |
81c285 |
*/
|
|
Karsten Hopp |
81c285 |
static int
|
|
Karsten Hopp |
81c285 |
ucs2bytes(c, pp, flags)
|
|
Karsten Hopp |
81c285 |
*** ../vim-7.2.243/src/version.c 2009-07-29 16:13:35.000000000 +0200
|
|
Karsten Hopp |
81c285 |
--- src/version.c 2009-07-29 18:01:27.000000000 +0200
|
|
Karsten Hopp |
81c285 |
***************
|
|
Karsten Hopp |
81c285 |
*** 678,679 ****
|
|
Karsten Hopp |
81c285 |
--- 678,681 ----
|
|
Karsten Hopp |
81c285 |
{ /* Add new patch number below this line */
|
|
Karsten Hopp |
81c285 |
+ /**/
|
|
Karsten Hopp |
81c285 |
+ 244,
|
|
Karsten Hopp |
81c285 |
/**/
|
|
Karsten Hopp |
81c285 |
|
|
Karsten Hopp |
81c285 |
--
|
|
Karsten Hopp |
81c285 |
Support your right to bare arms! Wear short sleeves!
|
|
Karsten Hopp |
81c285 |
|
|
Karsten Hopp |
81c285 |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
Karsten Hopp |
81c285 |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
Karsten Hopp |
81c285 |
\\\ download, build and distribute -- http://www.A-A-P.org ///
|
|
Karsten Hopp |
81c285 |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|