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