Karsten Hopp e33e6d
To: vim_dev@googlegroups.com
Karsten Hopp e33e6d
Subject: Patch 7.3.535
Karsten Hopp e33e6d
Fcc: outbox
Karsten Hopp e33e6d
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp e33e6d
Mime-Version: 1.0
Karsten Hopp e33e6d
Content-Type: text/plain; charset=UTF-8
Karsten Hopp e33e6d
Content-Transfer-Encoding: 8bit
Karsten Hopp e33e6d
------------
Karsten Hopp e33e6d
Karsten Hopp e33e6d
Patch 7.3.535
Karsten Hopp e33e6d
Problem:    Many #ifdefs for MB_MAXBYTES.
Karsten Hopp e33e6d
Solution:   Also define MB_MAXBYTES without the +multi_byte feature.  Fix
Karsten Hopp e33e6d
	    places where the buffer didn't include space for a NUL byte.
Karsten Hopp e33e6d
Files:	    src/arabic.c, src/edit.c, src/eval.c, src/getchar.c, src/mbyte.c,
Karsten Hopp e33e6d
	    src/misc1.c, src/screen.c, src/spell.c, src/vim.h
Karsten Hopp e33e6d
Karsten Hopp e33e6d
Karsten Hopp e33e6d
*** ../vim-7.3.534/src/arabic.c	2010-08-15 21:57:28.000000000 +0200
Karsten Hopp e33e6d
--- src/arabic.c	2012-06-01 14:59:37.000000000 +0200
Karsten Hopp e33e6d
***************
Karsten Hopp e33e6d
*** 1066,1072 ****
Karsten Hopp e33e6d
  
Karsten Hopp e33e6d
      if (curr_c != c && ccp != NULL)
Karsten Hopp e33e6d
      {
Karsten Hopp e33e6d
! 	char_u buf[MB_MAXBYTES];
Karsten Hopp e33e6d
  
Karsten Hopp e33e6d
  	/* Update the first byte of the character. */
Karsten Hopp e33e6d
  	(*mb_char2bytes)(curr_c, buf);
Karsten Hopp e33e6d
--- 1066,1072 ----
Karsten Hopp e33e6d
  
Karsten Hopp e33e6d
      if (curr_c != c && ccp != NULL)
Karsten Hopp e33e6d
      {
Karsten Hopp e33e6d
! 	char_u buf[MB_MAXBYTES + 1];
Karsten Hopp e33e6d
  
Karsten Hopp e33e6d
  	/* Update the first byte of the character. */
Karsten Hopp e33e6d
  	(*mb_char2bytes)(curr_c, buf);
Karsten Hopp e33e6d
*** ../vim-7.3.534/src/edit.c	2012-06-01 14:57:47.000000000 +0200
Karsten Hopp e33e6d
--- src/edit.c	2012-06-01 15:01:49.000000000 +0200
Karsten Hopp e33e6d
***************
Karsten Hopp e33e6d
*** 1648,1658 ****
Karsten Hopp e33e6d
  #define PC_STATUS_RIGHT	1	/* right halve of double-wide char */
Karsten Hopp e33e6d
  #define PC_STATUS_LEFT	2	/* left halve of double-wide char */
Karsten Hopp e33e6d
  #define PC_STATUS_SET	3	/* pc_bytes was filled */
Karsten Hopp e33e6d
- #ifdef FEAT_MBYTE
Karsten Hopp e33e6d
  static char_u pc_bytes[MB_MAXBYTES + 1]; /* saved bytes */
Karsten Hopp e33e6d
- #else
Karsten Hopp e33e6d
- static char_u pc_bytes[2];		/* saved bytes */
Karsten Hopp e33e6d
- #endif
Karsten Hopp e33e6d
  static int  pc_attr;
Karsten Hopp e33e6d
  static int  pc_row;
Karsten Hopp e33e6d
  static int  pc_col;
Karsten Hopp e33e6d
--- 1648,1654 ----
Karsten Hopp e33e6d
***************
Karsten Hopp e33e6d
*** 6819,6829 ****
Karsten Hopp e33e6d
      char_u	*s;
Karsten Hopp e33e6d
  
Karsten Hopp e33e6d
      vim_free(last_insert);
Karsten Hopp e33e6d
- #ifdef FEAT_MBYTE
Karsten Hopp e33e6d
      last_insert = alloc(MB_MAXBYTES * 3 + 5);
Karsten Hopp e33e6d
- #else
Karsten Hopp e33e6d
-     last_insert = alloc(6);
Karsten Hopp e33e6d
- #endif
Karsten Hopp e33e6d
      if (last_insert != NULL)
Karsten Hopp e33e6d
      {
Karsten Hopp e33e6d
  	s = last_insert;
Karsten Hopp e33e6d
--- 6815,6821 ----
Karsten Hopp e33e6d
***************
Karsten Hopp e33e6d
*** 6861,6867 ****
Karsten Hopp e33e6d
      char_u	*s;
Karsten Hopp e33e6d
  {
Karsten Hopp e33e6d
  #ifdef FEAT_MBYTE
Karsten Hopp e33e6d
!     char_u	temp[MB_MAXBYTES];
Karsten Hopp e33e6d
      int		i;
Karsten Hopp e33e6d
      int		len;
Karsten Hopp e33e6d
  
Karsten Hopp e33e6d
--- 6853,6859 ----
Karsten Hopp e33e6d
      char_u	*s;
Karsten Hopp e33e6d
  {
Karsten Hopp e33e6d
  #ifdef FEAT_MBYTE
Karsten Hopp e33e6d
!     char_u	temp[MB_MAXBYTES + 1];
Karsten Hopp e33e6d
      int		i;
Karsten Hopp e33e6d
      int		len;
Karsten Hopp e33e6d
  
Karsten Hopp e33e6d
***************
Karsten Hopp e33e6d
*** 7423,7429 ****
Karsten Hopp e33e6d
      int		cc;
Karsten Hopp e33e6d
  {
Karsten Hopp e33e6d
      int		n;
Karsten Hopp e33e6d
!     char_u	buf[MB_MAXBYTES];
Karsten Hopp e33e6d
      int		i;
Karsten Hopp e33e6d
      int		c;
Karsten Hopp e33e6d
  
Karsten Hopp e33e6d
--- 7415,7421 ----
Karsten Hopp e33e6d
      int		cc;
Karsten Hopp e33e6d
  {
Karsten Hopp e33e6d
      int		n;
Karsten Hopp e33e6d
!     char_u	buf[MB_MAXBYTES + 1];
Karsten Hopp e33e6d
      int		i;
Karsten Hopp e33e6d
      int		c;
Karsten Hopp e33e6d
  
Karsten Hopp e33e6d
***************
Karsten Hopp e33e6d
*** 10109,10119 ****
Karsten Hopp e33e6d
      int c;
Karsten Hopp e33e6d
  {
Karsten Hopp e33e6d
      char_u	*res;
Karsten Hopp e33e6d
- #ifdef FEAT_MBYTE
Karsten Hopp e33e6d
      char_u	buf[MB_MAXBYTES + 1];
Karsten Hopp e33e6d
- #else
Karsten Hopp e33e6d
-     char_u	buf[2];
Karsten Hopp e33e6d
- #endif
Karsten Hopp e33e6d
  
Karsten Hopp e33e6d
      /* Return quickly when there is nothing to do. */
Karsten Hopp e33e6d
      if (!has_insertcharpre())
Karsten Hopp e33e6d
--- 10101,10107 ----
Karsten Hopp e33e6d
*** ../vim-7.3.534/src/eval.c	2012-05-18 18:34:15.000000000 +0200
Karsten Hopp e33e6d
--- src/eval.c	2012-06-01 15:02:08.000000000 +0200
Karsten Hopp e33e6d
***************
Karsten Hopp e33e6d
*** 19170,19180 ****
Karsten Hopp e33e6d
  set_vim_var_char(c)
Karsten Hopp e33e6d
      int c;
Karsten Hopp e33e6d
  {
Karsten Hopp e33e6d
! #ifdef FEAT_MBYTE
Karsten Hopp e33e6d
!     char_u	buf[MB_MAXBYTES];
Karsten Hopp e33e6d
! #else
Karsten Hopp e33e6d
!     char_u	buf[2];
Karsten Hopp e33e6d
! #endif
Karsten Hopp e33e6d
  
Karsten Hopp e33e6d
  #ifdef FEAT_MBYTE
Karsten Hopp e33e6d
      if (has_mbyte)
Karsten Hopp e33e6d
--- 19170,19176 ----
Karsten Hopp e33e6d
  set_vim_var_char(c)
Karsten Hopp e33e6d
      int c;
Karsten Hopp e33e6d
  {
Karsten Hopp e33e6d
!     char_u	buf[MB_MAXBYTES + 1];
Karsten Hopp e33e6d
  
Karsten Hopp e33e6d
  #ifdef FEAT_MBYTE
Karsten Hopp e33e6d
      if (has_mbyte)
Karsten Hopp e33e6d
*** ../vim-7.3.534/src/getchar.c	2012-04-05 16:07:01.000000000 +0200
Karsten Hopp e33e6d
--- src/getchar.c	2012-06-01 15:03:51.000000000 +0200
Karsten Hopp e33e6d
***************
Karsten Hopp e33e6d
*** 723,729 ****
Karsten Hopp e33e6d
      int				c;
Karsten Hopp e33e6d
  #ifdef FEAT_MBYTE
Karsten Hopp e33e6d
      int				n;
Karsten Hopp e33e6d
!     char_u			buf[MB_MAXBYTES];
Karsten Hopp e33e6d
      int				i;
Karsten Hopp e33e6d
  #endif
Karsten Hopp e33e6d
  
Karsten Hopp e33e6d
--- 723,729 ----
Karsten Hopp e33e6d
      int				c;
Karsten Hopp e33e6d
  #ifdef FEAT_MBYTE
Karsten Hopp e33e6d
      int				n;
Karsten Hopp e33e6d
!     char_u			buf[MB_MAXBYTES + 1];
Karsten Hopp e33e6d
      int				i;
Karsten Hopp e33e6d
  #endif
Karsten Hopp e33e6d
  
Karsten Hopp e33e6d
***************
Karsten Hopp e33e6d
*** 1072,1078 ****
Karsten Hopp e33e6d
      int	    c;
Karsten Hopp e33e6d
  {
Karsten Hopp e33e6d
  #ifdef FEAT_MBYTE
Karsten Hopp e33e6d
!     char_u	buf[MB_MAXBYTES];
Karsten Hopp e33e6d
  #else
Karsten Hopp e33e6d
      char_u	buf[4];
Karsten Hopp e33e6d
  #endif
Karsten Hopp e33e6d
--- 1072,1078 ----
Karsten Hopp e33e6d
      int	    c;
Karsten Hopp e33e6d
  {
Karsten Hopp e33e6d
  #ifdef FEAT_MBYTE
Karsten Hopp e33e6d
!     char_u	buf[MB_MAXBYTES + 1];
Karsten Hopp e33e6d
  #else
Karsten Hopp e33e6d
      char_u	buf[4];
Karsten Hopp e33e6d
  #endif
Karsten Hopp e33e6d
***************
Karsten Hopp e33e6d
*** 1547,1553 ****
Karsten Hopp e33e6d
      int		c, c2;
Karsten Hopp e33e6d
  #ifdef FEAT_MBYTE
Karsten Hopp e33e6d
      int		n;
Karsten Hopp e33e6d
!     char_u	buf[MB_MAXBYTES];
Karsten Hopp e33e6d
      int		i;
Karsten Hopp e33e6d
  #endif
Karsten Hopp e33e6d
  
Karsten Hopp e33e6d
--- 1547,1553 ----
Karsten Hopp e33e6d
      int		c, c2;
Karsten Hopp e33e6d
  #ifdef FEAT_MBYTE
Karsten Hopp e33e6d
      int		n;
Karsten Hopp e33e6d
!     char_u	buf[MB_MAXBYTES + 1];
Karsten Hopp e33e6d
      int		i;
Karsten Hopp e33e6d
  #endif
Karsten Hopp e33e6d
  
Karsten Hopp e33e6d
***************
Karsten Hopp e33e6d
*** 4335,4345 ****
Karsten Hopp e33e6d
      int		scol;		/* starting column of the abbr. */
Karsten Hopp e33e6d
      int		j;
Karsten Hopp e33e6d
      char_u	*s;
Karsten Hopp e33e6d
- #ifdef FEAT_MBYTE
Karsten Hopp e33e6d
      char_u	tb[MB_MAXBYTES + 4];
Karsten Hopp e33e6d
- #else
Karsten Hopp e33e6d
-     char_u	tb[4];
Karsten Hopp e33e6d
- #endif
Karsten Hopp e33e6d
      mapblock_T	*mp;
Karsten Hopp e33e6d
  #ifdef FEAT_LOCALMAP
Karsten Hopp e33e6d
      mapblock_T	*mp2;
Karsten Hopp e33e6d
--- 4335,4341 ----
Karsten Hopp e33e6d
*** ../vim-7.3.534/src/mbyte.c	2012-03-07 19:38:52.000000000 +0100
Karsten Hopp e33e6d
--- src/mbyte.c	2012-06-01 15:04:27.000000000 +0200
Karsten Hopp e33e6d
***************
Karsten Hopp e33e6d
*** 708,714 ****
Karsten Hopp e33e6d
  	     */
Karsten Hopp e33e6d
  	    n = (i & 0x80) ? 2 : 1;
Karsten Hopp e33e6d
  # else
Karsten Hopp e33e6d
! 	    char buf[MB_MAXBYTES];
Karsten Hopp e33e6d
  # ifdef X_LOCALE
Karsten Hopp e33e6d
  #  ifndef mblen
Karsten Hopp e33e6d
  #   define mblen _Xmblen
Karsten Hopp e33e6d
--- 708,714 ----
Karsten Hopp e33e6d
  	     */
Karsten Hopp e33e6d
  	    n = (i & 0x80) ? 2 : 1;
Karsten Hopp e33e6d
  # else
Karsten Hopp e33e6d
! 	    char buf[MB_MAXBYTES + 1];
Karsten Hopp e33e6d
  # ifdef X_LOCALE
Karsten Hopp e33e6d
  #  ifndef mblen
Karsten Hopp e33e6d
  #   define mblen _Xmblen
Karsten Hopp e33e6d
***************
Karsten Hopp e33e6d
*** 1953,1959 ****
Karsten Hopp e33e6d
  /*
Karsten Hopp e33e6d
   * Convert the character at screen position "off" to a sequence of bytes.
Karsten Hopp e33e6d
   * Includes the composing characters.
Karsten Hopp e33e6d
!  * "buf" must at least have the length MB_MAXBYTES.
Karsten Hopp e33e6d
   * Only to be used when ScreenLinesUC[off] != 0.
Karsten Hopp e33e6d
   * Returns the produced number of bytes.
Karsten Hopp e33e6d
   */
Karsten Hopp e33e6d
--- 1953,1959 ----
Karsten Hopp e33e6d
  /*
Karsten Hopp e33e6d
   * Convert the character at screen position "off" to a sequence of bytes.
Karsten Hopp e33e6d
   * Includes the composing characters.
Karsten Hopp e33e6d
!  * "buf" must at least have the length MB_MAXBYTES + 1.
Karsten Hopp e33e6d
   * Only to be used when ScreenLinesUC[off] != 0.
Karsten Hopp e33e6d
   * Returns the produced number of bytes.
Karsten Hopp e33e6d
   */
Karsten Hopp e33e6d
*** ../vim-7.3.534/src/misc1.c	2012-04-30 21:09:38.000000000 +0200
Karsten Hopp e33e6d
--- src/misc1.c	2012-06-01 15:04:56.000000000 +0200
Karsten Hopp e33e6d
***************
Karsten Hopp e33e6d
*** 1932,1938 ****
Karsten Hopp e33e6d
      int		c;
Karsten Hopp e33e6d
  {
Karsten Hopp e33e6d
  #if defined(FEAT_MBYTE) || defined(PROTO)
Karsten Hopp e33e6d
!     char_u	buf[MB_MAXBYTES];
Karsten Hopp e33e6d
      int		n;
Karsten Hopp e33e6d
  
Karsten Hopp e33e6d
      n = (*mb_char2bytes)(c, buf);
Karsten Hopp e33e6d
--- 1932,1938 ----
Karsten Hopp e33e6d
      int		c;
Karsten Hopp e33e6d
  {
Karsten Hopp e33e6d
  #if defined(FEAT_MBYTE) || defined(PROTO)
Karsten Hopp e33e6d
!     char_u	buf[MB_MAXBYTES + 1];
Karsten Hopp e33e6d
      int		n;
Karsten Hopp e33e6d
  
Karsten Hopp e33e6d
      n = (*mb_char2bytes)(c, buf);
Karsten Hopp e33e6d
*** ../vim-7.3.534/src/screen.c	2012-03-23 16:25:13.000000000 +0100
Karsten Hopp e33e6d
--- src/screen.c	2012-06-01 15:06:03.000000000 +0200
Karsten Hopp e33e6d
***************
Karsten Hopp e33e6d
*** 6621,6636 ****
Karsten Hopp e33e6d
      int	    row, col;
Karsten Hopp e33e6d
      int	    attr;
Karsten Hopp e33e6d
  {
Karsten Hopp e33e6d
- #ifdef FEAT_MBYTE
Karsten Hopp e33e6d
      char_u	buf[MB_MAXBYTES + 1];
Karsten Hopp e33e6d
  
Karsten Hopp e33e6d
!     buf[(*mb_char2bytes)(c, buf)] = NUL;
Karsten Hopp e33e6d
! #else
Karsten Hopp e33e6d
!     char_u	buf[2];
Karsten Hopp e33e6d
! 
Karsten Hopp e33e6d
!     buf[0] = c;
Karsten Hopp e33e6d
!     buf[1] = NUL;
Karsten Hopp e33e6d
  #endif
Karsten Hopp e33e6d
      screen_puts(buf, row, col, attr);
Karsten Hopp e33e6d
  }
Karsten Hopp e33e6d
  
Karsten Hopp e33e6d
--- 6621,6637 ----
Karsten Hopp e33e6d
      int	    row, col;
Karsten Hopp e33e6d
      int	    attr;
Karsten Hopp e33e6d
  {
Karsten Hopp e33e6d
      char_u	buf[MB_MAXBYTES + 1];
Karsten Hopp e33e6d
  
Karsten Hopp e33e6d
! #ifdef FEAT_MBYTE
Karsten Hopp e33e6d
!     if (has_mbyte)
Karsten Hopp e33e6d
! 	buf[(*mb_char2bytes)(c, buf)] = NUL;
Karsten Hopp e33e6d
!     else
Karsten Hopp e33e6d
  #endif
Karsten Hopp e33e6d
+     {
Karsten Hopp e33e6d
+ 	buf[0] = c;
Karsten Hopp e33e6d
+ 	buf[1] = NUL;
Karsten Hopp e33e6d
+     }
Karsten Hopp e33e6d
      screen_puts(buf, row, col, attr);
Karsten Hopp e33e6d
  }
Karsten Hopp e33e6d
  
Karsten Hopp e33e6d
*** ../vim-7.3.534/src/spell.c	2012-05-18 18:07:57.000000000 +0200
Karsten Hopp e33e6d
--- src/spell.c	2012-06-01 15:06:30.000000000 +0200
Karsten Hopp e33e6d
***************
Karsten Hopp e33e6d
*** 13694,13700 ****
Karsten Hopp e33e6d
  {
Karsten Hopp e33e6d
      int		m1, m2;
Karsten Hopp e33e6d
  #ifdef FEAT_MBYTE
Karsten Hopp e33e6d
!     char_u	buf[MB_MAXBYTES];
Karsten Hopp e33e6d
      hashitem_T  *hi;
Karsten Hopp e33e6d
  
Karsten Hopp e33e6d
      if (c1 >= 256)
Karsten Hopp e33e6d
--- 13694,13700 ----
Karsten Hopp e33e6d
  {
Karsten Hopp e33e6d
      int		m1, m2;
Karsten Hopp e33e6d
  #ifdef FEAT_MBYTE
Karsten Hopp e33e6d
!     char_u	buf[MB_MAXBYTES + 1];
Karsten Hopp e33e6d
      hashitem_T  *hi;
Karsten Hopp e33e6d
  
Karsten Hopp e33e6d
      if (c1 >= 256)
Karsten Hopp e33e6d
*** ../vim-7.3.534/src/vim.h	2012-04-30 18:48:38.000000000 +0200
Karsten Hopp e33e6d
--- src/vim.h	2012-06-01 14:59:28.000000000 +0200
Karsten Hopp e33e6d
***************
Karsten Hopp e33e6d
*** 1703,1708 ****
Karsten Hopp e33e6d
--- 1703,1710 ----
Karsten Hopp e33e6d
   * character of up to 6 bytes, or one 16-bit character of up to three bytes
Karsten Hopp e33e6d
   * plus six following composing characters of three bytes each. */
Karsten Hopp e33e6d
  # define MB_MAXBYTES	21
Karsten Hopp e33e6d
+ #else
Karsten Hopp e33e6d
+ # define MB_MAXBYTES	1
Karsten Hopp e33e6d
  #endif
Karsten Hopp e33e6d
  
Karsten Hopp e33e6d
  #if (defined(FEAT_PROFILE) || defined(FEAT_RELTIME)) && !defined(PROTO)
Karsten Hopp e33e6d
***************
Karsten Hopp e33e6d
*** 2017,2022 ****
Karsten Hopp e33e6d
--- 2019,2025 ----
Karsten Hopp e33e6d
   #pragma warning(disable : 4312)
Karsten Hopp e33e6d
  #endif
Karsten Hopp e33e6d
  
Karsten Hopp e33e6d
+ /* Note: a NULL argument for vim_realloc() is not portable, don't use it. */
Karsten Hopp e33e6d
  #if defined(MEM_PROFILE)
Karsten Hopp e33e6d
  # define vim_realloc(ptr, size)  mem_realloc((ptr), (size))
Karsten Hopp e33e6d
  #else
Karsten Hopp e33e6d
*** ../vim-7.3.534/src/version.c	2012-06-01 14:57:47.000000000 +0200
Karsten Hopp e33e6d
--- src/version.c	2012-06-01 15:08:20.000000000 +0200
Karsten Hopp e33e6d
***************
Karsten Hopp e33e6d
*** 716,717 ****
Karsten Hopp e33e6d
--- 716,719 ----
Karsten Hopp e33e6d
  {   /* Add new patch number below this line */
Karsten Hopp e33e6d
+ /**/
Karsten Hopp e33e6d
+     535,
Karsten Hopp e33e6d
  /**/
Karsten Hopp e33e6d
Karsten Hopp e33e6d
-- 
Karsten Hopp e33e6d
Me?  A skeptic?  I trust you have proof.
Karsten Hopp e33e6d
Karsten Hopp e33e6d
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp e33e6d
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp e33e6d
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp e33e6d
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///